crux_rest v0.1.3 Crux.Rest View Source

Collection of Rest functions.

Link to this section Summary

Types

Used to add a member to a guild via add_guild_member/3

Used to send messages via create_message/2

Used to edit overwrites for a role or member with edit_channel_permissions/3

Used to send and embed via create_message/2

Used to attach files via create_message/2

Used to get messages from the api via get_messages/2

Used to get more specific users who reacted to a message from the api via get_reactions/4

Used to create a role in a guild with create_guild_role/2

Used to edit messages via edit_message/2 or edit_message/3

Used to modify a channel via modify_channel/2

Used to modify a guild emoji via modify_guild_emoji/3

Used to modify a member with modify_guild_member/3

A Discord snowflake, fits in a 64bit integer

Functions

Adds a user to a guild via a provided oauth2 access token with the guilds.join scope

Adds a message to the pinned messages of a channel

Adds a message to the pinned messages of a channel

Prunes members in a guild

Creates an invite to a channel, see t:create_channel_invite_data for available options

Bans a user from a guild, the user does not have to be part of the guild

Creates a channel in a guild, see t:create_guild_channel_data for available options

Creates an emoji in a guild, see t:create_guild_emoji_data for available options

Attaches an integration from the current user to a guild

Sends a message to a channel

Creates a reaction on a message, or increases its count by one

Creates a reaction on a message, or increases its count by one

Creates a role in a guild

Deletes all reactions from a messaage

Deletes all reactions from a messaage

Deletes a guild, can only be used if the executing user is the owner

Deletes an emoji from a guild

Deletes an integration from a guild

Deletes an invite

Deletes a message

Deletes 2-100 messages not older than 14 days

Deletes a message from the pinned messages. This does not delete the message itself

Deletes a message from the pinned messages. This does not delete the message itself

Edits or creates an overwrite for a user, or member

Edits a message

Fetches the gateway url from the api

Fetches the gateway url along a recommended shards count from the api

Gets a channel from the api.
This should NOT be necessary

Gets invites for the specified channel from the api

Gets a guild from the api.
This should usually, due to cache, NOT be necessary

Fetches a single ban entry by id

Fetches a map of banned users along their ban reasons

Gets all channels from a guild via the api.
This should usually, due to caching, NOT be necessary

Fetches a guild’s embed (server widget)

Gets an emoji from a guild
This should usually, due to cache, NOT be necessary

Fetches a list of guild integrations

Fetches all available invites in a guild

Fetches a member from the api

Fetches the number of members in a guild that would be removed when pruned

Fetches a list of roles in a guild.
This should usually, due to caching, NOT be necessary

Fetches the vanity url of a guild, if any

Fetches a list of voice regions for a guild. Returns VIP servers when the guild is VIP-enabled

Fetches an invite from the api

Gets a message from the api

Gets 1-100 messages from the api, this limit is enforced on discord’s end

Gets a list of pinned messages from the api

Gets a list of emojis in a guild.
This should usually, due to cache, NOT be necessary

Gets a list of members from the guild

Modifies a channel, see t:modify_channel_data for available options

Modifies the nickname of the current user in a guild

Updates a guild, see t:modify_guild_data for available options

Modifyies the position of a list of channels in a guild

Modifies a guild’s embed (server widget)

Modifies an integreation for a guild

Modifies a member in a guild

Modifies a role in a guild

Modifies the positions of a list of role objects for a guild

Removes a ban for a user from a guild

Syncs an integration for a guild

Lets the bot appear as typing for roughly ~9 seconds or until a message is sent.
Should generally be used sparingly for commands that may take a while as a form of acknowledging

Link to this section Types

Link to this type add_guild_member_data() View Source
add_guild_member_data() ::
  %{
    :access_token => String.t(),
    optional(:nick) => String.t() | nil,
    optional(:roles) => [snowflake()],
    optional(:mute) => boolean(),
    optional(:deaf) => boolean(),
    optional(:reason) => String.t()
  }
  | [
      access_token: String.t(),
      nick: String.t() | nil,
      roles: [snowflake()],
      mute: boolean(),
      deaf: boolean(),
      reason: String.t()
    ]

Used to add a member to a guild via add_guild_member/3.

Link to this type create_channel_invite_data() View Source
create_channel_invite_data() ::
  %{
    optional(:max_age) => non_neg_integer(),
    optional(:max_uses) => non_neg_integer(),
    optional(:temporary) => boolean(),
    optional(:unique) => boolean(),
    optional(:reason) => String.t()
  }
  | [
      max_age: non_neg_integer(),
      max_uses: non_neg_integer(),
      temporary: boolean(),
      unique: boolean(),
      reason: String.t()
    ]

Used to create invites via create_channel_invite/2.

Notes:

  • :max_age 0 indicates no max age, defaults to 86_400 (1 day)
  • :max_uses 0 indicates no max uses, defaults to 0
  • :temporary if true, members which do not get a role assigned within 24 hours get automatically kicked, defaults to false
  • :unique if true, always creates a new invite instead of maybe returning a similar one, defaults to false

    For more informations see Discord Docs.

Link to this type create_guild_channel_data() View Source
create_guild_channel_data() ::
  %{
    optional(:name) => String.t(),
    optional(:type) => non_neg_integer(),
    optional(:bitrate) => non_neg_integer() | nil,
    optional(:user_limit) => integer() | nil,
    optional(:permission_overwrites) => [
      Overwrite.t()
      | %{
          :id => snowflake(),
          :type => String.t(),
          optional(:allow) => non_neg_integer(),
          optional(:deny) => non_neg_integer()
        }
    ],
    optional(:parent_id) => snowflake() | nil,
    optional(:nsfw) => boolean(),
    optional(:reason) => String.t()
  }
  | [
      name: String.t(),
      type: pos_integer(),
      bitrate: non_neg_integer() | nil,
      user_limit: integer() | nil,
      permission_overwrites: [
        Overwrite.t()
        | %{
            :id => snowflake(),
            :type => String.t(),
            optional(:allow) => non_neg_integer(),
            optional(:deny) => non_neg_integer()
          }
      ],
      parent_id: snowflake() | nil,
      nsfw: boolean(),
      reason: String.t()
    ]

Used to create a channel via create_guild_channel/2.

Notes:

  • :name has to be [2-100] chars and may only contain [a-Z_-]
Link to this type create_guild_emoji_data() View Source
create_guild_emoji_data() ::
  %{
    :name => String.t(),
    :image => String.t() | binary(),
    optional(:roles) => [Crux.Structs.Role.t() | snowflake()],
    optional(:reason) => String.t()
  }
  | [
      name: String.t(),
      image: String.t() | binary(),
      roles: [Crux.Structs.Role.t() | snowflake()],
      reason: String.t()
    ]

Used to create emojis via create_guild_emoji/2.

Notes:

  • :name has to be [1-32] chars long, valid chars are [a-Z0-9] (invalid chars may get filtered out instead of erroring).
    A 1 char long name gets suffixed with `
    ` to be 2 chars long.
  • :image may not be larger than 256kb
  • :roles, if present limits the emoji to only those roles
Link to this type create_message_data() View Source
create_message_data() ::
  %{
    optional(:content) => String.t(),
    optional(:nonce) => non_neg_integer(),
    optional(:tts) => boolean(),
    optional(:embed) => embed(),
    optional(:files) => [file_list_entry()]
  }
  | [
      content: String.t(),
      nonce: non_neg_integer(),
      tts: boolean(),
      embed: embed(),
      files: [file_list_entry()]
    ]

Used to send messages via create_message/2.

The content my not exceed 2000 chars.
The nonce has to fit in a 64 bit integer.
The whole message payload may not be larger than 8mb, this should only be possible when attaching (a) large file(s).

Link to this type edit_channel_permissions_data() View Source
edit_channel_permissions_data() ::
  %{
    optional(:allow) => non_neg_integer(),
    optional(:deny) => non_neg_integer(),
    optional(:type) => String.t(),
    optional(:reason) => String.t()
  }
  | {{:allow, non_neg_integer()}
     | {:deny, non_neg_integer()}
     | {:type, :member | :role | String.t()}
     | {:reason, String.t()}}

Used to edit overwrites for a role or member with edit_channel_permissions/3

See Permissions for available bitflags.

Link to this type embed() View Source
embed() :: %{
  optional(:title) => String.t(),
  optional(:description) => String.t(),
  optional(:url) => String.t(),
  optional(:timestamp) => String.t(),
  optional(:color) => non_neg_integer(),
  optional(:footer) => %{
    optional(:text) => String.t(),
    optional(:icon_url) => String.t()
  },
  optional(:image) => %{optional(:url) => String.t()},
  optional(:thumbnail) => %{optional(:url) => String.t()},
  optional(:author) => %{
    optional(:name) => String.t(),
    optional(:url) => String.t(),
    optional(:icon_url) => String.t()
  },
  optional(:fields) => [
    %{:name => String.t(), :value => String.t(), optional(:inline) => boolean()}
  ]
}

Used to send and embed via create_message/2.

You should probably consult the Embed Limits page.

Link to this type file_list_entry() View Source
file_list_entry() :: String.t() | {String.t(), String.t()}

Used to attach files via create_message/2.

This can be one of:

Example
path/home/user/image.png / https://example.com/image.png
{path, name}{one of the above, "other_name.png"}
{binary, name}{<<0, 0, 0, 0>>, "other_name.png"}
Link to this type get_messages_data() View Source
get_messages_data() ::
  %{
    optional(:around) => snowflake(),
    optional(:before) => snowflake(),
    optional(:after) => snowflake(),
    optional(:limit) => pos_integer()
  }
  | [
      around: snowflake(),
      before: snowflake(),
      after: snowflake(),
      limit: pos_integer()
    ]

Used to get messages from the api via get_messages/2.

Notes:

  • :around is inclusive
  • :before and :after are exclusive
  • :limit has to be [1-100], defaults to 50
Link to this type get_reactions_data() View Source
get_reactions_data() ::
  %{
    optional(:before) => snowflake(),
    optional(:after) => snowflake(),
    optional(:limit) => pos_integer()
  }
  | [before: snowflake(), after: snowflake(), limit: pos_integer()]

Used to get more specific users who reacted to a message from the api via get_reactions/4

Notes:

  • :before seems currently broken on discord’s end
  • :after is exclusive
Link to this type guild_role_data() View Source
guild_role_data() ::
  %{
    optional(:name) => String.t(),
    optional(:permissions) => non_neg_integer(),
    optional(:color) => non_neg_integer(),
    optional(:hoist) => boolean(),
    optional(:mentionable) => boolean(),
    optional(:reason) => String.t()
  }
  | [
      name: String.t(),
      permissions: non_neg_integer(),
      color: non_neg_integer(),
      hoist: boolean(),
      mentionable: boolean(),
      reason: String.t()
    ]

Used to create a role in a guild with create_guild_role/2.

Link to this type list_guild_members_options() View Source
list_guild_members_options() ::
  %{optional(:limit) => pos_integer(), optional(:after) => snowflake()}
  | [limit: pos_integer(), after: snowflake()]
Link to this type message_edit_data() View Source
message_edit_data() ::
  %{optional(:content) => String.t() | nil, optional(:embed) => embed() | nil}
  | [content: String.t(), embed: embed()]

Used to edit messages via edit_message/2 or edit_message/3.

The content my not exceed 2000 chars, this limit is enfored on discord’s end.

Link to this type modify_channel_data() View Source
modify_channel_data() ::
  %{
    optional(:name) => String.t() | nil,
    optional(:position) => non_neg_integer(),
    optional(:topic) => String.t() | nil,
    optional(:nsfw) => boolean(),
    optional(:bitrate) => non_neg_integer(),
    optional(:user_limit) => non_neg_integer() | nil,
    optional(:permission_overwrites) => [Overwrite.t()],
    optional(:parent_id) => snowflake() | nil,
    optional(:reason) => String.t()
  }
  | [
      name: String.t() | nil,
      position: non_neg_integer(),
      topic: String.t() | nil,
      nsfw: boolean(),
      bitrate: non_neg_integer(),
      user_limit: integer() | nil,
      overwrites: [Overwrite.t()],
      parent_id: snowflake() | nil,
      reason: String.t()
    ]

Used to modify a channel via modify_channel/2.

Notes

  • :name has to be [2-100] chars long.
  • :topic has to be [0-1024] chars long
  • :bitrate is in bits [8_000-96_000] (128_000 for VIP servers)
  • :user_limit has to be [0-99], 0 refers to no limit

    For more informations see Discord Docs.

Link to this type modify_guild_channel_positions_data_entry() View Source
modify_guild_channel_positions_data_entry() ::
  {Crux.Structs.Channel.t(), integer()}
  | {snowflake(), integer()}
  | %{channel: Crux.Structs.Channel.t(), position: integer()}
  | %{id: snowflake(), position: integer()}
Link to this type modify_guild_data() View Source
modify_guild_data() ::
  %{
    optional(:name) => String.t(),
    optional(:region) => String.t(),
    optional(:verification_level) => non_neg_integer(),
    optional(:default_message_notifications) => non_neg_integer(),
    optional(:explicit_content_filter) => non_neg_integer(),
    optional(:afk_channel_id) => snowflake() | nil,
    optional(:afk_timeout) => non_neg_integer(),
    optional(:icon) => String.t() | binary() | nil,
    optional(:splash) => String.t() | binary() | nil,
    optional(:owner_id) => snowflake(),
    optional(:system_channel_id) => snowflake() | nil,
    optional(:reason) => String.t()
  }
  | [
      name: String.t(),
      region: String.t(),
      verification_level: non_neg_integer(),
      default_message_notifications: non_neg_integer(),
      explicit_content_filter: non_neg_integer(),
      afk_channel_id: snowflake() | nil,
      afk_timeout: non_neg_integer(),
      icon: String.t() | binary() | nil,
      splash: String.t() | binary() | nil,
      owner_id: snowflake(),
      system_channel_id: snowflake() | nil,
      reason: String.t()
    ]

TBD, see modify_guild/2

Link to this type modify_guild_emoji_data() View Source
modify_guild_emoji_data() ::
  %{
    optional(:name) => String.t(),
    optional(:roles) => [Crux.Structs.Role.t() | snowflake()],
    optional(:reason) => String.t()
  } :: [
    name: String.t(),
    roles: [Crux.Structs.Role.t() | snowflake()],
    reason: String.t()
  ]

Used to modify a guild emoji via modify_guild_emoji/3.

See t:create_guild_emoji_data for name restrictions.

Link to this type modify_guild_member_data() View Source
modify_guild_member_data() ::
  %{
    optional(:nick) => String.t() | nil,
    optional(:roles) => [snowflake()],
    optional(:mute) => boolean(),
    optional(:deaf) => boolean(),
    optional(:channel_id) => snowflake(),
    optional(:reason) => String.t()
  }
  | [
      nick: String.t() | nil,
      roles: [snowflake()],
      mute: boolean(),
      deaf: boolean(),
      channel_id: snowflake(),
      reason: String.t()
    ]

Used to modify a member with modify_guild_member/3.

Notes:

* `:mute`, `:deaf`, and `:channel_id` will silently be discarded by discord if the member is not connected to a voice channel.

A Discord snowflake, fits in a 64bit integer.

Received as integers via the gateway, but as strings via http.

They are normalized to integers via Crux.Structs.

Link to this section Functions

Link to this function add_guild_member(guild, user, data) View Source
add_guild_member(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  user :: Crux.Rest.Util.user_id_resolvable(),
  data :: add_guild_member_data()
) :: {:ok, Crux.Structs.Member.t()} | {:error, term()}

Adds a user to a guild via a provided oauth2 access token with the guilds.join scope.

For more informations see Discord Docs.

Link to this function add_guild_member_role(guild, member, role, reason \\ nil) View Source
add_guild_member_role(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  member :: Crux.Rest.Util.user_id_resolvable(),
  role :: Crux.Rest.Util.role_id_resolvable(),
  reason :: String.t()
) :: :ok | {:error, term()}

Adds a role to a member.

For more informations see Discord Docs.

Link to this function add_pinned_message(message) View Source
add_pinned_message(message :: Crux.Structs.Message.t()) ::
  :ok | {:error, term()}

Adds a message to the pinned messages of a channel.

You may only have up to 50 pinned messages per channel.
For more informations see Discord Docs.

Link to this function add_pinned_message(channel, message) View Source
add_pinned_message(
  channel :: Crux.Rest.Util.channel_id_resolvable(),
  message :: Crux.Rest.Util.message_id_resolvable()
) :: :ok | {:error, term()}

Adds a message to the pinned messages of a channel.

You may only have up to 50 pinned messages per channel.
For more informations see Discord Docs.

Link to this function begin_guild_prune(guild, days) View Source
begin_guild_prune(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  days :: pos_integer()
) :: {:ok, non_neg_integer()} | {:error, term()}

Prunes members in a guild.

For more informations see Discord Docs.

Link to this function create_channel_invite(channel, args) View Source
create_channel_invite(
  channel :: Crux.Rest.Util.channel_id_resolvable(),
  args :: create_channel_invite_data()
) :: {:ok, Crux.Structs.Invite.t()} | {:error, term()}

Creates an invite to a channel, see t:create_channel_invite_data for available options.

For more informations see Discord Docs.

Link to this function create_guild_ban(guild, user, reason \\ nil) View Source
create_guild_ban(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  user :: Crux.Rest.Util.user_id_resolvable(),
  reason :: String.t()
) :: :ok | {:error, term()}

Bans a user from a guild, the user does not have to be part of the guild.

For more informations see Discord Docs.

Link to this function create_guild_channel(guild, data) View Source
create_guild_channel(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  data :: create_guild_channel_data()
) :: {:ok, Crux.Structs.Channel.t()} | {:error, term()}

Creates a channel in a guild, see t:create_guild_channel_data for available options.

For more informations see Discord Docs.

Link to this function create_guild_emoji(guild, data) View Source
create_guild_emoji(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  data :: create_guild_emoji_data()
) :: {:ok, Crux.Structs.Emoji} | {:error, term()}

Creates an emoji in a guild, see t:create_guild_emoji_data for available options.

For more informations see Discord Docs.

Link to this function create_guild_integration(guild, data) View Source
create_guild_integration(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  data ::
    %{type: String.t(), id: snowflake()} | [type: String.t(), id: snowflake()]
) :: :ok | {:error, term()}

Attaches an integration from the current user to a guild.

For more informations see Discord Docs.

Link to this function create_message(channel_or_message, args) View Source
create_message(
  channel :: Crux.Rest.Util.channel_id_resolvable(),
  args :: create_message_data()
) :: {:ok, Crux.Structs.Message.t()} | {:error, term()}

Sends a message to a channel.

For more informations see Discord Docs

Link to this function create_reaction(message, emoji) View Source
create_reaction(
  message :: Crux.Rest.Util.message_id_resolvable(),
  emoji :: Crux.Rest.Util.emoji_identifier_resolvable()
) :: :ok | {:error, term()}

Creates a reaction on a message, or increases its count by one.

For more informations see Discord Docs.

Link to this function create_reaction(channel, message, emoji) View Source
create_reaction(
  channel :: Crux.Rest.Util.channel_id_resolvable(),
  message :: Crux.Rest.Util.message_id_resolvable(),
  emoji :: Crux.Rest.Util.emoji_id_resolvable()
) :: :ok | {:error, term()}

Creates a reaction on a message, or increases its count by one.

For more informations see Discord Docs.

Link to this function create_role(guild, data) View Source
create_role(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  data :: guild_role_data()
) :: {:ok, Crux.Structs.Role.t()} | {:error, term()}

Creates a role in a guild.

For more informations see Discord Docs.

Link to this function delete_all_reactions(message, emoji) View Source
delete_all_reactions(
  message :: Crux.Structs.Message.t(),
  emoji :: Crux.Rest.Util.emoji_identifier_resolvable()
) :: :ok | {:error, term()}

Deletes all reactions from a messaage.

For more informations see Discord Docs.

Link to this function delete_all_reactions(channel, message, emoji) View Source
delete_all_reactions(
  channel :: Crux.Rest.Util.channel_id_resolvable(),
  message :: Crux.Rest.Util.message_id_resolvable(),
  emoji :: Crux.Rest.Util.emoji_identifier_resolvable()
) :: :ok | {:error, term()}

Deletes all reactions from a messaage.

For more informations see Discord Docs.

Link to this function delete_channel(channel, reason \\ nil) View Source
delete_channel(
  channel :: Crux.Rest.Util.channel_id_resolvable(),
  reason :: String.t()
) :: {:ok, Crux.Structs.Channel.t()} | {:error, term()}

Deletes a channel.

For more informations see Discord Docs.

Link to this function delete_channel_permissions(channel, target, reason \\ nil) View Source
delete_channel_permissions(
  channel :: Crux.Rest.Util.channel_id_resolvable(),
  target :: Crux.Rest.Util.overwrite_target_resolvable(),
  reason :: String.t()
) :: :ok | {:error, term()}

Deletes an overwrite from a channel.

For more informations see Discord Docs.

Link to this function delete_guild(guild) View Source
delete_guild(guild :: Crux.Rest.Util.guild_id_resolvable()) ::
  :ok | {:error, term()}

Deletes a guild, can only be used if the executing user is the owner.

For more informations see Discord Docs.

Link to this function delete_guild_emoji(guild, emoji, reason \\ nil) View Source
delete_guild_emoji(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  emoji :: Crux.Rest.Util.emoji_id_resolvable(),
  reason :: String.t()
) :: :ok | {:error, term()}

Deletes an emoji from a guild.

For more informations see Discord Docs.

Link to this function delete_guild_integration(guild, integration_id) View Source
delete_guild_integration(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  integration_id :: snowflake()
) :: :ok | {:error, term()}

Deletes an integration from a guild.

For more informations see Discord Docs.

Link to this function delete_guild_role(guild, role, reason \\ nil) View Source
delete_guild_role(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  role :: Crux.Rest.Util.role_id_resolvable(),
  reason :: String.t()
) :: :ok | {:error, term()}

Deletes a role in a guild.

For more informations see Discord Docs.

Link to this function delete_invite(code) View Source
delete_invite(invite_or_code :: String.t() | Crux.Structs.Invite.t()) ::
  {:ok, Crux.Structs.Invite.t()} | {:error, term()}

Deletes an invite.

For more informations see Discord Docs.

Link to this function delete_message(message) View Source
delete_message(message :: Crux.Structs.Message.t()) ::
  {:ok, Crux.Structs.Message.t()} | {:error, term()}

Deletes a message

For more informations see Discord Docs.

Link to this function delete_message(channel, message) View Source
delete_message(
  channel_id :: Crux.Rest.Util.channel_id_resolvable(),
  message_id :: Crux.Rest.Util.message_id_resolvable()
) :: {:ok, Crux.Structs.Message} | {:error, term()}

Deletes a message

For more informations see Discord Docs.

Link to this function delete_messages(channel, messages) View Source
delete_messages(
  channel :: Crux.Rest.Util.channel_id_resolvable(),
  messages :: [Crux.Rest.Util.message_id_resolvable()]
) :: :ok | {:error, term()}

Deletes 2-100 messages not older than 14 days.

For more informations see Discord Docs

Link to this function delete_pinned_message(message) View Source
delete_pinned_message(message :: Crux.Structs.Message.t()) ::
  :ok | {:error, term()}

Deletes a message from the pinned messages. This does not delete the message itself.

For more informations see Discord Docs.

Link to this function delete_pinned_message(channel, message) View Source
delete_pinned_message(
  channel :: Crux.Rest.Util.channel_id_resolvable(),
  message :: Crux.Rest.Util.message_id_resolvable()
) :: :ok | {:error, term()}

Deletes a message from the pinned messages. This does not delete the message itself.

For more informations see Discord Docs.

Link to this function delete_reaction(message_or_channel, emoji_or_message_id, emoji_or_maybe_user \\ "@me", mayber_user \\ "@me") View Source

Deletes a user from a reaction.

The first argument is optional if a Crux.Structs.Message is provided.

For more informations see Discord Docs 2.

Link to this function edit_channel_permissions(channel, target, data) View Source
edit_channel_permissions(
  channel :: Crux.Rest.Util.channel_id_resolvable(),
  target :: Crux.Rest.Util.overwrite_target_resolvable(),
  data :: edit_channel_permissions_data()
) :: :ok | {:error, :missing_target} | {:error, term()}

Edits or creates an overwrite for a user, or member.

If an id is provided for :target, :type must be specified in t:edit_channel_permissions_data.

For more informations see Discord Docs.

Link to this function edit_message(message, args) View Source
edit_message(target :: Crux.Structs.Message.t(), args :: message_edit_data()) ::
  {:ok, Crux.Structs.Message.t()} | {:error, term()}

Edits a message.

For more informations see Discord Docs.

Link to this function edit_message(channel, message_id, args) View Source
edit_message(
  channel_id :: Crux.Rest.Util.channel_id_resolvable(),
  message_id :: Crux.Rest.Util.message_id_resolvable(),
  args :: message_edit_data()
) :: {:ok, Crux.Structs.Message.t()} | {:error, term()}

Edits a message.

For more informations see Discord Docs.

Link to this function gateway() View Source
gateway() :: {:ok, term()} | {:error, term()}

Fetches the gateway url from the api.

For more informations see Discord Docs.

Link to this function gateway_bot() View Source
gateway_bot() :: {:ok, term()} | {:error, term()}

Fetches the gateway url along a recommended shards count from the api.

For more informations see Discord Docs.

Link to this function get_channel(channel) View Source
get_channel(channel :: Crux.Rest.Util.resolve_channel_id()) ::
  {:ok, Crux.Structs.Channel.t()} | {:error, term()}

Gets a channel from the api.
This should NOT be necessary.

For more informations see Discord Docs

Link to this function get_channel_invites(channel) View Source
get_channel_invites(channel :: Crux.Rest.Util.channel_id_resolvable()) ::
  {:ok, [Crux.Structs.Invite.t()]} | {:error, term()}

Gets invites for the specified channel from the api.

For more informations see Discord Docs

Link to this function get_guild(guild) View Source
get_guild(guild :: Crux.Rest.Util.guild_id_resolvable()) ::
  {:ok, Crux.Structs.Guild.t()} | {:error, term()}

Gets a guild from the api.
This should usually, due to cache, NOT be necessary.

For more informations see Discord Docs

Link to this function get_guild_ban(guild, user) View Source
get_guild_ban(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  user :: Crux.Rest.Util.user_id_resolvable()
) ::
  {:ok, %{user: Crux.Structs.User.t(), reason: String.t() | nil}}
  | {:error, term()}

Fetches a single ban entry by id.

Returns {:error, %Crux.Rest.ApiError{status_code: 404, code: 10026, …}} when the user is not banned.

For more informations see Discord Docs.

Link to this function get_guild_bans(guild) View Source
get_guild_bans(guild :: Crux.Rest.Util.guild_id_resolvable()) ::
  {:ok,
   %{
     optional(snowflake()) => %{
       user: Crux.Structs.User.t(),
       reason: String.t() | nil
     }
   }}
  | {:error, term()}

Fetches a map of banned users along their ban reasons.

For more informations see discord Docs.

Link to this function get_guild_channels(guild) View Source
get_guild_channels(guild :: Crux.Rest.Util.guild_id_resolvable()) ::
  {:ok, [Crux.Structs.Channel.t()]} | {:error, term()}

Gets all channels from a guild via the api.
This should usually, due to caching, NOT be necessary.

For more informations see Discord Docs-

Link to this function get_guild_embed(guild) View Source
get_guild_embed(guild :: Crux.Rest.Util.guild_id_resolvable()) ::
  {:ok, term()} | {:error, term()}

Fetches a guild’s embed (server widget).

Returns a Guild Embed Object.

For more informations see Discord Docs.

Link to this function get_guild_emoji(guild, emoji) View Source
get_guild_emoji(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  emoji :: Crux.Rest.Util.emoji_id_resolvable()
) :: {:ok, Crux.Structs.Emoji} | {:error, term()}

Gets an emoji from a guild
This should usually, due to cache, NOT be necessary.

For more informations see Discord Docs.

Link to this function get_guild_integrations(guild) View Source
get_guild_integrations(guild :: Crux.Rest.Util.guild_id_resolvable()) ::
  {:ok, list()} | {:error, term()}

Fetches a list of guild integrations.

Returns a list of Integration Objects.

For more informations see Discord Docs.

Link to this function get_guild_invites(guild) View Source
get_guild_invites(guild :: Crux.Rest.Util.guild_id_resolvable()) ::
  {:ok, %{optional(String.t()) => Crux.Structs.Invite.t()}} | {:error, term()}

Fetches all available invites in a guild.

For more informations see Discord Docs.

Link to this function get_guild_member(guild, user) View Source
get_guild_member(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  user :: Crux.Rest.Util.user_id_resolvable()
) :: {:ok, Crux.Structs.Member.t()} | {:error, term()}

Fetches a member from the api.

This may be necessary for offline members in large guilds.

For more informations see Discord Docs.

Link to this function get_guild_prune_count(guild, days) View Source
get_guild_prune_count(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  days :: pos_integer()
) :: {:ok, non_neg_integer()} | {:error, term()}

Fetches the number of members in a guild that would be removed when pruned.

For more informations see Discord Docs.

Link to this function get_guild_roles(guild) View Source
get_guild_roles(guild :: Crux.Rest.Util.guild_id_resolvable()) ::
  {:ok, %{optional(snowflake()) => Crux.Structs.Role.t()}} | {:error, term()}

Fetches a list of roles in a guild.
This should usually, due to caching, NOT be necessary.

For more informations see Discord Docs.

Link to this function get_guild_vanity_url(guild) View Source
get_guild_vanity_url(guild :: Crux.Rest.Util.guild_id_resolvable()) ::
  {:ok, String.t()} | {:error, term()}

Fetches the vanity url of a guild, if any

Link to this function get_guild_voice_regions(guild) View Source
get_guild_voice_regions(guild :: Crux.Rest.Util.guild_id_resolvable()) ::
  {:ok, term()} | {:error, term()}

Fetches a list of voice regions for a guild. Returns VIP servers when the guild is VIP-enabled.

Returns a list of Voice Region Objects.

For more informations see Discord Docs.

Link to this function get_invite(code) View Source
get_invite(code :: String.t()) ::
  {:ok, Crux.Structs.Invite.t()} | {:error, term()}

Fetches an invite from the api.

For more informations see Discord Docs.

Link to this function get_message(channel, message) View Source
get_message(
  channel :: Crux.Rest.Util.channel_id_resolvable(),
  message_id :: Crux.Rest.Util.message_id_resolvable()
) :: {:ok, Crux.Structs.Message} | {:error, term()}

Gets a message from the api.

For more informations see Discord Docs.

Link to this function get_messages(channel, args \\ []) View Source
get_messages(
  channel :: Crux.Rest.Util.channel_id_resolvable(),
  args :: get_messages_data()
) :: {:ok, [Crux.Structs.Message.t()]} | {:error, term()}

Gets 1-100 messages from the api, this limit is enforced on discord’s end.

For more informations see Discord Docs.

Link to this function get_pinned_messages(channel) View Source
get_pinned_messages(channel :: Crux.Rest.Util.channel_id_resolvable()) ::
  {:ok, [Crux.Structs.Message.t()]} | {:error, term()}

Gets a list of pinned messages from the api.

For more informations see Discord Docs.

Link to this function get_reactions(channel_or_message, emoji_or_message_id, emoji_or_maybe_data \\ [], maybe_data \\ []) View Source

Gets users who reacted to a message.

The first argument is optional if a Crux.Structs.Message is provided.

For more informations see Discord Docs.

Link to this function list_guild_emojis(guild) View Source
list_guild_emojis(guild :: Crux.Rest.Util.guild_id_resolvable()) ::
  {:ok, [Crux.Structs.Emoji.t()]} | {:error, term()}

Gets a list of emojis in a guild.
This should usually, due to cache, NOT be necessary.

For more informations see Discord Docs.

Link to this function list_guild_members(guild, options \\ []) View Source
list_guild_members(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  options :: list_guild_members_options()
) :: {:ok, [Crux.Structs.Member.t()]} | {:error, term()}

Gets a list of members from the guild.

For more informations see Discord Docs.

Link to this function modify_channel(channel, args) View Source
modify_channel(
  channel :: Crux.Rest.Util.channel_id_resolvable(),
  args :: modify_channel_data()
) :: {:ok, Crux.Structs.Channel.t()} | {:error, term()}

Modifies a channel, see t:modify_channel_data for available options.

For more informations see Discord Docs.

Link to this function modify_current_users_nick(guild, nick, reason \\ nil) View Source
modify_current_users_nick(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  nick :: String.t(),
  reason :: String.t()
) :: :ok | {:error, term()}

Modifies the nickname of the current user in a guild.

Yes, you read correctly, that has its own endpoint.
Great, isn’t it?

For more informations, but not an answer to the question why, see Discord Docs.

Link to this function modify_guild(guild, data) View Source
modify_guild(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  data :: modify_guild_data()
) :: {:ok, Crux.Structs.Guild.t()} | {:error, term()}

Updates a guild, see t:modify_guild_data for available options.

For more informations see Discord Docs.

Link to this function modify_guild_channel_positions(guild, channels) View Source
modify_guild_channel_positions(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  channels :: [modify_guild_channel_positions_data_entry()]
) :: :ok | {:error, term()}

Modifyies the position of a list of channels in a guild.

For more informations see Discord Docs.

Link to this function modify_guild_embed(guild, data) View Source
modify_guild_embed(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  data ::
    %{optional(:enabled) => boolean(), optional(:channel_id) => snowflake()}
    | [enabled: boolean(), channel_id: snowflake()]
) :: {:ok, term()} | {:error, term()}

Modifies a guild’s embed (server widget).

Returns the updated Guild Embed Object.

For more informations see Discord Docs.

Link to this function modify_guild_emoji(guild, emoji, data) View Source
modify_guild_emoji(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  emoji :: Crux.Rest.Util.emoji_id_resolvable(),
  data :: modify_guild_emoji_data()
) :: {:ok, Crux.Structs.Emoji} | {:error, term()}

Modifies a guild emoji.

For more informations see Discord Docs.

Link to this function modify_guild_integration(guild, integration_id, data) View Source
modify_guild_integration(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  integration_id :: snowflake(),
  data ::
    %{
      optional(:expire_behavior) => integer(),
      optional(:expire_grace_period) => integer(),
      optional(:enable_emoticons) => boolean()
    }
    | [
        expire_behavior: integer(),
        expire_grace_period: integer(),
        enable_emoticons: boolean()
      ]
) :: :ok | {:error, term()}

Modifies an integreation for a guild.

For more informations see Discord Docs.

Link to this function modify_guild_member(guild, member, data) View Source
modify_guild_member(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  member :: Crux.Rest.Util.user_id_resolvable(),
  data :: modify_guild_member_data()
) :: :ok | {:error, term()}

Modifies a member in a guild.

For more informations see Discord Docs.

Link to this function modify_guild_role(guild, role, data) View Source
modify_guild_role(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  role :: Crux.Rest.Util.role_id_resolvable(),
  data :: guild_role_data()
) :: {:ok, Crux.Structs.Role.t()} | {:error, term()}

Modifies a role in a guild.

For more informations see Discord Docs.

Link to this function modify_guild_role_positions(guild, data) View Source
modify_guild_role_positions(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  data :: Crux.Rest.Util.modify_guild_role_positions_data()
) :: {:ok, %{optional(snowflake()) => Crux.Structs.Role.t()}} | {:error, term()}

Modifies the positions of a list of role objects for a guild.

For more informations see Discord Docs.

Link to this function remove_guild_ban(guild, user, reason \\ nil) View Source
remove_guild_ban(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  user :: Crux.Rest.Util.user_id_resolvable(),
  reason :: String.t()
) :: :ok | {:error, term()}

Removes a ban for a user from a guild.

For more informations see Discord Docs.

Link to this function remove_guild_member_role(guild, member, role, reason \\ nil) View Source
remove_guild_member_role(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  member :: Crux.Rest.Util.user_id_resolvable(),
  role :: Crux.Rest.Util.role_id_resolvable(),
  reason :: String.t()
) :: :ok | {:error, term()}

Removes a role from a member.

For more informations see Discord Docs.

Link to this function sync_guild_integration(guild, integration_id) View Source
sync_guild_integration(
  guild :: Crux.Rest.Util.guild_id_resolvable(),
  integration_id :: snowflake()
) :: :ok | {:error, term()}

Syncs an integration for a guild.

For more informations see Discord Docs.

Link to this function trigger_typing(channel) View Source
trigger_typing(channel :: Crux.Rest.Util.channel_id_resolvable()) ::
  :ok | {:error, term()}

Lets the bot appear as typing for roughly ~9 seconds or until a message is sent.
Should generally be used sparingly for commands that may take a while as a form of acknowledging.

Consider sending a message and edit that later on instead.

For more informations see Discord Docs.