Nostrum.Api.Webhook (nostrum v0.11.0-dev)
View SourceFunctions for interacting with the Discord API's webhook endpoints.
Summary
Functions
Creates a webhook.
Deletes a webhook.
Edits a message previously created by the same webhook,
args are the same as execute/3
,
however all fields are optional.
Executes a webhook.
Executes a git webhook.
Executes a slack webhook.
Gets a webhook by id.
Retrieves the original message of a webhook.
Gets a webhook by id and token.
Modifies a webhook.
Modifies a webhook with a token.
Types
Functions
@spec create( Nostrum.Struct.Channel.id(), %{name: String.t(), avatar: String.t()}, Nostrum.Struct.Guild.AuditLogEntry.reason() ) :: Nostrum.Api.error() | {:ok, Nostrum.Struct.Webhook.t()}
Creates a webhook.
Parameters
channel_id
- Id of the channel to send the message to.args
- Map with the following required keys:name
- Name of the webhook.avatar
- Base64 128x128 jpeg image for the default avatar.
reason
- An optional reason for the guild audit log.
@spec delete(Nostrum.Struct.Webhook.id(), Nostrum.Struct.Guild.AuditLogEntry.reason()) :: Nostrum.Api.error() | {:ok}
Deletes a webhook.
Parameters
webhook_id
- Id of webhook to delete.reason
- An optional reason for the guild audit log.
@spec edit_message( Nostrum.Struct.Webhook.id(), Nostrum.Struct.Webhook.token(), Nostrum.Struct.Message.id(), map() ) :: Nostrum.Api.error() | {:ok, Nostrum.Struct.Message.t()}
Edits a message previously created by the same webhook,
args are the same as execute/3
,
however all fields are optional.
@spec execute( Nostrum.Struct.Webhook.id() | Nostrum.Struct.User.id(), Nostrum.Struct.Webhook.token() | Nostrum.Struct.Interaction.token(), matrix(), boolean() ) :: Nostrum.Api.error() | {:ok} | {:ok, Nostrum.Struct.Message.t()}
Executes a webhook.
Parameters
webhook_id
- Id of the webhook to execute.webhook_token
- Token of the webhook to execute.args
- Map with the following allowed keys:content
- Message content.files
- List of Files to send.embeds
- List of embeds to send.username
- Overrides the default name of the webhook.avatar_url
- Overrides the default avatar of the webhook.tts
- Whether the message should be read over text to speech.flags
- Bitwise flags.thread_id
- Send a message to the specified thread within the webhook's channel.allowed_mentions
- Mentions to allow in the webhook message
wait
- Whether to return an error or not. Defaults tofalse
.
Note: If wait
is true
, this method will return a Message.t()
on success.
At least one of content
, files
or embeds
should be supplied in the args
parameter.
@spec execute_git( Nostrum.Struct.Webhook.id(), Nostrum.Struct.Webhook.token(), boolean() ) :: Nostrum.Api.error() | {:ok}
Executes a git webhook.
Parameters
webhook_id
- Id of the webhook to execute.webhook_token
- Token of the webhook to execute.
@spec execute_slack( Nostrum.Struct.Webhook.id(), Nostrum.Struct.Webhook.token(), boolean() ) :: Nostrum.Api.error() | {:ok}
Executes a slack webhook.
Parameters
webhook_id
- Id of the webhook to execute.webhook_token
- Token of the webhook to execute.
@spec get(Nostrum.Struct.Webhook.id()) :: Nostrum.Api.error() | {:ok, Nostrum.Struct.Webhook.t()}
Gets a webhook by id.
Parameters
webhook_id
- Id of the webhook to get.
@spec get_message(Nostrum.Struct.Webhook.t(), Nostrum.Struct.Message.id()) :: Nostrum.Api.error() | {:ok, Nostrum.Struct.Message.t()}
Retrieves the original message of a webhook.
@spec get_with_token(Nostrum.Struct.Webhook.id(), Nostrum.Struct.Webhook.token()) :: Nostrum.Api.error() | {:ok, Nostrum.Struct.Webhook.t()}
Gets a webhook by id and token.
This method is exactly like get/1
but does not require
authentication.
Parameters
webhook_id
- Id of the webhook to get.webhook_token
- Token of the webhook to get.
@spec modify( Nostrum.Struct.Webhook.id(), %{ optional(:name) => String.t(), optional(:avatar) => String.t() | nil, optional(:channel_id) => Nostrum.Struct.Channel.id() }, Nostrum.Struct.Guild.AuditLogEntry.reason() ) :: Nostrum.Api.error() | {:ok, Nostrum.Struct.Webhook.t()}
Modifies a webhook.
Parameters
webhook_id
- Id of the webhook to modify.args
- Map with the following optional keys:name
- Name of the webhook.avatar
- Base64 128x128 jpeg image for the default avatar.channel_id
- The new channel this webhook should be moved to.
reason
- An optional reason for the guild audit log.
Reference
See the Discord developer docs.
@spec modify_with_token( Nostrum.Struct.Webhook.id(), Nostrum.Struct.Webhook.token(), %{ optional(:name) => String.t(), optional(:avatar) => String.t() | nil, optional(:channel_id) => Nostrum.Struct.Channel.id() }, Nostrum.Struct.Guild.AuditLogEntry.reason() ) :: Nostrum.Api.error() | {:ok, Nostrum.Struct.Webhook.t()}
Modifies a webhook with a token.
This method is exactly like modify_webhook/1
but does not require
authentication.
Parameters
webhook_id
- Id of the webhook to modify.webhook_token
- Token of the webhook to get.args
- Map with the following optional keys:name
- Name of the webhook.avatar
- Base64 128x128 jpeg image for the default avatar.channel_id
- The new channel this webhook should be moved to.
reason
- An optional reason for the guild audit log.
Reference
See the Discord developer docs.