View Source Nostrum.Api.Invite (Nostrum v0.10.4)
Functions for interacting with the Discord API's invite endpoints.
Summary
Functions
Gets a list of invites for a channel.
Creates an invite for a guild channel.
Deletes an invite by its invite_code.
Gets an invite by its invite_code.
Gets a list of invites for a guild.
Functions
@spec channel_invites(Nostrum.Struct.Channel.id()) :: Nostrum.Api.error() | {:ok, [Nostrum.Struct.Invite.detailed_invite()]}
Gets a list of invites for a channel.
This endpoint requires the 'VIEW_CHANNEL' and 'MANAGE_CHANNELS' permissions.
If successful, returns {:ok, invite}. Otherwise, returns a
Nostrum.Api.error/0.
Examples
iex> Nostrum.Api.Invite.channel_invites(43189401384091)
{:ok, [%Nostrum.Struct.Invite{} | _]}
@spec create( Nostrum.Struct.Channel.id(), Nostrum.Api.options(), Nostrum.Struct.Guild.AuditLogEntry.reason() ) :: Nostrum.Api.error() | {:ok, Nostrum.Struct.Invite.detailed_invite()}
Creates an invite for a guild channel.
An optional reason can be provided for the audit log.
This endpoint requires the CREATE_INSTANT_INVITE permission.
If successful, returns {:ok, invite}. Otherwise, returns a Nostrum.Api.error/0.
Options
:max_age(integer) - duration of invite in seconds before expiry, or 0 for never. (default:86400):max_uses(integer) - max number of uses or 0 for unlimited. (default:0):temporary(boolean) - Whether the invite should grant temporary membership. (default:false):unique(boolean) - used when creating unique one time use invites. (default:false)
Examples
Nostrum.Api.Invite.create(41771983423143933)
{:ok, Nostrum.Struct.Invite{}}
Nostrum.Api.Invite.create(41771983423143933, max_uses: 20)
{:ok, %Nostrum.Struct.Invite{}}
@spec delete(Nostrum.Struct.Invite.code()) :: Nostrum.Api.error() | {:ok, Nostrum.Struct.Invite.simple_invite()}
Deletes an invite by its invite_code.
This endpoint requires the MANAGE_CHANNELS permission.
If successful, returns {:ok, invite}. Otherwise, returns a
Nostrum.Api.error/0.
Examples
Nostrum.Api.Invite.delete("zsjUsC")
@spec get(Nostrum.Struct.Invite.code(), Nostrum.Api.options()) :: Nostrum.Api.error() | {:ok, Nostrum.Struct.Invite.simple_invite()}
Gets an invite by its invite_code.
If successful, returns {:ok, invite}. Otherwise, returns a
Nostrum.Api.error/0.
Options
:with_counts(boolean) - whether to include member count fields
Examples
Nostrum.Api.Invite.get("zsjUsC")
Nostrum.Api.Invite.get("zsjUsC", with_counts: true)
@spec guild_invites(Nostrum.Struct.Guild.id()) :: Nostrum.Api.error() | {:ok, [Nostrum.Struct.Invite.detailed_invite()]}
Gets a list of invites for a guild.
This endpoint requires the MANAGE_GUILD permission.
If successful, returns {:ok, invites}. Otherwise, returns a Nostrum.Api.error/0.
Examples
Nostrum.Api.Invite.guild_invites(81384788765712384)
{:ok, [%Nostrum.Struct.Invite{} | _]}