grom / interaction v5.1.3

grom/interaction

Types and functions for working with Discord interactions — slash commands, component callbacks, modals, and more.

Types

type pub type Interaction

Represents a Discord interaction. This is the base type sent whenever a user triggers an interaction.

type pub type InteractionData

The data payload of an interaction. The content varies based on the interaction type.

type pub type ApplicationCommandInteractionDataOption

An individual option passed to a slash command. Contains the name, type, and value of the option as provided by the user.

type pub type MessageComponentInteractionData

Data from a message component interaction, such as a button click or select menu choice.

Functions

fn pub fn reply(interaction: Interaction, message: Message) -> Result(Nil, RestError)

Send a reply to an interaction. Must be called within 3 seconds, otherwise use defer_reply.

fn pub fn defer_reply(interaction: Interaction, ephemeral: Bool) -> Result(Nil, RestError)

Acknowledge an interaction with a deferred response, showing a loading state. Follow up with edit_original_response.

fn pub fn edit_original_response(interaction: Interaction, message: Message) -> Result(Nil, RestError)

Edit the original response to an interaction. Used after a deferred reply to send the actual content.

fn pub fn create_followup_message_with_options(interaction: Interaction, content: Option(String), embeds: Option(List(Embed)), ephemeral: Bool) -> Result(Message, RestError)

Create a followup message to an interaction with fine-grained control over content, embeds, and visibility. This is the long function definition that motivated the improved sidebar — it should never be word-wrapped mid-identifier.

fn pub fn respond_to_autocomplete_interaction(interaction: Interaction, choices: List(ApplicationCommandOptionChoice)) -> Result(Nil, RestError)

Respond to an autocomplete interaction with a list of choices to show to the user.

fn pub fn get_original_interaction_response(application_id: Snowflake, interaction_token: String) -> Result(Message, RestError)

Retrieve the original response message for an interaction using the application ID and token.