Nostrum.Api.Interaction (nostrum v0.11.0-dev)

View Source

Functions for interacting with the Discord API's interaction endpoints.

See: https://discord.com/developers/docs/interactions/overview

Summary

Functions

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.

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)

(since 0.10.1)

Create a followup message for an interaction.

Delegates to execute_webhook/3, see the function for more details.

create_response(interaction, response)

(since 0.10.1)
@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.

create_response(id, token, response)

(since 0.10.1)

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: An InteractionResponse 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.

delete_followup_message(application_id \\ Me.get().id, token, message_id)

(since 0.10.1)

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 from Me.
  • token: Interaction token.
  • message_id: Followup message ID.

delete_response(interaction)

(since 1.x.x)
@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.

delete_response(id \\ Me.get().id, token)

(since 1.x.x)

Deletes the original interaction response.

edit_response(interaction, response)

(since 1.x.x)

Same as edit_response/3, but directly takes the Nostrum.Struct.Interaction.t/0 received from the gateway.

edit_response(id \\ Me.get().id, token, response)

(since 1.x.x)

Edits the original interaction response.

Functions the same as edit_webhook_message/3

original_response(interaction)

(since 1.x.x)
@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.

original_response(id \\ Me.get().id, token)

(since 1.x.x)

Retrieves the original message of an interaction.