crux_rest v0.2.2 Crux.Rest behaviour View Source

Main entry point for Crux.Rest.

For a more convenient way to consume this module you can use it in your own.

Possible use options are:

  • transform - whether to transform the received JSON further into the documented structs. Defaults to true.

    Example

  defmodule MyBot.Rest do
    use Crux.Rest

    # Define helper functions as needed
    def gateway_bot_additional_info() do
      with {:ok, data} <- gateway_bot() do
        Map.put(data, "additional_info", MyBot.Additional.info())
      end
    end
  end

This module fits under a supervision tree, see start_link/1's' arguments for configuration. The same applies to modules use-ing this module.

Link to this section Summary

Types

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

Used to filter audit log results via c:get_audit_logs/2. The :user_id field refers to the executor and not the target of the log.

Used to prune inactive guild members with c:begin_guild_prune/2.

Used to send messages via c:create_message/2.

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

Used to send and embed via c:create_message/2.

Used for sending discord webhooks. For more information on non-discord webhooks, check Slack Docs or Github Docs

Used to list the current user's guilds in c:get_current_user_guild/1.

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

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

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

Used to list guild members via c:list_guild_members/2.

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

Used to modify a channel via c:modify_channel/2.

Used to modify the currently logged in c:modify_current_user/1.

Used to modify a guild using c:modify_guild/2.

Used to modify a guild emoji via c:modify_guild_emoji/3.

Used to modify a member with c:modify_guild_member/3.

Options used to start Crux.Rest.

A Discord snowflake, fits in a 64bit integer.

Functions

Executes a request.

Executes a request, but raises on error.

Starts a Crux.Rest process linked to the current process.

Callbacks

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

The same as c:add_guild_member/3, but raises an exception if it fails.

The same as c:add_guild_member_role/4, but raises an exception if it fails.

Adds a message to the pinned messages of a channel.

Adds a message to the pinned messages of a channel.

The same as c:add_pinned_message/1, but raises an exception if it fails.

The same as c:add_pinned_message/2, but raises an exception if it fails.

Prunes members in a guild.

The same as c:begin_guild_prune/2, but raises an exception if it fails.

Creates an invite to a channel, see t:Crux.Rest.create_channel_invite_data/0 for available options.

The same as c:create_channel_invite/2, but raises an exception if it fails.

Creates a new dm channel with a user.

The same as c:create_dm/1, but raises an exception if it fails.

The same as c:create_guild/1, but raises an exception if it fails.

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

The same as c:create_guild_ban/3, but raises an exception if it fails.

Creates a channel in a guild, see t:Crux.Rest.create_guild_channel_data/0 for available options.

The same as c:create_guild_channel/2, but raises an exception if it fails.

Creates an emoji in a guild, see t:Crux.Rest.create_guild_emoji_data/0 for available options.

The same as c:create_guild_emoji/2, but raises an exception if it fails.

Attaches an integration from the current user to a guild.

The same as c:create_guild_integration/2, but raises an exception if it fails.

Creates a role in a guild.

The same as c:create_guild_role/2, but raises an exception if it fails.

Sends a message to a channel.

The same as c:create_message/2, but raises an exception if it fails.

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

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

The same as c:create_reaction/2, but raises an exception if it fails.

The same as c:create_reaction/3, but raises an exception if it fails.

Deletes all reactions from a message.

Deletes all reactions from a message.

The same as c:delete_all_reactions/2, but raises an exception if it fails.

The same as c:delete_all_reactions/3, but raises an exception if it fails.

Deletes a channel.

The same as c:delete_channel/2, but raises an exception if it fails.

Deletes an overwrite from a channel.

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

The same as c:delete_guild/1, but raises an exception if it fails.

Deletes an emoji from a guild.

The same as c:delete_guild_emoji/3, but raises an exception if it fails.

Deletes an integration from a guild.

The same as c:delete_guild_integration/2, but raises an exception if it fails.

Deletes a role in a guild.

The same as c:delete_guild_role/3, but raises an exception if it fails.

Deletes an invite.

The same as c:delete_invite/1, but raises an exception if it fails.

Deletes a message

The same as c:delete_message/1, but raises an exception if it fails.

The same as c:delete_message/2, but raises an exception if it fails.

Deletes 2-100 messages not older than 14 days.

The same as c:delete_messages/2, but raises an exception if it fails.

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.

The same as c:delete_pinned_message/1, but raises an exception if it fails.

The same as c:delete_pinned_message/2, but raises an exception if it fails.

Deletes a user from a reaction.

The same as c:delete_reaction/4, but raises an exception if it fails.

Deletes a webhook

The same as c:delete_webhook/2, but raises an exception if it fails.

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

The same as c:edit_channel_permissions/3, but raises an exception if it fails.

Edits a message.

The same as c:edit_message/2, but raises an exception if it fails.

The same as c:edit_message/3, but raises an exception if it fails.

The same as c:execute_github_webhook/3, but raises an exception if it fails.

The same as c:execute_github_webhook/4, but raises an exception if it fails.

Executes a slack webhook

The same as c:execute_slack_webhook/2, but raises an exception if it fails.

The same as c:execute_slack_webhook/3, but raises an exception if it fails.

The same as c:execute_slack_webhook/4, but raises an exception if it fails.

Executes a webhook

The same as c:execute_webhook/2, but raises an exception if it fails.

The same as c:execute_webhook/3, but raises an exception if it fails.

The same as c:execute_webhook/4, but raises an exception if it fails.

Gets the gateway url from the api.

The same as c:gateway/0, but raises an exception if it fails.

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

The same as c:gateway_bot/0, but raises an exception if it fails.

Gets the audit logs for a guild

The same as c:get_audit_logs/2, but raises an exception if it fails.

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

The same as c:get_channel/1, but raises an exception if it fails.

Gets invites for the specified channel from the api.

The same as c:get_channel_invites/1, but raises an exception if it fails.

Gets the current user from the api.

The same as c:get_current_user/0, but raises an exception if it fails.

Gets a list of partial Crux.Structs.Guilds the current user is a member of.

The same as c:get_current_user_guilds/1, but raises an exception if it fails.

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

The same as c:get_guild/1, but raises an exception if it fails.

Gets a single ban entry by id.

The same as c:get_guild_ban/2, but raises an exception if it fails.

Gets a map of banned users along their ban reasons.

The same as c:get_guild_bans/1, but raises an exception if it fails.

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

The same as c:get_guild_channels/1, but raises an exception if it fails.

Gets a guild's embed (server widget).

The same as c:get_guild_embed/1, but raises an exception if it fails.

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

The same as c:get_guild_emoji/2, but raises an exception if it fails.

Gets a list of guild integrations.

The same as c:get_guild_integrations/1, but raises an exception if it fails.

Gets all available invites in a guild.

The same as c:get_guild_invites/1, but raises an exception if it fails.

Gets a member from the api.

The same as c:get_guild_member/2, but raises an exception if it fails.

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

The same as c:get_guild_prune_count/2, but raises an exception if it fails.

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

The same as c:get_guild_roles/1, but raises an exception if it fails.

Gets the vanity invite of a guild, if any

The same as c:get_guild_vanity_invite/1, but raises an exception if it fails.

Gets the vanity url of a guild, if any

The same as c:get_guild_vanity_url/1, but raises an exception if it fails.

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

The same as c:get_guild_voice_regions/1, but raises an exception if it fails.

Gets an invite from the api.

The same as c:get_invite/1, but raises an exception if it fails.

Gets a message from the api.

The same as c:get_message/2, but raises an exception if it fails.

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

The same as c:get_messages/2, but raises an exception if it fails.

Gets a list of pinned messages from the api.

The same as c:get_pinned_messages/1, but raises an exception if it fails.

Gets users who reacted to a message.

The same as c:get_reactions/3, but raises an exception if it fails.

The same as c:get_reactions/4, but raises an exception if it fails.

Gets a user from the api.

The same as c:get_user/1, but raises an exception if it fails.

Gets a webhook

The same as c:get_webhook/2, but raises an exception if it fails.

Leaves a guild.

The same as c:leave_guild/1, but raises an exception if it fails.

Gets a channel's webhook list

The same as c:list_channel_webhooks/1, but raises an exception if it fails.

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

The same as c:list_guild_emojis/1, but raises an exception if it fails.

Gets a list of members from the guild.

The same as c:list_guild_members/2, but raises an exception if it fails.

Gets a guild's webhook list

The same as c:list_guild_webhooks/1, but raises an exception if it fails.

Modifies a channel, see t:Crux.Rest.modify_channel_data/0 for available options.

The same as c:modify_channel/2, but raises an exception if it fails.

Modifes the currently logged in user.

The same as c:modify_current_user/1, but raises an exception if it fails.

Modifies the nickname of the current user in a guild.

The same as c:modify_current_users_nick/3, but raises an exception if it fails.

Updates a guild, see t:Crux.Rest.modify_guild_data/0 for available options.

The same as c:modify_guild/2, but raises an exception if it fails.

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

Modifies a guild's embed (server widget).

The same as c:modify_guild_embed/2, but raises an exception if it fails.

Modifies a guild emoji.

The same as c:modify_guild_emoji/3, but raises an exception if it fails.

Modifies an integreation for a guild.

Modifies a member in a guild.

The same as c:modify_guild_member/3, but raises an exception if it fails.

Modifies a role in a guild.

The same as c:modify_guild_role/3, but raises an exception if it fails.

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

The same as c:modify_guild_role_positions/2, but raises an exception if it fails.

Removes a ban for a user from a guild.

The same as c:remove_guild_ban/3, but raises an exception if it fails.

Syncs an integration for a guild.

The same as c:sync_guild_integration/2, but raises an exception if it fails.

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.

The same as c:trigger_typing/1, but raises an exception if it fails.

The same as c:update_webhook/3, but raises an exception if it fails.

Link to this section Types

Link to this type

add_guild_member_data()

View Source (since 0.1.0)

Specs

add_guild_member_data() ::
  %{
    :access_token => String.t(),
    optional(:nick) => String.t() | nil,
    optional(:roles) => [Crux.Structs.Role.id_resolvable()],
    optional(:mute) => boolean(),
    optional(:deaf) => boolean(),
    optional(:reason) => String.t() | nil
  }
  | [
      access_token: String.t(),
      nick: String.t() | nil,
      roles: [Crux.Structs.Role.id_resolvable()],
      mute: boolean(),
      deaf: boolean(),
      reason: String.t() | nil
    ]

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

Link to this type

audit_log_options()

View Source (since 0.1.7)

Specs

audit_log_options() ::
  %{
    optional(:user_id) => Crux.Structs.User.id_resolvable(),
    optional(:action_type) => pos_integer(),
    optional(:before) => Crux.Structs.User.id_resolvable(),
    optional(:limit) => pos_integer()
  }
  | [
      user_id: Crux.Structs.User.id_resolvable(),
      action_type: pos_integer(),
      before: Crux.Structs.User.id_resolvable(),
      limit: pos_integer()
    ]

Used to filter audit log results via c:get_audit_logs/2. The :user_id field refers to the executor and not the target of the log.

Link to this type

begin_guild_prune_opts()

View Source (since 0.2.0)

Specs

begin_guild_prune_opts() ::
  %{
    optional(:days) => pos_integer(),
    optional(:compute_prune_count) => boolean()
  }
  | [days: pos_integer(), compute_prune_count: boolean()]

Used to prune inactive guild members with c:begin_guild_prune/2.

Link to this type

create_channel_invite_data()

View Source (since 0.1.0)

Specs

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() | nil
  }
  | [
      max_age: non_neg_integer(),
      max_uses: non_neg_integer(),
      temporary: boolean(),
      unique: boolean(),
      reason: String.t() | nil
    ]

Used to create invites via c: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 (since 0.1.0)

Specs

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) => [
      Crux.Structs.Overwrite.t()
      | %{
          :id =>
            Crux.Structs.Role.id_resolvable()
            | Crux.Structs.Channel.id_resolvable(),
          :type => String.t(),
          optional(:allow) => non_neg_integer(),
          optional(:deny) => non_neg_integer()
        }
    ],
    optional(:parent_id) => Crux.Structs.Channel.id_resolvable() | nil,
    optional(:nsfw) => boolean(),
    optional(:reason) => String.t() | nil
  }
  | [
      name: String.t(),
      type: pos_integer(),
      bitrate: non_neg_integer() | nil,
      user_limit: integer() | nil,
      permission_overwrites: [
        Crux.Structs.Overwrite.t()
        | %{
            :id =>
              Crux.Structs.Role.id_resolvable()
              | Crux.Structs.Channel.id_resolvable(),
            :type => String.t(),
            optional(:allow) => non_neg_integer(),
            optional(:deny) => non_neg_integer()
          }
      ],
      parent_id: Crux.Structs.Channel.id_resolvable() | nil,
      nsfw: boolean(),
      reason: String.t() | nil
    ]

Used to create a channel via c: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 (since 0.1.0)

Specs

create_guild_emoji_data() ::
  %{
    :name => String.t(),
    :image => Crux.Rest.Util.image(),
    optional(:roles) => [Crux.Structs.Role.id_resolvable()],
    optional(:reason) => String.t() | nil
  }
  | [
      name: String.t(),
      image: Crux.Rest.Util.image(),
      roles: [Crux.Structs.Role.id_resolvable()],
      reason: String.t() | nil
    ]

Used to create emojis via c: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 (since 0.1.0)

Specs

create_message_data() ::
  %{
    optional(:content) => String.t(),
    optional(:nonce) => String.t() | integer(),
    optional(:tts) => boolean(),
    optional(:embed) => embed(),
    optional(:files) => [Crux.Rest.Util.attachment()]
  }
  | [
      content: String.t(),
      nonce: String.t() | integer(),
      tts: boolean(),
      embed: embed(),
      files: [Crux.Rest.Util.attachment()]
    ]

Used to send messages via c:create_message/2.

The content my not exceed 2000 chars. The nonce has to fit in a 64 bit integer or be a string. The whole message payload may not be larger than 8mb, this should only be possible when attaching (a) large file(s). Exception to this rule are boosted guilds where the limit may differ.

Link to this type

edit_channel_permissions_data()

View Source (since 0.1.0)

Specs

edit_channel_permissions_data() ::
  %{
    optional(:allow) => non_neg_integer(),
    optional(:deny) => non_neg_integer(),
    optional(:type) => String.t(),
    optional(:reason) => String.t() | nil
  }
  | [
      allow: non_neg_integer(),
      deny: non_neg_integer(),
      type: :member | :role | String.t(),
      reason: String.t() | nil
    ]

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

See Permissions for available bitflags.

Specs

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 c:create_message/2.

You should probably consult the Embed Limits page.

Link to this type

execute_webhook_options()

View Source (since 0.1.7)

Specs

execute_webhook_options() :: %{
  optional(:content) => String.t(),
  optional(:username) => String.t(),
  optional(:avatar_url) => String.t(),
  optional(:tts) => boolean(),
  optional(:files) => [Crux.Rest.Util.attachment()],
  optional(:embeds) => [embed()]
}

Used for sending discord webhooks. For more information on non-discord webhooks, check Slack Docs or Github Docs

Link to this type

get_current_user_guild_data()

View Source (since 0.1.4)

Specs

get_current_user_guild_data() ::
  %{
    optional(:before) => Crux.Structs.Message.id_resolvable(),
    optional(:after) => Crux.Structs.Message.id_resolvable(),
    optional(:limit) => pos_integer()
  }
  | [
      before: Crux.Structs.Message.id_resolvable(),
      after: Crux.Structs.Message.id_resolvable(),
      limit: pos_integer()
    ]

Used to list the current user's guilds in c:get_current_user_guild/1.

Link to this type

get_messages_data()

View Source (since 0.1.0)

Specs

get_messages_data() ::
  %{
    optional(:around) => Crux.Structs.Message.id_resolvable(),
    optional(:before) => Crux.Structs.Message.id_resolvable(),
    optional(:after) => Crux.Structs.Message.id_resolvable(),
    optional(:limit) => pos_integer()
  }
  | [
      around: Crux.Structs.Message.id_resolvable(),
      before: Crux.Structs.Message.id_resolvable(),
      after: Crux.Structs.Message.id_resolvable(),
      limit: pos_integer()
    ]

Used to get messages from the api via c: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 (since 0.1.0)

Specs

get_reactions_data() ::
  %{
    optional(:before) => Crux.Structs.User.id_resolvable(),
    optional(:after) => Crux.Structs.User.id_resolvable(),
    optional(:limit) => pos_integer()
  }
  | [
      before: Crux.Structs.User.id_resolvable(),
      after: Crux.Structs.User.id_resolvable(),
      limit: pos_integer()
    ]

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

Notes:

  • :before seems currently broken on discord's end
  • :after is exclusive
Link to this type

guild_role_data()

View Source (since 0.1.2)

Specs

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() | nil
  }
  | [
      name: String.t(),
      permissions: non_neg_integer(),
      color: non_neg_integer(),
      hoist: boolean(),
      mentionable: boolean(),
      reason: String.t() | nil
    ]

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

Link to this type

list_guild_members_options()

View Source (since 0.1.0)

Specs

list_guild_members_options() ::
  %{
    optional(:limit) => pos_integer(),
    optional(:after) => Crux.Structs.User.id_resolvable()
  }
  | [limit: pos_integer(), after: Crux.Structs.User.id_resolvable()]

Used to list guild members via c:list_guild_members/2.

Link to this type

message_edit_data()

View Source (since 0.1.0)

Specs

message_edit_data() ::
  %{
    optional(:content) => String.t() | nil,
    optional(:embed) => embed() | nil,
    optional(:flags) => non_neg_integer()
  }
  | [content: String.t(), embed: embed()]

Used to edit messages via c:edit_message/2 or c: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 (since 0.1.0)

Specs

modify_channel_data() ::
  %{
    optional(:bitrate) => non_neg_integer(),
    optional(:icon) => Crux.Rest.Util.image(),
    optional(:name) => String.t() | nil,
    optional(:nsfw) => boolean(),
    optional(:parent_id) => Crux.Structs.Channel.id_resolvable() | nil,
    optional(:permission_overwrites) => [Crux.Structs.Overwrite.t()],
    optional(:position) => non_neg_integer(),
    optional(:rate_limit_per_user) => non_neg_integer(),
    optional(:reason) => String.t() | nil,
    optional(:topic) => String.t() | nil,
    optional(:user_limit) => non_neg_integer() | nil
  }
  | [
      bitrate: non_neg_integer(),
      icon: Crux.Rest.Util.image(),
      name: String.t() | nil,
      nsfw: boolean(),
      parent_id: Crux.Structs.Channel.id_resolvable() | nil,
      permission_overwrites: [Crux.Structs.Overwrite.t()],
      position: non_neg_integer(),
      rate_limit_per_user: non_neg_integer(),
      reason: String.t() | nil,
      topic: String.t() | nil,
      user_limit: integer() | nil
    ]

Used to modify a channel via c: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
  • :rate_limit_per_user has to be [0-120], 0 refers to no limit

    For more informations see Discord Docs.

Link to this type

modify_current_user_data()

View Source (since 0.1.4)

Specs

modify_current_user_data() ::
  %{
    optional(:username) => String.t(),
    optional(:avatar) => Crux.Rest.Util.image()
  }
  | [username: String.t(), avatar: Crux.Rest.Util.image() | nil]

Used to modify the currently logged in c:modify_current_user/1.

Link to this type

modify_guild_channel_positions_data_entry()

View Source (since 0.1.0)

Specs

modify_guild_channel_positions_data_entry() ::
  Crux.Structs.Channel.position_resolvable()

Used to change a channel's position via c:modify_guild_channel_positions/2.

Deprecated: Use Crux.Structs.Channel.position_resolvable() instead

Link to this type

modify_guild_data()

View Source (since 0.1.0)

Specs

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) => Crux.Structs.Channel.id_resolvable() | nil,
    optional(:afk_timeout) => non_neg_integer(),
    optional(:icon) => Crux.Rest.Util.image(),
    optional(:splash) => Crux.Rest.Util.image(),
    optional(:banner) => Crux.Rest.Util.image(),
    optional(:owner_id) => Crux.Structs.User.id_resolvable(),
    optional(:system_channel_id) => Crux.Structs.Channel.id_resolvable() | nil,
    optional(:reason) => String.t() | nil
  }
  | [
      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: Crux.Structs.Channel.id_resolvable() | nil,
      afk_timeout: non_neg_integer(),
      icon: Crux.Rest.Util.image(),
      splash: Crux.Rest.Util.image(),
      banner: Crux.Rest.Util.image(),
      owner_id: Crux.Structs.User.id_resolvable(),
      system_channel_id: Crux.Structs.Channel.id_resolvable() | nil,
      reason: String.t() | nil
    ]

Used to modify a guild using c:modify_guild/2.

Link to this type

modify_guild_emoji_data()

View Source (since 0.1.0)

Specs

modify_guild_emoji_data() ::
  %{
    optional(:name) => String.t(),
    optional(:roles) => [Crux.Structs.Role.id_resolvable()],
    optional(:reason) => String.t() | nil
  }
  | [
      name: String.t(),
      roles: [Crux.Structs.Role.id_resolvable()],
      reason: String.t() | nil
    ]

Used to modify a guild emoji via c:modify_guild_emoji/3.

See t:Crux.Rest.create_guild_emoji_data/0 for name restrictions.

Link to this type

modify_guild_member_data()

View Source (since 0.1.0)

Specs

modify_guild_member_data() ::
  %{
    optional(:nick) => String.t() | nil,
    optional(:roles) => [Crux.Structs.Role.id_resolvable()],
    optional(:mute) => boolean(),
    optional(:deaf) => boolean(),
    optional(:channel_id) => Crux.Structs.Channel.id_resolvable() | nil,
    optional(:reason) => String.t() | nil
  }
  | [
      nick: String.t() | nil,
      roles: [Crux.Structs.Role.id_resolvable()],
      mute: boolean(),
      deaf: boolean(),
      channel_id: Crux.Structs.Channel.id_resolvable() | nil,
      reason: String.t() | nil
    ]

Used to modify a member with c:modify_guild_member/3.

Notes:

  • A nil :channel_id will kick the member from the voice channel.
Link to this type

options()

View Source (since 0.2.0)

Specs

options() ::
  %{
    :token => String.t(),
    optional(:retry_limit) => non_neg_integer() | :infinity
  }
  | [token: String.t(), retry_limit: non_neg_integer() | :infinity]

Options used to start Crux.Rest.

Link to this type

snowflake()

View Source (since 0.1.0)

Specs

snowflake() :: non_neg_integer()

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.

Deprecated: Use Crux.Snowflake.resolvable() instead

Link to this section Functions

Link to this function

request(name, request)

View Source (since 0.2.0)

Specs

request(name :: atom(), request :: Crux.Rest.Request.t()) ::
  :ok | {:ok, term()} | {:error, term()}

Executes a request.

Link to this function

request!(name, request)

View Source (since 0.2.0)

Specs

request!(name :: atom(), request :: Crux.Rest.Request.t()) ::
  term() | no_return()

Executes a request, but raises on error.

Specs

start_link({name :: atom(), options()}) :: Supervisor.on_start()

Starts a Crux.Rest process linked to the current process.

Options are a tuple of a name atom and t:options/0.

Link to this section Callbacks

Link to this callback

add_guild_member(guild, user, data)

View Source (since 0.2.0)

Specs

add_guild_member(
  guild :: Crux.Structs.Guild.id_resolvable(),
  user :: Crux.Structs.User.id_resolvable(),
  data :: Crux.Rest.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 callback

add_guild_member!(guild, user, data)

View Source (optional) (since 0.2.0)

Specs

The same as c:add_guild_member/3, but raises an exception if it fails.

Link to this callback

add_guild_member_role(guild, member, role, reason)

View Source (since 0.2.0)

Specs

add_guild_member_role(
  guild :: Crux.Structs.Guild.id_resolvable(),
  member :: Crux.Structs.User.id_resolvable(),
  role :: Crux.Structs.Role.id_resolvable(),
  reason :: String.t() | nil
) :: :ok | {:error, term()}

Adds a role to a member.

For more informations see Discord Docs.

Link to this callback

add_guild_member_role!(guild, member, role, reason)

View Source (optional) (since 0.2.0)

Specs

add_guild_member_role!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  member :: Crux.Structs.User.id_resolvable(),
  role :: Crux.Structs.Role.id_resolvable(),
  reason :: String.t() | nil
) :: :ok | no_return()

The same as c:add_guild_member_role/4, but raises an exception if it fails.

Link to this callback

add_pinned_message(message)

View Source (since 0.2.0)

Specs

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 callback

add_pinned_message(channel, message)

View Source (since 0.2.0)

Specs

add_pinned_message(
  channel :: Crux.Structs.Channel.id_resolvable(),
  message :: Crux.Structs.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 callback

add_pinned_message!(message)

View Source (optional) (since 0.2.0)

Specs

add_pinned_message!(message :: Crux.Structs.Message.t()) :: :ok | no_return()

The same as c:add_pinned_message/1, but raises an exception if it fails.

Link to this callback

add_pinned_message!(channel, message)

View Source (optional) (since 0.2.0)

Specs

add_pinned_message!(
  channel :: Crux.Structs.Channel.id_resolvable(),
  message :: Crux.Structs.Message.id_resolvable()
) :: :ok | no_return()

The same as c:add_pinned_message/2, but raises an exception if it fails.

Link to this callback

begin_guild_prune(guild, opts)

View Source (since 0.2.0)

Specs

begin_guild_prune(
  guild :: Crux.Structs.Guild.id_resolvable(),
  opts :: Crux.Rest.begin_guild_prune_opts()
) :: {:ok, non_neg_integer()} | {:error, term()}

Prunes members in a guild.

For more informations see Discord Docs.

Link to this callback

begin_guild_prune!(guild, opts)

View Source (optional) (since 0.2.0)

Specs

The same as c:begin_guild_prune/2, but raises an exception if it fails.

Link to this callback

create_channel_invite(channel, args)

View Source (since 0.2.0)

Specs

create_channel_invite(
  channel :: Crux.Structs.Channel.id_resolvable(),
  args :: Crux.Rest.create_channel_invite_data()
) :: {:ok, Crux.Structs.Invite.t()} | {:error, term()}

Creates an invite to a channel, see t:Crux.Rest.create_channel_invite_data/0 for available options.

For more informations see Discord Docs.

Link to this callback

create_channel_invite!(channel, args)

View Source (optional) (since 0.2.0)

Specs

The same as c:create_channel_invite/2, but raises an exception if it fails.

Link to this callback

create_dm(user)

View Source (since 0.2.0)

Specs

create_dm(user :: Crux.Structs.User.id_resolvable()) ::
  {:ok, Crux.Structs.Channel.t()} | {:error, term()}

Creates a new dm channel with a user.

For more informations see Discord Docs.

Link to this callback

create_dm!(user)

View Source (optional) (since 0.2.0)

Specs

The same as c:create_dm/1, but raises an exception if it fails.

Link to this callback

create_guild(term)

View Source (since 0.2.0)

Specs

create_guild(term()) :: {:ok, Crux.Structs.Guild.t()} | {:error, term()}
Link to this callback

create_guild!(term)

View Source (optional) (since 0.2.0)

Specs

create_guild!(term()) :: Crux.Structs.Guild.t() | no_return()

The same as c:create_guild/1, but raises an exception if it fails.

Link to this callback

create_guild_ban(guild, user, reason)

View Source (since 0.2.0)

Specs

create_guild_ban(
  guild :: Crux.Structs.Guild.id_resolvable(),
  user :: Crux.Structs.User.id_resolvable(),
  reason :: String.t() | nil
) :: :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 callback

create_guild_ban!(guild, user, reason)

View Source (optional) (since 0.2.0)

Specs

create_guild_ban!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  user :: Crux.Structs.User.id_resolvable(),
  reason :: String.t() | nil
) :: :ok | no_return()

The same as c:create_guild_ban/3, but raises an exception if it fails.

Link to this callback

create_guild_channel(guild, data)

View Source (since 0.2.0)

Specs

create_guild_channel(
  guild :: Crux.Structs.Guild.id_resolvable(),
  data :: Crux.Rest.create_guild_channel_data()
) :: {:ok, Crux.Structs.Channel.t()} | {:error, term()}

Creates a channel in a guild, see t:Crux.Rest.create_guild_channel_data/0 for available options.

For more informations see Discord Docs.

Link to this callback

create_guild_channel!(guild, data)

View Source (optional) (since 0.2.0)

Specs

The same as c:create_guild_channel/2, but raises an exception if it fails.

Link to this callback

create_guild_emoji(guild, data)

View Source (since 0.2.0)

Specs

create_guild_emoji(
  guild :: Crux.Structs.Guild.id_resolvable(),
  data :: Crux.Rest.create_guild_emoji_data()
) :: {:ok, Crux.Structs.Emoji} | {:error, term()}

Creates an emoji in a guild, see t:Crux.Rest.create_guild_emoji_data/0 for available options.

For more informations see Discord Docs.

Link to this callback

create_guild_emoji!(guild, data)

View Source (optional) (since 0.2.0)

Specs

create_guild_emoji!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  data :: Crux.Rest.create_guild_emoji_data()
) :: Crux.Structs.Emoji | no_return()

The same as c:create_guild_emoji/2, but raises an exception if it fails.

Link to this callback

create_guild_integration(guild, data)

View Source (since 0.2.0)

Specs

create_guild_integration(
  guild :: Crux.Structs.Guild.id_resolvable(),
  data ::
    %{type: String.t(), id: Crux.Structs.Snowflake.resolvable()}
    | [type: String.t(), id: Crux.Structs.Snowflake.resolvable()]
) :: :ok | {:error, term()}

Attaches an integration from the current user to a guild.

For more informations see Discord Docs.

Link to this callback

create_guild_integration!(guild, data)

View Source (optional) (since 0.2.0)

Specs

create_guild_integration!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  data ::
    %{type: String.t(), id: Crux.Structs.Snowflake.resolvable()}
    | [type: String.t(), id: Crux.Structs.Snowflake.resolvable()]
) :: :ok | no_return()

The same as c:create_guild_integration/2, but raises an exception if it fails.

Link to this callback

create_guild_role(guild, data)

View Source (since 0.2.0)

Specs

create_guild_role(
  guild :: Crux.Structs.Guild.id_resolvable(),
  data :: Crux.Rest.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 callback

create_guild_role!(guild, data)

View Source (optional) (since 0.2.0)

Specs

create_guild_role!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  data :: Crux.Rest.guild_role_data()
) :: Crux.Structs.Role.t() | no_return()

The same as c:create_guild_role/2, but raises an exception if it fails.

Link to this callback

create_message(channel, args)

View Source (since 0.2.0)

Specs

create_message(
  channel :: Crux.Structs.Channel.id_resolvable(),
  args :: Crux.Rest.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 callback

create_message!(channel, args)

View Source (optional) (since 0.2.0)

Specs

The same as c:create_message/2, but raises an exception if it fails.

Link to this callback

create_reaction(message, emoji)

View Source (since 0.2.0)

Specs

create_reaction(
  message :: Crux.Structs.Message.id_resolvable(),
  emoji :: Crux.Structs.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 callback

create_reaction(channel, message, emoji)

View Source (since 0.2.0)

Specs

create_reaction(
  channel :: Crux.Structs.Channel.id_resolvable(),
  message :: Crux.Structs.Message.id_resolvable(),
  emoji :: Crux.Structs.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 callback

create_reaction!(message, emoji)

View Source (optional) (since 0.2.0)

Specs

create_reaction!(
  message :: Crux.Structs.Message.id_resolvable(),
  emoji :: Crux.Structs.Emoji.identifier_resolvable()
) :: :ok | no_return()

The same as c:create_reaction/2, but raises an exception if it fails.

Link to this callback

create_reaction!(channel, message, emoji)

View Source (optional) (since 0.2.0)

Specs

create_reaction!(
  channel :: Crux.Structs.Channel.id_resolvable(),
  message :: Crux.Structs.Message.id_resolvable(),
  emoji :: Crux.Structs.Emoji.id_resolvable()
) :: :ok | no_return()

The same as c:create_reaction/3, but raises an exception if it fails.

Link to this callback

delete_all_reactions(message, emoji)

View Source (since 0.2.0)

Specs

delete_all_reactions(
  message :: Crux.Structs.Message.t(),
  emoji :: Crux.Structs.Emoji.identifier_resolvable()
) :: :ok | {:error, term()}

Deletes all reactions from a message.

For more informations see Discord Docs.

Link to this callback

delete_all_reactions(channel, message, emoji)

View Source (since 0.2.0)

Specs

delete_all_reactions(
  channel :: Crux.Structs.Channel.id_resolvable(),
  message :: Crux.Structs.Message.id_resolvable(),
  emoji :: Crux.Structs.Emoji.identifier_resolvable()
) :: :ok | {:error, term()}

Deletes all reactions from a message.

For more informations see Discord Docs.

Link to this callback

delete_all_reactions!(message, emoji)

View Source (optional) (since 0.2.0)

Specs

delete_all_reactions!(
  message :: Crux.Structs.Message.t(),
  emoji :: Crux.Structs.Emoji.identifier_resolvable()
) :: :ok | no_return()

The same as c:delete_all_reactions/2, but raises an exception if it fails.

Link to this callback

delete_all_reactions!(channel, message, emoji)

View Source (optional) (since 0.2.0)

Specs

delete_all_reactions!(
  channel :: Crux.Structs.Channel.id_resolvable(),
  message :: Crux.Structs.Message.id_resolvable(),
  emoji :: Crux.Structs.Emoji.identifier_resolvable()
) :: :ok | no_return()

The same as c:delete_all_reactions/3, but raises an exception if it fails.

Link to this callback

delete_channel(channel, reason)

View Source (since 0.2.0)

Specs

delete_channel(
  channel :: Crux.Structs.Channel.id_resolvable(),
  reason :: String.t() | nil
) :: {:ok, Crux.Structs.Channel.t()} | {:error, term()}

Deletes a channel.

For more informations see Discord Docs.

Link to this callback

delete_channel!(channel, reason)

View Source (optional) (since 0.2.0)

Specs

delete_channel!(
  channel :: Crux.Structs.Channel.id_resolvable(),
  reason :: String.t() | nil
) :: Crux.Structs.Channel.t() | no_return()

The same as c:delete_channel/2, but raises an exception if it fails.

Link to this callback

delete_channel_permissions(channel, target, reason)

View Source (since 0.2.0)

Specs

delete_channel_permissions(
  channel :: Crux.Structs.Channel.id_resolvable(),
  target :: Crux.Structs.Overwrite.target_resolvable(),
  reason :: String.t() | nil
) :: :ok | {:error, term()}

Deletes an overwrite from a channel.

For more informations see Discord Docs.

Link to this callback

delete_channel_permissions!(channel, target, reason)

View Source (optional) (since 0.2.0)

Specs

delete_channel_permissions!(
  channel :: Crux.Structs.Channel.id_resolvable(),
  target :: Crux.Structs.Overwrite.target_resolvable(),
  reason :: String.t() | nil
) :: :ok | no_return()

The same as c:delete_channel_permissions/3, but raises an exception if it fails.

Link to this callback

delete_guild(guild)

View Source (since 0.2.0)

Specs

delete_guild(guild :: Crux.Structs.Guild.id_resolvable()) ::
  :ok | {:error, term()}

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

For more informations see Discord Docs.

Link to this callback

delete_guild!(guild)

View Source (optional) (since 0.2.0)

Specs

delete_guild!(guild :: Crux.Structs.Guild.id_resolvable()) :: :ok | no_return()

The same as c:delete_guild/1, but raises an exception if it fails.

Link to this callback

delete_guild_emoji(guild, emoji, reason)

View Source (since 0.2.0)

Specs

delete_guild_emoji(
  guild :: Crux.Structs.Guild.id_resolvable(),
  emoji :: Crux.Structs.Emoji.id_resolvable(),
  reason :: String.t() | nil
) :: :ok | {:error, term()}

Deletes an emoji from a guild.

For more informations see Discord Docs.

Link to this callback

delete_guild_emoji!(guild, emoji, reason)

View Source (optional) (since 0.2.0)

Specs

delete_guild_emoji!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  emoji :: Crux.Structs.Emoji.id_resolvable(),
  reason :: String.t() | nil
) :: :ok | no_return()

The same as c:delete_guild_emoji/3, but raises an exception if it fails.

Link to this callback

delete_guild_integration(guild, integration_id)

View Source (since 0.2.0)

Specs

delete_guild_integration(
  guild :: Crux.Structs.Guild.id_resolvable(),
  integration_id :: Crux.Structs.Snowflake.resolvable()
) :: :ok | {:error, term()}

Deletes an integration from a guild.

For more informations see Discord Docs.

Link to this callback

delete_guild_integration!(guild, integration_id)

View Source (optional) (since 0.2.0)

Specs

delete_guild_integration!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  integration_id :: Crux.Structs.Snowflake.resolvable()
) :: :ok | no_return()

The same as c:delete_guild_integration/2, but raises an exception if it fails.

Link to this callback

delete_guild_role(guild, role, reason)

View Source (since 0.2.0)

Specs

delete_guild_role(
  guild :: Crux.Structs.Guild.id_resolvable(),
  role :: Crux.Structs.Role.id_resolvable(),
  reason :: String.t() | nil
) :: :ok | {:error, term()}

Deletes a role in a guild.

For more informations see Discord Docs.

Link to this callback

delete_guild_role!(guild, role, reason)

View Source (optional) (since 0.2.0)

Specs

delete_guild_role!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  role :: Crux.Structs.Role.id_resolvable(),
  reason :: String.t() | nil
) :: :ok | no_return()

The same as c:delete_guild_role/3, but raises an exception if it fails.

Link to this callback

delete_invite(invite_or_code)

View Source (since 0.2.0)

Specs

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 callback

delete_invite!(invite_or_code)

View Source (optional) (since 0.2.0)

Specs

delete_invite!(invite_or_code :: String.t() | Crux.Structs.Invite.t()) ::
  Crux.Structs.Invite.t() | no_return()

The same as c:delete_invite/1, but raises an exception if it fails.

Link to this callback

delete_message(message)

View Source (since 0.2.0)

Specs

delete_message(message :: Crux.Structs.Message.t()) :: :ok | {:error, term()}

Deletes a message

For more informations see Discord Docs.

Link to this callback

delete_message(channel_id, message_id)

View Source (since 0.2.0)

Specs

delete_message(
  channel_id :: Crux.Structs.Channel.id_resolvable(),
  message_id :: Crux.Structs.Message.id_resolvable()
) :: :ok | {:error, term()}

Deletes a message

For more informations see Discord Docs.

Link to this callback

delete_message!(message)

View Source (optional) (since 0.2.0)

Specs

delete_message!(message :: Crux.Structs.Message.t()) :: :ok | no_return()

The same as c:delete_message/1, but raises an exception if it fails.

Link to this callback

delete_message!(channel_id, message_id)

View Source (optional) (since 0.2.0)

Specs

delete_message!(
  channel_id :: Crux.Structs.Channel.id_resolvable(),
  message_id :: Crux.Structs.Message.id_resolvable()
) :: :ok | no_return()

The same as c:delete_message/2, but raises an exception if it fails.

Link to this callback

delete_messages(channel, messages)

View Source (since 0.2.0)

Specs

delete_messages(
  channel :: Crux.Structs.Channel.id_resolvable(),
  messages :: [Crux.Structs.Message.id_resolvable()]
) :: :ok | {:error, term()}

Deletes 2-100 messages not older than 14 days.

For more informations see Discord Docs

Link to this callback

delete_messages!(channel, messages)

View Source (optional) (since 0.2.0)

Specs

delete_messages!(
  channel :: Crux.Structs.Channel.id_resolvable(),
  messages :: [Crux.Structs.Message.id_resolvable()]
) :: :ok | no_return()

The same as c:delete_messages/2, but raises an exception if it fails.

Link to this callback

delete_pinned_message(message)

View Source (since 0.2.0)

Specs

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 callback

delete_pinned_message(channel, message)

View Source (since 0.2.0)

Specs

delete_pinned_message(
  channel :: Crux.Structs.Channel.id_resolvable(),
  message :: Crux.Structs.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 callback

delete_pinned_message!(message)

View Source (optional) (since 0.2.0)

Specs

delete_pinned_message!(message :: Crux.Structs.Message.t()) :: :ok | no_return()

The same as c:delete_pinned_message/1, but raises an exception if it fails.

Link to this callback

delete_pinned_message!(channel, message)

View Source (optional) (since 0.2.0)

Specs

delete_pinned_message!(
  channel :: Crux.Structs.Channel.id_resolvable(),
  message :: Crux.Structs.Message.id_resolvable()
) :: :ok | no_return()

The same as c:delete_pinned_message/2, but raises an exception if it fails.

Link to this callback

delete_reaction(channel, message, emoji, user)

View Source (since 0.2.0)

Specs

delete_reaction(
  channel :: Crux.Structs.Channel.id_resolvable(),
  message :: Crux.Structs.Message.id_resolvable(),
  emoji :: Crux.Structs.Emoji.identifier_resolvable(),
  user :: Crux.Structs.User.id_resolvable()
) :: :ok | {:error, term()}

Deletes a user from a reaction.

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

For more informations see Discord Docs2.

Link to this callback

delete_reaction!(channel, message, emoji, user)

View Source (optional) (since 0.2.0)

Specs

The same as c:delete_reaction/4, but raises an exception if it fails.

Link to this callback

delete_webhook(user, token)

View Source (since 0.2.0)

Specs

delete_webhook(
  user :: Crux.Structs.User.id_resolvable(),
  token :: String.t() | nil
) :: :ok | {:error, term()}

Deletes a webhook

For more information see Discord Docs

Link to this callback

delete_webhook!(user, token)

View Source (optional) (since 0.2.0)

Specs

delete_webhook!(
  user :: Crux.Structs.User.id_resolvable(),
  token :: String.t() | nil
) :: :ok | no_return()

The same as c:delete_webhook/2, but raises an exception if it fails.

Link to this callback

edit_channel_permissions(channel, target, data)

View Source (since 0.2.0)

Specs

edit_channel_permissions(
  channel :: Crux.Structs.Channel.id_resolvable(),
  target :: Crux.Structs.Overwrite.target_resolvable(),
  data :: Crux.Rest.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:Crux.Rest.edit_channel_permissions_data/0.

For more informations see Discord Docs.

Link to this callback

edit_channel_permissions!(channel, target, data)

View Source (optional) (since 0.2.0)

Specs

edit_channel_permissions!(
  channel :: Crux.Structs.Channel.id_resolvable(),
  target :: Crux.Structs.Overwrite.target_resolvable(),
  data :: Crux.Rest.edit_channel_permissions_data()
) :: :ok | no_return()

The same as c:edit_channel_permissions/3, but raises an exception if it fails.

Link to this callback

edit_message(target, args)

View Source (since 0.2.0)

Specs

edit_message(
  target :: Crux.Structs.Message.t(),
  args :: Crux.Rest.message_edit_data()
) :: {:ok, Crux.Structs.Message.t()} | {:error, term()}

Edits a message.

For more informations see Discord Docs.

Link to this callback

edit_message(channel_id, message_id, args)

View Source (since 0.2.0)

Specs

edit_message(
  channel_id :: Crux.Structs.Channel.id_resolvable(),
  message_id :: Crux.Structs.Message.id_resolvable(),
  args :: Crux.Rest.message_edit_data()
) :: {:ok, Crux.Structs.Message.t()} | {:error, term()}

Edits a message.

For more informations see Discord Docs.

Link to this callback

edit_message!(target, args)

View Source (optional) (since 0.2.0)

Specs

edit_message!(
  target :: Crux.Structs.Message.t(),
  args :: Crux.Rest.message_edit_data()
) :: Crux.Structs.Message.t() | no_return()

The same as c:edit_message/2, but raises an exception if it fails.

Link to this callback

edit_message!(channel_id, message_id, args)

View Source (optional) (since 0.2.0)

Specs

The same as c:edit_message/3, but raises an exception if it fails.

Link to this callback

execute_github_webhook(webhook, event, data)

View Source (since 0.2.0)

Specs

execute_github_webhook(
  webhook :: Crux.Structs.Webhook.t(),
  event :: String.t(),
  data :: term()
) :: :ok

Executes a github webhook

Returns :ok by default. If wait parameter is set to true, it will either return :ok or an error tuple. Discord does not return the message object unlike the regular webhook endpoint.

The event parameter is passed into the "x-github-event" header. If this is not set to a valid event (e.g, "push", "issue"), discord will not send the webhook but still return 204 OK

For more information see Github Docs

Link to this callback

execute_github_webhook(webhook, event, wait, data)

View Source (since 0.2.0)

Specs

execute_github_webhook(
  webhook :: Crux.Structs.Webhook.t(),
  event :: String.t(),
  wait :: boolean() | nil,
  data :: term()
) :: :ok | {:error, term()}
Link to this callback

execute_github_webhook(user, token, event, wait, data)

View Source (since 0.2.0)

Specs

execute_github_webhook(
  user :: Crux.Structs.User.id_resolvable(),
  token :: String.t(),
  event :: String.t(),
  wait :: boolean() | nil,
  data :: term()
) :: :ok | {:error, term()}
Link to this callback

execute_github_webhook!(webhook, event, data)

View Source (optional) (since 0.2.0)

Specs

execute_github_webhook!(
  webhook :: Crux.Structs.Webhook.t(),
  event :: String.t(),
  data :: term()
) :: :ok | no_return()

The same as c:execute_github_webhook/3, but raises an exception if it fails.

Link to this callback

execute_github_webhook!(webhook, event, wait, data)

View Source (optional) (since 0.2.0)

Specs

execute_github_webhook!(
  webhook :: Crux.Structs.Webhook.t(),
  event :: String.t(),
  wait :: boolean() | nil,
  data :: term()
) :: :ok | no_return()

The same as c:execute_github_webhook/4, but raises an exception if it fails.

Link to this callback

execute_github_webhook!(user, token, event, wait, data)

View Source (optional) (since 0.2.0)

Specs

execute_github_webhook!(
  user :: Crux.Structs.User.id_resolvable(),
  token :: String.t(),
  event :: String.t(),
  wait :: boolean() | nil,
  data :: term()
) :: :ok | no_return()

The same as c:execute_github_webhook/5, but raises an exception if it fails.

Link to this callback

execute_slack_webhook(webhook, data)

View Source (since 0.2.0)

Specs

execute_slack_webhook(webhook :: Crux.Structs.Webhook.t(), data :: term()) ::
  :ok

Executes a slack webhook

Returns :ok by default. If wait parameter is set to true, it will either return :ok or an error tuple. Discord does not return the message object unlike the regular webhook endpoint.

For more information see Slack Docs

Link to this callback

execute_slack_webhook(webhook, wait, data)

View Source (since 0.2.0)

Specs

execute_slack_webhook(
  webhook :: Crux.Structs.Webhook.t(),
  wait :: boolean() | nil,
  data :: term()
) :: :ok | {:error, term()}
Link to this callback

execute_slack_webhook(user, token, wait, data)

View Source (since 0.2.0)

Specs

execute_slack_webhook(
  user :: Crux.Structs.User.id_resolvable(),
  token :: String.t(),
  wait :: boolean() | nil,
  data :: term()
) :: :ok | {:error, term()}
Link to this callback

execute_slack_webhook!(webhook, data)

View Source (optional) (since 0.2.0)

Specs

execute_slack_webhook!(webhook :: Crux.Structs.Webhook.t(), data :: term()) ::
  :ok | no_return()

The same as c:execute_slack_webhook/2, but raises an exception if it fails.

Link to this callback

execute_slack_webhook!(webhook, wait, data)

View Source (optional) (since 0.2.0)

Specs

execute_slack_webhook!(
  webhook :: Crux.Structs.Webhook.t(),
  wait :: boolean() | nil,
  data :: term()
) :: :ok | no_return()

The same as c:execute_slack_webhook/3, but raises an exception if it fails.

Link to this callback

execute_slack_webhook!(user, token, wait, data)

View Source (optional) (since 0.2.0)

Specs

execute_slack_webhook!(
  user :: Crux.Structs.User.id_resolvable(),
  token :: String.t(),
  wait :: boolean() | nil,
  data :: term()
) :: :ok | no_return()

The same as c:execute_slack_webhook/4, but raises an exception if it fails.

Link to this callback

execute_webhook(webhook, data)

View Source (since 0.2.0)

Specs

execute_webhook(
  webhook :: Crux.Structs.Webhook.t(),
  data :: Crux.Rest.execute_webhook_options()
) :: :ok

Executes a webhook

Returns :ok by default. If wait parameter is set to true, returns a tuple returning the message object or error

For more information see Discord Docs

Link to this callback

execute_webhook(webhook, wait, data)

View Source (since 0.2.0)

Specs

execute_webhook(
  webhook :: Crux.Structs.Webhook.t(),
  wait :: boolean() | nil,
  data :: Crux.Rest.execute_webhook_options()
) :: :ok | {:ok, Crux.Structs.Message.t()} | {:error, term()}
Link to this callback

execute_webhook(user, token, wait, data)

View Source (since 0.2.0)

Specs

execute_webhook(
  user :: Crux.Structs.User.id_resolvable(),
  token :: String.t(),
  wait :: boolean() | nil,
  data :: Crux.Rest.execute_webhook_options()
) :: :ok | {:ok, Crux.Structs.Message.t()} | {:error, term()}
Link to this callback

execute_webhook!(webhook, data)

View Source (optional) (since 0.2.0)

Specs

execute_webhook!(
  webhook :: Crux.Structs.Webhook.t(),
  data :: Crux.Rest.execute_webhook_options()
) :: :ok | no_return()

The same as c:execute_webhook/2, but raises an exception if it fails.

Link to this callback

execute_webhook!(webhook, wait, data)

View Source (optional) (since 0.2.0)

Specs

execute_webhook!(
  webhook :: Crux.Structs.Webhook.t(),
  wait :: boolean() | nil,
  data :: Crux.Rest.execute_webhook_options()
) :: :ok | no_return()

The same as c:execute_webhook/3, but raises an exception if it fails.

Link to this callback

execute_webhook!(user, token, wait, data)

View Source (optional) (since 0.2.0)

Specs

execute_webhook!(
  user :: Crux.Structs.User.id_resolvable(),
  token :: String.t(),
  wait :: boolean() | nil,
  data :: Crux.Rest.execute_webhook_options()
) :: :ok | no_return()

The same as c:execute_webhook/4, but raises an exception if it fails.

Specs

gateway() :: {:ok, term()} | {:error, term()}

Gets the gateway url from the api.

For more informations see Discord Docs.

Link to this callback

gateway!()

View Source (optional) (since 0.2.0)

Specs

gateway!() :: term() | no_return()

The same as c:gateway/0, but raises an exception if it fails.

Link to this callback

gateway_bot()

View Source (since 0.2.0)

Specs

gateway_bot() :: {:ok, term()} | {:error, term()}

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

For more informations see Discord Docs.

Link to this callback

gateway_bot!()

View Source (optional) (since 0.2.0)

Specs

gateway_bot!() :: term() | no_return()

The same as c:gateway_bot/0, but raises an exception if it fails.

Link to this callback

get_audit_logs(guild, options)

View Source (since 0.2.0)

Specs

get_audit_logs(
  guild :: Crux.Structs.Guild.id_resolvable(),
  options :: Crux.Rest.audit_log_options() | nil
) :: {:ok, Crux.Structs.AuditLog.t()} | {:error, term()}

Gets the audit logs for a guild

Link to this callback

get_audit_logs!(guild, options)

View Source (optional) (since 0.2.0)

Specs

get_audit_logs!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  options :: Crux.Rest.audit_log_options() | nil
) :: Crux.Structs.AuditLog.t() | no_return()

The same as c:get_audit_logs/2, but raises an exception if it fails.

Link to this callback

get_channel(channel)

View Source (since 0.2.0)

Specs

get_channel(channel :: Crux.Structs.Channel.id_resolvable()) ::
  {: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 callback

get_channel!(channel)

View Source (optional) (since 0.2.0)

Specs

The same as c:get_channel/1, but raises an exception if it fails.

Link to this callback

get_channel_invites(channel)

View Source (since 0.2.0)

Specs

get_channel_invites(channel :: Crux.Structs.Channel.id_resolvable()) ::
  {:ok, %{required(String.t()) => Crux.Structs.Invite.t()}} | {:error, term()}

Gets invites for the specified channel from the api.

For more informations see Discord Docs

Link to this callback

get_channel_invites!(channel)

View Source (optional) (since 0.2.0)

Specs

get_channel_invites!(channel :: Crux.Structs.Channel.id_resolvable()) ::
  %{required(String.t()) => Crux.Structs.Invite.t()} | no_return()

The same as c:get_channel_invites/1, but raises an exception if it fails.

Link to this callback

get_current_user()

View Source (since 0.2.1)

Specs

get_current_user() :: {:ok, Crux.Structs.User.t()} | {:error, term()}

Gets the current user from the api.

For more information see Discord Docs.

Link to this callback

get_current_user!()

View Source (optional) (since 0.2.1)

Specs

get_current_user!() :: Crux.Structs.User.t() | no_return()

The same as c:get_current_user/0, but raises an exception if it fails.

Link to this callback

get_current_user_guilds(data)

View Source (since 0.2.0)

Specs

get_current_user_guilds(data :: Crux.Rest.get_current_user_guild_data()) ::
  {:ok, %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.Guild.t()}}
  | {:error, term()}

Gets a list of partial Crux.Structs.Guilds the current user is a member of.

For more informations see Discord Docs.

Link to this callback

get_current_user_guilds!(data)

View Source (optional) (since 0.2.0)

Specs

get_current_user_guilds!(data :: Crux.Rest.get_current_user_guild_data()) ::
  %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.Guild.t()}
  | no_return()

The same as c:get_current_user_guilds/1, but raises an exception if it fails.

Link to this callback

get_guild(guild)

View Source (since 0.2.0)

Specs

get_guild(guild :: Crux.Structs.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 callback

get_guild!(guild)

View Source (optional) (since 0.2.0)

Specs

The same as c:get_guild/1, but raises an exception if it fails.

Link to this callback

get_guild_ban(guild, user)

View Source (since 0.2.0)

Specs

get_guild_ban(
  guild :: Crux.Structs.Guild.id_resolvable(),
  user :: Crux.Structs.User.id_resolvable()
) ::
  {:ok, %{user: Crux.Structs.User.t(), reason: String.t() | nil}}
  | {:error, term()}

Gets 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 callback

get_guild_ban!(guild, user)

View Source (optional) (since 0.2.0)

Specs

get_guild_ban!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  user :: Crux.Structs.User.id_resolvable()
) :: %{user: Crux.Structs.User.t(), reason: String.t() | nil} | no_return()

The same as c:get_guild_ban/2, but raises an exception if it fails.

Link to this callback

get_guild_bans(guild)

View Source (since 0.2.0)

Specs

get_guild_bans(guild :: Crux.Structs.Guild.id_resolvable()) ::
  {:ok,
   %{
     required(Crux.Structs.Snowflake.t()) => %{
       user: Crux.Structs.User.t(),
       reason: String.t() | nil
     }
   }}
  | {:error, term()}

Gets a map of banned users along their ban reasons.

For more informations see discord Docs.

Link to this callback

get_guild_bans!(guild)

View Source (optional) (since 0.2.0)

Specs

get_guild_bans!(guild :: Crux.Structs.Guild.id_resolvable()) ::
  %{
    required(Crux.Structs.Snowflake.t()) => %{
      user: Crux.Structs.User.t(),
      reason: String.t() | nil
    }
  }
  | no_return()

The same as c:get_guild_bans/1, but raises an exception if it fails.

Link to this callback

get_guild_channels(guild)

View Source (since 0.2.0)

Specs

get_guild_channels(guild :: Crux.Structs.Guild.id_resolvable()) ::
  {:ok, %{required(Crux.Structs.Snowflake.t()) => 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 callback

get_guild_channels!(guild)

View Source (optional) (since 0.2.0)

Specs

get_guild_channels!(guild :: Crux.Structs.Guild.id_resolvable()) ::
  %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.Channel.t()}
  | no_return()

The same as c:get_guild_channels/1, but raises an exception if it fails.

Link to this callback

get_guild_embed(guild)

View Source (since 0.2.0)

Specs

get_guild_embed(guild :: Crux.Structs.Guild.id_resolvable()) ::
  {:ok, term()} | {:error, term()}

Gets a guild's embed (server widget).

Returns a Guild Embed Object.

For more informations see Discord Docs.

Link to this callback

get_guild_embed!(guild)

View Source (optional) (since 0.2.0)

Specs

get_guild_embed!(guild :: Crux.Structs.Guild.id_resolvable()) ::
  term() | no_return()

The same as c:get_guild_embed/1, but raises an exception if it fails.

Link to this callback

get_guild_emoji(guild, emoji)

View Source (since 0.2.0)

Specs

get_guild_emoji(
  guild :: Crux.Structs.Guild.id_resolvable(),
  emoji :: Crux.Structs.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 callback

get_guild_emoji!(guild, emoji)

View Source (optional) (since 0.2.0)

Specs

get_guild_emoji!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  emoji :: Crux.Structs.Emoji.id_resolvable()
) :: Crux.Structs.Emoji | no_return()

The same as c:get_guild_emoji/2, but raises an exception if it fails.

Link to this callback

get_guild_integrations(guild)

View Source (since 0.2.0)

Specs

get_guild_integrations(guild :: Crux.Structs.Guild.id_resolvable()) ::
  {:ok, list()} | {:error, term()}

Gets a list of guild integrations.

Returns a list of Integration Objects.

For more informations see Discord Docs.

Link to this callback

get_guild_integrations!(guild)

View Source (optional) (since 0.2.0)

Specs

get_guild_integrations!(guild :: Crux.Structs.Guild.id_resolvable()) ::
  list() | no_return()

The same as c:get_guild_integrations/1, but raises an exception if it fails.

Link to this callback

get_guild_invites(guild)

View Source (since 0.2.0)

Specs

get_guild_invites(guild :: Crux.Structs.Guild.id_resolvable()) ::
  {:ok, %{required(String.t()) => Crux.Structs.Invite.t()}} | {:error, term()}

Gets all available invites in a guild.

For more informations see Discord Docs.

Link to this callback

get_guild_invites!(guild)

View Source (optional) (since 0.2.0)

Specs

get_guild_invites!(guild :: Crux.Structs.Guild.id_resolvable()) ::
  %{required(String.t()) => Crux.Structs.Invite.t()} | no_return()

The same as c:get_guild_invites/1, but raises an exception if it fails.

Link to this callback

get_guild_member(guild, user)

View Source (since 0.2.0)

Specs

get_guild_member(
  guild :: Crux.Structs.Guild.id_resolvable(),
  user :: Crux.Structs.User.id_resolvable()
) :: {:ok, Crux.Structs.Member.t()} | {:error, term()}

Gets a member from the api.

This may be necessary for offline members in large guilds.

For more informations see Discord Docs.

Link to this callback

get_guild_member!(guild, user)

View Source (optional) (since 0.2.0)

Specs

The same as c:get_guild_member/2, but raises an exception if it fails.

Link to this callback

get_guild_prune_count(guild, days)

View Source (since 0.2.0)

Specs

get_guild_prune_count(
  guild :: Crux.Structs.Guild.id_resolvable(),
  days :: pos_integer()
) :: {:ok, non_neg_integer()} | {:error, term()}

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

For more informations see Discord Docs.

Link to this callback

get_guild_prune_count!(guild, days)

View Source (optional) (since 0.2.0)

Specs

get_guild_prune_count!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  days :: pos_integer()
) :: non_neg_integer() | no_return()

The same as c:get_guild_prune_count/2, but raises an exception if it fails.

Link to this callback

get_guild_roles(guild)

View Source (since 0.2.0)

Specs

get_guild_roles(guild :: Crux.Structs.Guild.id_resolvable()) ::
  {:ok, %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.Role.t()}}
  | {:error, term()}

Gets 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 callback

get_guild_roles!(guild)

View Source (optional) (since 0.2.0)

Specs

get_guild_roles!(guild :: Crux.Structs.Guild.id_resolvable()) ::
  %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.Role.t()} | no_return()

The same as c:get_guild_roles/1, but raises an exception if it fails.

Link to this callback

get_guild_vanity_invite(guild)

View Source (since 0.2.1)

Specs

get_guild_vanity_invite(guild :: Crux.Structs.Guild.id_resolvable()) ::
  {:ok, Crux.Structs.Invite.t()} | {:error, term()}

Gets the vanity invite of a guild, if any

Link to this callback

get_guild_vanity_invite!(guild)

View Source (optional) (since 0.2.1)

Specs

get_guild_vanity_invite!(guild :: Crux.Structs.Guild.id_resolvable()) ::
  Crux.Structs.Invite.t() | no_return()

The same as c:get_guild_vanity_invite/1, but raises an exception if it fails.

Link to this callback

get_guild_vanity_url(guild)

View Source (since 0.2.0)
This callback is deprecated. Use get_guild_vanity_invite/1 instead.

Specs

get_guild_vanity_url(guild :: Crux.Structs.Guild.id_resolvable()) ::
  {:ok, String.t()} | {:error, term()}

Gets the vanity url of a guild, if any

Link to this callback

get_guild_vanity_url!(guild)

View Source (optional) (since 0.2.0)
This callback is deprecated. Use get_guild_vanity_invite/1 instead.

Specs

get_guild_vanity_url!(guild :: Crux.Structs.Guild.id_resolvable()) ::
  String.t() | no_return()

The same as c:get_guild_vanity_url/1, but raises an exception if it fails.

Link to this callback

get_guild_voice_regions(guild)

View Source (since 0.2.0)

Specs

get_guild_voice_regions(guild :: Crux.Structs.Guild.id_resolvable()) ::
  {:ok, term()} | {:error, term()}

Gets 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 callback

get_guild_voice_regions!(guild)

View Source (optional) (since 0.2.0)

Specs

get_guild_voice_regions!(guild :: Crux.Structs.Guild.id_resolvable()) ::
  term() | no_return()

The same as c:get_guild_voice_regions/1, but raises an exception if it fails.

Link to this callback

get_invite(code)

View Source (since 0.2.0)

Specs

get_invite(code :: String.t()) ::
  {:ok, Crux.Structs.Invite.t()} | {:error, term()}

Gets an invite from the api.

For more informations see Discord Docs.

Link to this callback

get_invite!(code)

View Source (optional) (since 0.2.0)

Specs

get_invite!(code :: String.t()) :: Crux.Structs.Invite.t() | no_return()

The same as c:get_invite/1, but raises an exception if it fails.

Link to this callback

get_message(channel, message_id)

View Source (since 0.2.0)

Specs

get_message(
  channel :: Crux.Structs.Channel.id_resolvable(),
  message_id :: Crux.Structs.Message.id_resolvable()
) :: {:ok, Crux.Structs.Message.t()} | {:error, term()}

Gets a message from the api.

For more informations see Discord Docs.

Link to this callback

get_message!(channel, message_id)

View Source (optional) (since 0.2.0)

Specs

The same as c:get_message/2, but raises an exception if it fails.

Link to this callback

get_messages(channel, args)

View Source (since 0.2.0)

Specs

get_messages(
  channel :: Crux.Structs.Channel.id_resolvable(),
  args :: Crux.Rest.get_messages_data()
) ::
  {:ok, %{required(Crux.Structs.Snowflake.t()) => 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 callback

get_messages!(channel, args)

View Source (optional) (since 0.2.0)

Specs

The same as c:get_messages/2, but raises an exception if it fails.

Link to this callback

get_pinned_messages(channel)

View Source (since 0.2.0)

Specs

get_pinned_messages(channel :: Crux.Structs.Channel.id_resolvable()) ::
  {:ok, %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.Message.t()}}
  | {:error, term()}

Gets a list of pinned messages from the api.

For more informations see Discord Docs.

Link to this callback

get_pinned_messages!(channel)

View Source (optional) (since 0.2.0)

Specs

get_pinned_messages!(channel :: Crux.Structs.Channel.id_resolvable()) ::
  %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.Message.t()}
  | no_return()

The same as c:get_pinned_messages/1, but raises an exception if it fails.

Link to this callback

get_reactions(message, emoji, args)

View Source (since 0.2.0)

Specs

get_reactions(
  message :: Crux.Structs.Message.t(),
  emoji :: Crux.Structs.Emoji.identifier_resolvable(),
  args :: Crux.Rest.get_reactions_data()
) ::
  {:ok, %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.User.t()}}
  | {:error, term()}
Link to this callback

get_reactions(channel, message, emoji, args)

View Source (since 0.2.0)

Specs

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 callback

get_reactions!(message, emoji, args)

View Source (optional) (since 0.2.0)

Specs

The same as c:get_reactions/3, but raises an exception if it fails.

Link to this callback

get_reactions!(channel, message, emoji, args)

View Source (optional) (since 0.2.0)

Specs

The same as c:get_reactions/4, but raises an exception if it fails.

Link to this callback

get_user(user)

View Source (since 0.2.0)

Specs

get_user(user :: Crux.Structs.User.id_resolvable()) ::
  {:ok, Crux.Structs.User.t()} | {:error, term()}

Gets a user from the api.

For more informations see Discord Docs.

Link to this callback

get_user!(user)

View Source (optional) (since 0.2.0)

Specs

The same as c:get_user/1, but raises an exception if it fails.

Link to this callback

get_webhook(user, token)

View Source (since 0.2.0)

Specs

get_webhook(
  user :: Crux.Structs.User.id_resolvable(),
  token :: String.t() | nil
) :: {:ok, Crux.Structs.Webhook.t()} | {:error, term()}

Gets a webhook

For more information see Discord Docs

Link to this callback

get_webhook!(user, token)

View Source (optional) (since 0.2.0)

Specs

get_webhook!(
  user :: Crux.Structs.User.id_resolvable(),
  token :: String.t() | nil
) :: Crux.Structs.Webhook.t() | no_return()

The same as c:get_webhook/2, but raises an exception if it fails.

Link to this callback

leave_guild(guild)

View Source (since 0.2.0)

Specs

leave_guild(guild :: Crux.Structs.Guild.id_resolvable()) ::
  :ok | {:error, term()}

Leaves a guild.

For more informations see Discord Docs.

Link to this callback

leave_guild!(guild)

View Source (optional) (since 0.2.0)

Specs

leave_guild!(guild :: Crux.Structs.Guild.id_resolvable()) :: :ok | no_return()

The same as c:leave_guild/1, but raises an exception if it fails.

Link to this callback

list_channel_webhooks(channel)

View Source (since 0.2.0)

Specs

list_channel_webhooks(channel :: Crux.Structs.Channel.id_resolvable()) ::
  {:ok, %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.Webhook.t()}}
  | {:error, term()}

Gets a channel's webhook list

For more information see Discord Docs

Link to this callback

list_channel_webhooks!(channel)

View Source (optional) (since 0.2.0)

Specs

list_channel_webhooks!(channel :: Crux.Structs.Channel.id_resolvable()) ::
  %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.Webhook.t()}
  | no_return()

The same as c:list_channel_webhooks/1, but raises an exception if it fails.

Link to this callback

list_guild_emojis(guild)

View Source (since 0.2.0)

Specs

list_guild_emojis(guild :: Crux.Structs.Guild.id_resolvable()) ::
  {:ok, %{required(Crux.Structs.Snowflake.t()) => 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 callback

list_guild_emojis!(guild)

View Source (optional) (since 0.2.0)

Specs

list_guild_emojis!(guild :: Crux.Structs.Guild.id_resolvable()) ::
  %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.Emoji.t()}
  | no_return()

The same as c:list_guild_emojis/1, but raises an exception if it fails.

Link to this callback

list_guild_members(guild, options)

View Source (since 0.2.0)

Specs

list_guild_members(
  guild :: Crux.Structs.Guild.id_resolvable(),
  options :: Crux.Rest.list_guild_members_options()
) ::
  {:ok, %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.Member.t()}}
  | {:error, term()}

Gets a list of members from the guild.

For more informations see Discord Docs.

Link to this callback

list_guild_members!(guild, options)

View Source (optional) (since 0.2.0)

Specs

The same as c:list_guild_members/2, but raises an exception if it fails.

Link to this callback

list_guild_webhooks(guild)

View Source (since 0.2.0)

Specs

list_guild_webhooks(guild :: Crux.Structs.Guild.id_resolvable()) ::
  {:ok, %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.Webhook.t()}}
  | {:error, term()}

Gets a guild's webhook list

For more information see Discord Docs

Link to this callback

list_guild_webhooks!(guild)

View Source (optional) (since 0.2.0)

Specs

list_guild_webhooks!(guild :: Crux.Structs.Guild.id_resolvable()) ::
  %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.Webhook.t()}
  | no_return()

The same as c:list_guild_webhooks/1, but raises an exception if it fails.

Link to this callback

modify_channel(channel, data)

View Source (since 0.2.0)

Specs

modify_channel(
  channel :: Crux.Structs.Channel.id_resolvable(),
  data :: Crux.Rest.modify_channel_data()
) :: {:ok, Crux.Structs.Channel.t()} | {:error, term()}

Modifies a channel, see t:Crux.Rest.modify_channel_data/0 for available options.

For more informations see Discord Docs.

Link to this callback

modify_channel!(channel, data)

View Source (optional) (since 0.2.0)

Specs

The same as c:modify_channel/2, but raises an exception if it fails.

Link to this callback

modify_current_user(data)

View Source (since 0.2.0)

Specs

modify_current_user(data :: Crux.Rest.modify_current_user_data()) ::
  {:ok, Crux.Structs.User.t()} | {:error, term()}

Modifes the currently logged in user.

For more informations see Discord Docs.

Link to this callback

modify_current_user!(data)

View Source (optional) (since 0.2.0)

Specs

modify_current_user!(data :: Crux.Rest.modify_current_user_data()) ::
  Crux.Structs.User.t() | no_return()

The same as c:modify_current_user/1, but raises an exception if it fails.

Link to this callback

modify_current_users_nick(guild, nick, reason)

View Source (since 0.2.0)

Specs

modify_current_users_nick(
  guild :: Crux.Structs.Guild.id_resolvable(),
  nick :: String.t(),
  reason :: String.t() | nil
) :: :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 callback

modify_current_users_nick!(guild, nick, reason)

View Source (optional) (since 0.2.0)

Specs

modify_current_users_nick!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  nick :: String.t(),
  reason :: String.t() | nil
) :: :ok | no_return()

The same as c:modify_current_users_nick/3, but raises an exception if it fails.

Link to this callback

modify_guild(guild, data)

View Source (since 0.2.0)

Specs

modify_guild(
  guild :: Crux.Structs.Guild.id_resolvable(),
  data :: Crux.Rest.modify_guild_data()
) :: {:ok, Crux.Structs.Guild.t()} | {:error, term()}

Updates a guild, see t:Crux.Rest.modify_guild_data/0 for available options.

For more informations see Discord Docs.

Link to this callback

modify_guild!(guild, data)

View Source (optional) (since 0.2.0)

Specs

The same as c:modify_guild/2, but raises an exception if it fails.

Link to this callback

modify_guild_channel_positions(guild, channels)

View Source (since 0.2.0)

Specs

modify_guild_channel_positions(
  guild :: Crux.Structs.Guild.id_resolvable(),
  channels :: [Crux.Structs.Channel.position_resolvable()]
) :: :ok | {:error, term()}

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

For more informations see Discord Docs.

Link to this callback

modify_guild_channel_positions!(guild, channels)

View Source (optional) (since 0.2.0)

Specs

modify_guild_channel_positions!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  channels :: [Crux.Structs.Channel.position_resolvable()]
) :: :ok | no_return()

The same as c:modify_guild_channel_positions/2, but raises an exception if it fails.

Link to this callback

modify_guild_embed(guild, data)

View Source (since 0.2.0)

Specs

modify_guild_embed(
  guild :: Crux.Structs.Guild.id_resolvable(),
  data ::
    %{
      optional(:enabled) => boolean(),
      optional(:channel_id) => Crux.Structs.Channel.id_resolvable()
    }
    | [enabled: boolean(), channel_id: Crux.Structs.Channel.id_resolvable()]
) :: {: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 callback

modify_guild_embed!(guild, data)

View Source (optional) (since 0.2.0)

Specs

modify_guild_embed!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  data ::
    %{
      optional(:enabled) => boolean(),
      optional(:channel_id) => Crux.Structs.Channel.id_resolvable()
    }
    | [enabled: boolean(), channel_id: Crux.Structs.Channel.id_resolvable()]
) :: term() | no_return()

The same as c:modify_guild_embed/2, but raises an exception if it fails.

Link to this callback

modify_guild_emoji(guild, emoji, data)

View Source (since 0.2.0)

Specs

modify_guild_emoji(
  guild :: Crux.Structs.Guild.id_resolvable(),
  emoji :: Crux.Structs.Emoji.id_resolvable(),
  data :: Crux.Rest.modify_guild_emoji_data()
) :: {:ok, Crux.Structs.Emoji} | {:error, term()}

Modifies a guild emoji.

For more informations see Discord Docs.

Link to this callback

modify_guild_emoji!(guild, emoji, data)

View Source (optional) (since 0.2.0)

Specs

modify_guild_emoji!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  emoji :: Crux.Structs.Emoji.id_resolvable(),
  data :: Crux.Rest.modify_guild_emoji_data()
) :: Crux.Structs.Emoji | no_return()

The same as c:modify_guild_emoji/3, but raises an exception if it fails.

Link to this callback

modify_guild_integration(guild, integration_id, data)

View Source (since 0.2.0)

Specs

modify_guild_integration(
  guild :: Crux.Structs.Guild.id_resolvable(),
  integration_id :: Crux.Structs.Snowflake.resolvable(),
  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 callback

modify_guild_integration!(guild, integration_id, data)

View Source (optional) (since 0.2.0)

Specs

modify_guild_integration!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  integration_id :: Crux.Structs.Snowflake.resolvable(),
  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 | no_return()

The same as c:modify_guild_integration/3, but raises an exception if it fails.

Link to this callback

modify_guild_member(guild, member, data)

View Source (since 0.2.0)

Specs

modify_guild_member(
  guild :: Crux.Structs.Guild.id_resolvable(),
  member :: Crux.Structs.User.id_resolvable(),
  data :: Crux.Rest.modify_guild_member_data()
) :: :ok | {:error, term()}

Modifies a member in a guild.

For more informations see Discord Docs.

Link to this callback

modify_guild_member!(guild, member, data)

View Source (optional) (since 0.2.0)

Specs

modify_guild_member!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  member :: Crux.Structs.User.id_resolvable(),
  data :: Crux.Rest.modify_guild_member_data()
) :: :ok | no_return()

The same as c:modify_guild_member/3, but raises an exception if it fails.

Link to this callback

modify_guild_role(guild, role, data)

View Source (since 0.2.0)

Specs

modify_guild_role(
  guild :: Crux.Structs.Guild.id_resolvable(),
  role :: Crux.Structs.Role.id_resolvable(),
  data :: Crux.Rest.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 callback

modify_guild_role!(guild, role, data)

View Source (optional) (since 0.2.0)

Specs

The same as c:modify_guild_role/3, but raises an exception if it fails.

Link to this callback

modify_guild_role_positions(guild, data)

View Source (since 0.2.0)

Specs

modify_guild_role_positions(
  guild :: Crux.Structs.Guild.id_resolvable(),
  data :: [Crux.Structs.Role.position_resolvable()]
) ::
  {:ok, %{required(Crux.Structs.Snowflake.t()) => 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 callback

modify_guild_role_positions!(guild, data)

View Source (optional) (since 0.2.0)

Specs

modify_guild_role_positions!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  data :: [Crux.Structs.Role.position_resolvable()]
) ::
  %{required(Crux.Structs.Snowflake.t()) => Crux.Structs.Role.t()} | no_return()

The same as c:modify_guild_role_positions/2, but raises an exception if it fails.

Link to this callback

remove_guild_ban(guild, user, reason)

View Source (since 0.2.0)

Specs

remove_guild_ban(
  guild :: Crux.Structs.Guild.id_resolvable(),
  user :: Crux.Structs.User.id_resolvable(),
  reason :: String.t() | nil
) :: :ok | {:error, term()}

Removes a ban for a user from a guild.

For more informations see Discord Docs.

Link to this callback

remove_guild_ban!(guild, user, reason)

View Source (optional) (since 0.2.0)

Specs

remove_guild_ban!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  user :: Crux.Structs.User.id_resolvable(),
  reason :: String.t() | nil
) :: :ok | no_return()

The same as c:remove_guild_ban/3, but raises an exception if it fails.

Link to this callback

remove_guild_member_role(guild, member, role, reason)

View Source (since 0.2.0)

Specs

remove_guild_member_role(
  guild :: Crux.Structs.Guild.id_resolvable(),
  member :: Crux.Structs.User.id_resolvable(),
  role :: Crux.Structs.Role.id_resolvable(),
  reason :: String.t() | nil
) :: :ok | {:error, term()}

Removes a role from a member.

For more informations see Discord Docs.

Link to this callback

remove_guild_member_role!(guild, member, role, reason)

View Source (optional) (since 0.2.0)

Specs

remove_guild_member_role!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  member :: Crux.Structs.User.id_resolvable(),
  role :: Crux.Structs.Role.id_resolvable(),
  reason :: String.t() | nil
) :: :ok | no_return()

The same as c:remove_guild_member_role/4, but raises an exception if it fails.

Link to this callback

sync_guild_integration(guild, integration_id)

View Source (since 0.2.0)

Specs

sync_guild_integration(
  guild :: Crux.Structs.Guild.id_resolvable(),
  integration_id :: Crux.Structs.Snowflake.resolvable()
) :: :ok | {:error, term()}

Syncs an integration for a guild.

For more informations see Discord Docs.

Link to this callback

sync_guild_integration!(guild, integration_id)

View Source (optional) (since 0.2.0)

Specs

sync_guild_integration!(
  guild :: Crux.Structs.Guild.id_resolvable(),
  integration_id :: Crux.Structs.Snowflake.resolvable()
) :: :ok | no_return()

The same as c:sync_guild_integration/2, but raises an exception if it fails.

Link to this callback

trigger_typing(channel)

View Source (since 0.2.0)

Specs

trigger_typing(channel :: Crux.Structs.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.

Link to this callback

trigger_typing!(channel)

View Source (optional) (since 0.2.0)

Specs

trigger_typing!(channel :: Crux.Structs.Channel.id_resolvable()) ::
  :ok | no_return()

The same as c:trigger_typing/1, but raises an exception if it fails.

Link to this callback

update_webhook(user, token, data)

View Source (since 0.2.0)

Specs

update_webhook(
  user :: Crux.Structs.User.id_resolvable(),
  token :: String.t() | nil,
  data ::
    %{
      optional(:name) => String.t(),
      optional(:avatar) => Crux.Rest.Util.image(),
      optional(:channel_id) => Crux.Structs.Channel.id_resolvable()
    }
    | [
        name: String.t(),
        avatar: Crux.Rest.Util.image(),
        channel_id: Crux.Structs.Channel.id_resolvable()
      ]
) :: {:ok, Crux.Structs.Webhook.t()} | {:error, term()}

Updates a webhook

For more information see Discord Docs

Link to this callback

update_webhook!(user, token, data)

View Source (optional) (since 0.2.0)

Specs

update_webhook!(
  user :: Crux.Structs.User.id_resolvable(),
  token :: String.t() | nil,
  data ::
    %{
      optional(:name) => String.t(),
      optional(:avatar) => Crux.Rest.Util.image(),
      optional(:channel_id) => Crux.Structs.Channel.id_resolvable()
    }
    | [
        name: String.t(),
        avatar: Crux.Rest.Util.image(),
        channel_id: Crux.Structs.Channel.id_resolvable()
      ]
) :: Crux.Structs.Webhook.t() | no_return()

The same as c:update_webhook/3, but raises an exception if it fails.