Nostrum.Api.Interaction (nostrum v0.11.0-dev)
View SourceFunctions for interacting with the Discord API's interaction endpoints.
See: https://discord.com/developers/docs/interactions/overview
Summary
Functions
Create a followup message for an interaction.
Same as create_response/3
, but directly takes the
Nostrum.Struct.Interaction.t/0
received from the gateway.
Create a response to an interaction received from the gateway.
Delete a followup message for an interaction.
Same as delete_response/3
, but directly takes the
Nostrum.Struct.Interaction.t/0
received from the gateway.
Deletes the original interaction response.
Same as edit_response/3
, but directly takes the
Nostrum.Struct.Interaction.t/0
received from the gateway.
Edits the original interaction response.
Retrieves the original message of an interaction.
Retrieves the original message of an interaction.
Functions
@spec create_followup_message( Nostrum.Struct.User.id(), Nostrum.Struct.Interaction.token(), map() ) :: {:ok, Nostrum.Struct.Message.t()} | Nostrum.Api.error()
Create a followup message for an interaction.
Delegates to execute_webhook/3
, see the function for more details.
@spec create_response(Nostrum.Struct.Interaction.t(), map()) :: :ok | Nostrum.Api.error()
Same as create_response/3
, but directly takes the
Nostrum.Struct.Interaction.t/0
received from the gateway.
@spec create_response( Nostrum.Struct.Interaction.id(), Nostrum.Struct.Interaction.token(), map() ) :: :ok | Nostrum.Api.error()
Create a response to an interaction received from the gateway.
Parameters
id
: The interaction ID to which the response should be created.token
: The interaction token.response
: AnInteractionResponse
object. See the linked documentation.
Attachments
To include attachments in the response, you can include a :files
field in the response.
This field expects a list of attachments which can be in either of the following formats:
- A path to the file to upload.
- A map with the following fields:
:body
The file contents.:name
The filename of the file.
Example
response = %{
type: 4,
data: %{
content: "I copy and pasted this code."
}
}
Nostrum.Api.Interaction.create_response(interaction, response)
As an alternative to passing the interaction ID and token, the
original Nostrum.Struct.Interaction.t/0
can also be passed
directly. See create_response/2
.
@spec delete_followup_message( Nostrum.Struct.User.id(), Nostrum.Struct.Interaction.token(), Nostrum.Struct.Message.id() ) :: :ok | Nostrum.Api.error()
Delete a followup message for an interaction.
Parameters
application_id
: Application ID for which to create the command. If not given, this will be fetched fromMe
.token
: Interaction token.message_id
: Followup message ID.
@spec delete_response(Nostrum.Struct.Interaction.t()) :: :ok | Nostrum.Api.error()
Same as delete_response/3
, but directly takes the
Nostrum.Struct.Interaction.t/0
received from the gateway.
@spec delete_response(Nostrum.Struct.User.id(), Nostrum.Struct.Interaction.token()) :: :ok | Nostrum.Api.error()
Deletes the original interaction response.
@spec edit_response(Nostrum.Struct.Interaction.t(), map()) :: {:ok, Nostrum.Struct.Message.t()} | Nostrum.Api.error()
Same as edit_response/3
, but directly takes the
Nostrum.Struct.Interaction.t/0
received from the gateway.
@spec edit_response( Nostrum.Struct.User.id(), Nostrum.Struct.Interaction.token(), map() ) :: {:ok, Nostrum.Struct.Message.t()} | Nostrum.Api.error()
Edits the original interaction response.
Functions the same as edit_webhook_message/3
@spec original_response(Nostrum.Struct.Interaction.t()) :: Nostrum.Api.error() | {:ok, Nostrum.Struct.Message.t()}
@spec original_response(Nostrum.Struct.Interaction.t()) :: Nostrum.Api.error() | {:ok, Nostrum.Struct.Message.t()}
Retrieves the original message of an interaction.
Retrieves the original message of an interaction.