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
¶
Message Component Data¶
MessageComponentData
dataclass
¶
Modal Component Data¶
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)