Skip to content

Interaction Events

Note

The following classes come from the discord.events.interaction_events module.


InteractionEvent dataclass

Bases: DataModel

Represents the interaction response.

interaction: Interaction instance-attribute

Interaction resource object. See Interaction.

data: Optional[ApplicationCommandData | MessageComponentData | ModalData] = None class-attribute instance-attribute

Interaction response data.

Application Command


ApplicationCommandData dataclass

Bases: DataModel

Represents the response from a command.

id: int instance-attribute

ID of the command.

name: str instance-attribute

Name of the command.

guild_id: Optional[int] instance-attribute

ID of guild from which the command was invoked.

target_id: Optional[int] instance-attribute

ID of the user or message from which the command was invoked (message/user commands only).

options: Optional[list[ApplicationCommandOptionData]] = field(default_factory=list) class-attribute instance-attribute

Options of the command (slash command only).

get_command_option_value

Get the input for a command option by name.

Parameters:

  • option_name (str) –

    option to fetch input from

Raises:

  • ValueError

    invalid option name

Returns:

  • str | int | float | bool

    input data of specified option

ApplicationCommandOptionData dataclass

Bases: DataModel

Represents the response options from a slash command.

name: str instance-attribute

Name of the command option.

value: str | int | float | bool instance-attribute

Input value for option.

Message Component Data


MessageComponentData dataclass

Bases: DataModel

Represents the select response from a select component.

custom_id: str instance-attribute

Unique ID associated with the component.

values: Optional[list[str]] = field(default_factory=list) class-attribute instance-attribute

Select values (if any).


ModalData dataclass

Bases: DataModel

Represents the modal response from a modal.

custom_id: str instance-attribute

Unique ID associated with the modal.

components: list[ModalComponent] = field(default_factory=list) class-attribute instance-attribute

Components on the modal.

get_modal_data

Fetch a modal field's data by its custom ID

Parameters:

  • custom_id (str) –

    custom ID of field to fetch

Raises:

  • ValueError

    invalid custom ID

Returns:

  • str | list[str]

    component values (if string select) or value (if text input)

ModalComponent dataclass

Bases: DataModel

Represents the modal component response from a modal.

component: ModalComponentData instance-attribute

Data associated with the component.

ModalComponentData dataclass

Bases: DataModel

Represents the modal field response from a modal.

value: Optional[str] instance-attribute

Text input value (Text Input component only).

values: Optional[list[str]] instance-attribute

String select values (String Select component only).

custom_id: str instance-attribute

Unique ID associated with the component.