View Source Nostrum.Api.Interaction (Nostrum v0.10.4)
Functions 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
create_followup_message(application_id \\ Me.get().id, token, webhook_payload)
View Source (since 0.10.1)@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: AnInteractionResponseobject. 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:
:bodyThe file contents.:nameThe 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.
delete_followup_message(application_id \\ Me.get().id, token, message_id)
View Source (since 0.10.1)@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.