InteractionEvent

Represents a processed INTERACTION_CREATE dispatch event.

Attributes

application_id : int

The interaction's application's identifier.

application_permissions : Permission

The permissions granted to the application in the guild.

channel : Channel

The channel from where the interaction was called.

entitlements : None, tuple of Entitlement

The applicable entitlements for the event's context. These can both target guild and user as well.

guild : None, Guild

The guild from where the interaction was called from.

id : int

The interaction's id.

Contain additional details of the interaction.

message : None, Message

The message from where the interaction was received. Applicable for message components.

token : str

Interaction's token used when responding on it.

The interaction's type.

The user who called the interaction.

user_locale : Locale

The selected language of the invoking user.

user_permissions : Permission

The user's permissions in the respective channel.

_async_task : None, Task

Task set if interaction event is acknowledged asynchronously.

_response_flags : int

The response order state of InteractionEvent

Respective nameShiftDescription
RESPONSE_FLAG_DEFERRING0The vent is being acknowledged.
RESPONSE_FLAG_DEFERRED1The event was acknowledged and response will be sent later. Shows loading screen for the user.
RESPONSE_FLAG_RESPONDING2Responding to the interaction.
RESPONSE_FLAG_RESPONDED3Response was sent on the interaction.
RESPONSE_FLAG_EPHEMERAL4Whether the main response is an ephemeral, showing for the invoking user only.

Can be used by extensions and is used by the the Client-s to ensure correct flow order.

Notes

The interaction token can be used for 15 minutes, tho if it is not used within the first 3 seconds, it is invalidated immediately.

Interaction event instances are weakreferable.

Properties

application_command_id

application_command_name

channel_id

Returns the interaction's channel's identifier.

Returns

channel_id : int

client

Returns the interaction's client.

Returns

client : Client

Raises

RuntimeError

Client could not be identified.

component_type

components

created_at

When the entity was created.

Returns

created_at : datetime

custom_id

entities

Returns the entities that were selected by the user of a select component interaction.

Returns

entities : list of (Channel, ClientUserbase, Role)

focused_option

Returns the focused option of the application command autocomplete interaction.

Returns

option : None, InteractionOption

guild_id

Returns the interaction's guild's identifier.

Returns

guild_id : int

guild_locale

Returns the interaction's guild's locale.

Returns

guild_locale : Locale

locale

Deprecated and will be removed in 2024 February. Please use .user_locale instead.

options

resolved

target

Returns the application command's target. Applicable if the interaction was invoked by a context command.

Returns

entity : None Attachment, Channel, ClientUserBase, Role, Message

target_id

user_id

Returns the interaction's user's identifier.

Returns

user_id : int

value

Returns the selected value of an component interaction.

Returns

value : None, str

values

voice_client

Returns the voice client of the interaction's client in it's guild.

Returns

voice_client : None, VoiceClient

Methods

__new__(...)

Creates a partial interaction event.

ParameterTypeOptionalKeyword onlyDescription
application_id

int, str

The interaction's application's identifier.

application_permissions

Permission, int

The permissions granted to the application in the guild.

channel_id

int, str, Channel

The channel's identifier from where the interaction was called.

Deprecated and will be removed in 2023 November.

channel

Channel

The channel from where the interaction was called.

entitlements

None, iterable of Entitlement

The applicable entitlements for the event's context.

guild

None, Guild

The guild from where the interaction was called from.

interaction

InteractionMetadataBase

Contain additional details of the interaction.

message

None, Message

The message from where the interaction was received.

token

str

Interaction's token used when responding on it.

type

InteractionType, int

The interaction's type.

user

ClientUserBase

The user who called the interaction.

user_locale

Locale, str

The selected language of the invoking user.

user_permissions

Permission, int

The user's permissions in the respective channel.

Returns

self : instance<cls>

Raises

TypeError

  • If a parameter's type is incorrect.

ValueError

  • If a parameter's type is incorrect.

copy()

Copies the interaction event. The returned interaction event is partial lacking internal fields.

Returns

new : instance<type<self>>

copy_with(...)

Copies the interaction event modifying it's defined fields. The returned interaction event is partial lacking internal fields.

ParameterTypeOptionalKeyword onlyDescription
application_id

int, str

The interaction's application's identifier.

application_permissions

Permission, int

The permissions granted to the application in the guild.

channel

Channel

The channel from where the interaction was called.

channel_id

int, str, Channel

The channel's identifier from where the interaction was called.

entitlements

None, iterable of Entitlement

The applicable entitlements for the event's context.

guild

None, Guild

The guild from where the interaction was called from.

interaction

InteractionMetadataBase

Contain additional details of the interaction.

message

None, Message

The message from where the interaction was received.

token

str

Interaction's token used when responding on it.

type

InteractionType, int

The interaction's type.

user

ClientUserBase

The user who called the interaction.

user_locale

Locale, str

The selected language of the invoking user.

user_permissions

Permission, int

The user's permissions in the respective channel.

Returns

new : instance<type<self>>

Raises

TypeError

  • If a parameter's type is incorrect.

ValueError

  • If a parameter's type is incorrect.

from_data(data)

Creates a new InteractionEvent with the given parameters.

ParameterTypeDescription
data

dict of (str, object) items

INTERACTION_CREATE dispatch event data.

Returns

self : instance<cls>

get_custom_id_value_relation()

Returns a dictionary with custom_id to value relation.

Returns

custom_id_value_relation : dict of (str, str) items

get_match_and_value(matcher)

Gets a custom_id 's value matching the given matcher.

ParameterTypeDescription
matcher

callable

Matcher to call on a custom_id

Should accept the following parameters:

NameType
custom_idstr

Should return non- None on success.

Returns

match : None, object

The returned value by the matcher

value : None, str

The matched custom_id 's value.

get_non_focused_values()

Gets the non focused values of the interaction.

Returns

non_focused_options : dict of (str, (None, str)) items

get_value_for(custom_id_to_match)

Returns the value for the given custom_id.

ParameterTypeDescription
custom_id_to_match

str

A respective components custom_id to match.

Returns

value : None, str

The value if any.

get_value_of(...)

Gets the value for the option by the given name.

ParameterTypeOptionalDescription
*option_names

str

The option(s)'s name.

Returns

value : None, str

The value, the user has been typed.

has_entitlement(entitlement)

Returns whether the interaction event hast he given entitlement.

ParameterTypeDescription
entitlement

Entitlement

The entitlement to look for.

Returns

has_entitlement : bool

has_sku(sku)

Returns whether any of the interaction event's entitlements grants access to the given stock keeping unit.

ParameterTypeDescription
sku

SKU

Stock keeping unit to look for.

Returns

has_sku : bool

is_acknowledged()

Returns whether the event is acknowledged.

Returns

is_acknowledged : bool

is_acknowledging()

Returns whether the event is being acknowledged.

Returns

is_acknowledging : bool

is_deferred()

Returns whether the event is deferred.

Returns

is_deferred : bool

is_expired()

Returns whether the event is already expired.

Returns

is_expired : bool

is_responded()

Returns whether was responded.

Returns

is_responded : bool

is_responding()

Returns whether the event it being responded.

Returns

is_responding : bool

is_unanswered()

Returns whether the event was not acknowledged and not acknowledging either.

Returns

is_unanswered : bool

iter_components()

Iterates over the sub-components of a form-submit interaction.

This method is an iterable generator.

Yields

component : InteractionComponent

iter_custom_ids_and_values()

Iterates over all the custom_id-s and values of the form submit interaction.

This method is an iterable generator.

Yields

custom_id : str

The custom_id of a represented component.

value : str

The value passed by the user.

iter_entities()

Iterates over the entities that were selected by the user of a select component interaction.

This method is an iterable generator.

Yields

entity : Channel, ClientUserbase, Role

iter_entitlements()

Iterates over the entitlements of the interaction event.

This method is an iterable generator.

Yields

entitlement : Entitlement

iter_matches_and_values(matcher)

Gets a custom_id 's value matching the given matcher.

This method is an iterable generator.

ParameterTypeDescription
matcher

callable

Matcher to call on a custom_id

Should accept the following parameters:

NameType
custom_idstr

Should return non- None on success.

Yields

match : None, object

The returned value by the matcher

value : None, str

The matched custom_id 's value.

iter_options()

Iterates over the options of the interaction application command (autocomplete) interaction.

This method is an iterable generator.

Yields

option : InteractionOption

iter_values()

Iterates over the values selected by the user.

This method is an iterable generator.

Yields

value : str

precreate(interaction_id, ...)

Creates an interaction event. Not like .__new__, .precreate allows setting .id as well.

Since interaction events are not cached, there os no major advantage of using this method.

ParameterTypeOptionalKeyword onlyDescription
interaction_id

int

The interaction's identifier.

channel_id

int, str, Channel

The channel's identifier from where the interaction was called.

Deprecated and will be removed in 2023 November.

**keyword_parameters

Keyword parameters

Additional keyword parameters defining which attribute and how should be set.

application

int, str, Application

Alternative for application_id.

application_id

int, str, Application

The interaction's application's identifier.

application_permissions

Permission, int

The permissions granted to the application in the guild.

channel

Channel

The channel from where the interaction was called.

entitlements

None, iterable of Entitlement

The applicable entitlements for the event's context.

guild

None, Guild

The guild from where the interaction was called from.

interaction

InteractionMetadataBase

Contain additional details of the interaction.

message

None, Message

The message from where the interaction was received.

token

str

Interaction's token used when responding on it.

type

InteractionType, int

The interaction's type.

user

ClientUserBase

The user who called the interaction.

user_locale

Locale, str

The selected language of the invoking user.

user_permissions

Permission, int

The user's permissions in the respective channel.

Returns

self : instance<cls>

Raises

TypeError

  • If a parameter's type is incorrect.

ValueError

  • If a parameter's type is incorrect.

resolve_attachment(attachment_id)

Tries to resolve an attachment by the given identifier.

ParameterTypeDescription
attachment_id

int

Attachment identifier.

Returns

attachment : None, Attachment

resolve_channel(channel_id)

Tries to resolve an channel by the given identifier.

ParameterTypeDescription
channel_id

int

Channel identifier.

Returns

channel : None, Channel

resolve_entity(entity_id)

Tries to resolve any entity with the given identifier.

ParameterTypeDescription
entity_id

int

Entity identifier.

Returns

entity : None Attachment, Channel, ClientUserBase, Role, Message

resolve_mentionable(mentionable_id)

Tries to resolve a mentionable entity (user / role).

ParameterTypeDescription
mentionable_id

int

Entity identifier.

Returns

entity : None, Role, ClientUserBase

resolve_message(message_id)

Tries to resolve an message by the given identifier.

ParameterTypeDescription
message_id

int

Message identifier.

Returns

message : None, Message

resolve_role(role_id)

Tries to resolve an role by the given identifier.

ParameterTypeDescription
role_id

int

Role identifier.

Returns

role : None, Role

resolve_user(user_id)

Tries to resolve an user by the given identifier.

ParameterTypeDescription
user_id

int

User identifier.

Returns

user : None, ClientUserBase

to_data(...)

Returns the interaction event's json serializable representation.

ParameterTypeOptionalKeyword onlyDefaultDescription
defaults

bool

False

Whether fields with their default values should be included as well.

Returns

data : dict of (str, object) items

wait_for_response_message(...)

Waits for response message. Applicable for application command interactions.

This method is a coroutine.

ParameterTypeOptionalKeyword onlyDefaultDescription
timeout

None, float

None

The maximal time to wait for message before TimeoutError is raised.

Returns

message : Message

The received message.

Raises

TimeoutError

Message was not received before timeout.

_add_response_waiter()

Adds the interaction event to response waiters.

Called when the interaction is application command one, to resolve it's .message attribute when created.

_create_empty(interaction_id)

Creates a new partial interaction event with it's attributes set as their default value.

ParameterTypeDescription
interaction_id

int

The interaction event's identifier.

Returns

self : instance<cls>

_wait_for_async_task_completion()

Waits for async task's completion.

This method is a coroutine.

__eq__()

Returns whether the two interaction events are equal.

__ge__()

Whether this entity's id is greater or equal than the other's.

__getattr__()

Drops a rich attribute error.

__gt__()

Whether this entity's id is greater than the other's.

__hash__()

Returns the hash value of the interaction event.

__iter__()

Unpacks the event.

This method is a generator.

__le__()

Whether this entity's id is less or equal than the other's.

__len__()

Helper for unpacking if needed.

__lt__()

Whether this entity's id is less than the other's.

__ne__()

Whether this entity's id is not equal as the other's.

__repr__()

Returns the representation of the event.