Nostrum.Api.Invite (nostrum v0.11.0-dev)

View Source

Functions for interacting with the Discord API's invite endpoints.

See: https://discord.com/developers/docs/resources/invite

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

channel_invites(channel_id)

(since 0.10.1)

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{} | _]}

create(channel_id, options \\ [], reason \\ nil)

(since 0.10.1)

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{}}

delete(invite_code)

(since 0.10.1)

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")

get(invite_code, options \\ [])

(since 0.10.1)

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)

guild_invites(guild_id)

(since 0.10.1)

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{} | _]}