Skip to content

Interaction Events

Note

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


InteractionEvent dataclass

Bases: Event, InteractionModel

Represents the interaction response.

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

Interaction response data.

type: int instance-attribute

Type of interaction. See InteractionTypes.

id: int instance-attribute

ID of interaction.

token: str instance-attribute

token of interaction.

channel_id: int instance-attribute

ID of the channel where the interaction was sent.

application_id: int instance-attribute

ID of the application that owns the interaction.

app_permissions: int instance-attribute

Bitwise set of permissions pertaining to the location of the interaction. [INT_LIMIT]

member: GuildMemberModel instance-attribute

Guild member invoking the interaction.

locale: str instance-attribute

Invoking user's locale.

guild_locale: str instance-attribute

Locale of the guild the interaction was invoked (if invoked in a guild).

guild_id: Optional[int] instance-attribute

ID of guild the interaction was invoked (if invoked in a guild).

guild: Optional[GuildModel] instance-attribute

Partial guild object of the guild the interaction was invoked (if invoked in a guild).

channel: Optional[ChannelModel] instance-attribute

Partial channel object the interaction was invoked.

name: str instance-attribute

Dispatch name of event.

raw: dict instance-attribute

Event's raw JSON payload. NOT A DATACLASS.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

bot_can

Checks app_permissions to see if permission bit is toggled.

Parameters:

  • permission_bit (int) –

    permission bit. See Permissions.

Returns:

  • bool

    whether the bot has this permission

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.

type: int instance-attribute

Type of command (e.g., message, user, slash).

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_focused_value

get_option

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

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

ApplicationCommandOptionData dataclass

Bases: DataModel

Represents the response options from a slash command.

name: str instance-attribute

Name of the command option.

type: int instance-attribute

Type of command option. See CommandOptionTypes.

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

Input value for option.

focused: bool instance-attribute

Whether this option is the currently focused option for autocomplete.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

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.

component_type: int instance-attribute

Type of component.

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

Select values (if any).

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


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)

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

ModalComponent dataclass

Bases: DataModel

Represents the modal component response from a modal.

type: int instance-attribute

Type of component.

component: ModalComponentData instance-attribute

Data associated with the component.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

ModalComponentData dataclass

Bases: DataModel

Represents the modal field response from a modal.

type: int instance-attribute

Type of component.

value: Optional[str] instance-attribute

Text input value (Text Input component only).

custom_id: str instance-attribute

Unique ID associated with the component.

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

String select values (String Select component only).

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss