InteractionEvent
Represents a processed INTERACTION_CREATE
dispatch event.
Attributes
int
The interaction's application's identifier.
The permissions granted to the application in the guild.
The channel from where the interaction was called.
The applicable entitlements for the event's context. These can both target guild and user as well.
None
, Guild
The guild from where the interaction was called from.
int
The interaction's id.
Contain additional details of the interaction.
None
, Message
The message from where the interaction was received. Applicable for message components.
str
Interaction's token used when responding on it.
The interaction's type.
The user who called the interaction.
The selected language of the invoking user.
The user's permissions in the respective channel.
None
, Task
Task set if interaction event is acknowledged asynchronously.
int
The response order state of InteractionEvent
Respective name | Shift | Description |
---|---|---|
RESPONSE_FLAG_DEFERRING | 0 | The vent is being acknowledged. |
RESPONSE_FLAG_DEFERRED | 1 | The event was acknowledged and response will be sent later. Shows loading screen for the user. |
RESPONSE_FLAG_RESPONDING | 2 | Responding to the interaction. |
RESPONSE_FLAG_RESPONDED | 3 | Response was sent on the interaction. |
RESPONSE_FLAG_EPHEMERAL | 4 | Whether 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
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
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.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
application_id |
| The interaction's application's identifier. | ||
application_permissions |
| The permissions granted to the application in the guild. | ||
channel_id |
| The channel's identifier from where the interaction was called.
| ||
channel | The channel from where the interaction was called. | |||
entitlements |
| The applicable entitlements for the event's context. | ||
guild |
| The guild from where the interaction was called from. | ||
interaction | Contain additional details of the interaction. | |||
message |
| The message from where the interaction was received. | ||
token |
| Interaction's token used when responding on it. | ||
type |
| The interaction's type. | ||
user | The user who called the interaction. | |||
user_locale |
| The selected language of the invoking user. | ||
user_permissions |
| 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.
()
copyCopies the interaction event. The returned interaction event is partial lacking internal fields.
Returns
new : instance<type<self>>
(...)
copy_withCopies the interaction event modifying it's defined fields. The returned interaction event is partial lacking internal fields.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
application_id |
| The interaction's application's identifier. | ||
application_permissions |
| The permissions granted to the application in the guild. | ||
channel | The channel from where the interaction was called. | |||
channel_id |
| The channel's identifier from where the interaction was called. | ||
entitlements |
| The applicable entitlements for the event's context. | ||
guild |
| The guild from where the interaction was called from. | ||
interaction | Contain additional details of the interaction. | |||
message |
| The message from where the interaction was received. | ||
token |
| Interaction's token used when responding on it. | ||
type |
| The interaction's type. | ||
user | The user who called the interaction. | |||
user_locale |
| The selected language of the invoking user. | ||
user_permissions |
| 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.
(data)
from_dataCreates a new InteractionEvent
with the given parameters.
Parameter | Type | Description |
---|---|---|
data |
|
|
Returns
self : instance<cls>
()
get_custom_id_value_relationReturns a dictionary with custom_id
to value
relation.
Returns
custom_id_value_relation : dict
of (str
, str
) items
(matcher)
get_match_and_valueGets a custom_id
's value matching the given matcher
.
Parameter | Type | Description | ||||
---|---|---|---|---|---|---|
matcher |
| Matcher to call on a Should accept the following parameters:
Should return non- |
Returns
match : None
, object
The returned value by the matcher
value : None
, str
The matched custom_id
's value.
()
get_non_focused_valuesGets the non focused values of the interaction.
Returns
non_focused_options : dict
of (str
, (None
, str
)) items
(custom_id_to_match)
get_value_forReturns the value for the given custom_id
.
Parameter | Type | Description |
---|---|---|
custom_id_to_match |
| A respective components |
Returns
value : None
, str
The value if any.
(...)
get_value_ofGets the value for the option by the given name.
Parameter | Type | Optional | Description |
---|---|---|---|
*option_names |
| The option(s)'s name. |
Returns
value : None
, str
The value, the user has been typed.
(entitlement)
has_entitlementReturns whether the interaction event hast he given entitlement.
Parameter | Type | Description |
---|---|---|
entitlement | The entitlement to look for. |
Returns
has_entitlement : bool
(sku)
has_skuReturns whether any of the interaction event's entitlements grants access to the given stock keeping unit.
Parameter | Type | Description |
---|---|---|
sku | Stock keeping unit to look for. |
Returns
has_sku : bool
()
is_acknowledgedReturns whether the event is acknowledged.
Returns
is_acknowledged : bool
()
is_acknowledgingReturns whether the event is being acknowledged.
Returns
is_acknowledging : bool
()
is_deferredReturns whether the event is deferred.
Returns
is_deferred : bool
()
is_expiredReturns whether the event is already expired.
Returns
is_expired : bool
()
is_respondedReturns whether was responded.
Returns
is_responded : bool
()
is_respondingReturns whether the event it being responded.
Returns
is_responding : bool
()
is_unansweredReturns whether the event was not acknowledged and not acknowledging either.
Returns
is_unanswered : bool
()
iter_componentsIterates over the sub-components of a form-submit interaction.
This method is an iterable generator.
Yields
component : InteractionComponent
()
iter_custom_ids_and_valuesIterates 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_entitiesIterates over the entities that were selected by the user of a select component interaction.
This method is an iterable generator.
Yields
()
iter_entitlementsIterates over the entitlements of the interaction event.
This method is an iterable generator.
Yields
entitlement : Entitlement
(matcher)
iter_matches_and_valuesGets a custom_id
's value matching the given matcher
.
This method is an iterable generator.
Parameter | Type | Description | ||||
---|---|---|---|---|---|---|
matcher |
| Matcher to call on a Should accept the following parameters:
Should return non- |
Yields
match : None
, object
The returned value by the matcher
value : None
, str
The matched custom_id
's value.
()
iter_optionsIterates over the options of the interaction application command (autocomplete) interaction.
This method is an iterable generator.
Yields
option : InteractionOption
()
iter_valuesIterates over the values selected by the user.
This method is an iterable generator.
Yields
value : str
(interaction_id, ...)
precreateCreates 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.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
interaction_id |
| The interaction's identifier. | ||
channel_id |
| The channel's identifier from where the interaction was called.
| ||
**keyword_parameters | Keyword parameters | Additional keyword parameters defining which attribute and how should be set. | ||
application |
| Alternative for | ||
application_id |
| The interaction's application's identifier. | ||
application_permissions |
| The permissions granted to the application in the guild. | ||
channel | The channel from where the interaction was called. | |||
entitlements |
| The applicable entitlements for the event's context. | ||
guild |
| The guild from where the interaction was called from. | ||
interaction | Contain additional details of the interaction. | |||
message |
| The message from where the interaction was received. | ||
token |
| Interaction's token used when responding on it. | ||
type |
| The interaction's type. | ||
user | The user who called the interaction. | |||
user_locale |
| The selected language of the invoking user. | ||
user_permissions |
| 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.
(attachment_id)
resolve_attachmentTries to resolve an attachment by the given identifier.
Parameter | Type | Description |
---|---|---|
attachment_id |
| Attachment identifier. |
Returns
attachment : None
, Attachment
(channel_id)
resolve_channelTries to resolve an channel by the given identifier.
Parameter | Type | Description |
---|---|---|
channel_id |
| Channel identifier. |
Returns
channel : None
, Channel
(entity_id)
resolve_entityTries to resolve any entity with the given identifier.
Parameter | Type | Description |
---|---|---|
entity_id |
| Entity identifier. |
Returns
entity : None
Attachment
, Channel
, ClientUserBase
, Role
, Message
(mentionable_id)
resolve_mentionableTries to resolve a mentionable entity (user / role).
Parameter | Type | Description |
---|---|---|
mentionable_id |
| Entity identifier. |
Returns
entity : None
, Role
, ClientUserBase
(message_id)
resolve_messageTries to resolve an message by the given identifier.
Parameter | Type | Description |
---|---|---|
message_id |
| Message identifier. |
Returns
message : None
, Message
(role_id)
resolve_roleTries to resolve an role by the given identifier.
Parameter | Type | Description |
---|---|---|
role_id |
| Role identifier. |
Returns
role : None
, Role
(user_id)
resolve_userTries to resolve an user by the given identifier.
Parameter | Type | Description |
---|---|---|
user_id |
| User identifier. |
Returns
user : None
, ClientUserBase
(...)
to_dataReturns the interaction event's json serializable representation.
Parameter | Type | Optional | Keyword only | Default | Description |
---|---|---|---|---|---|
defaults |
|
| Whether fields with their default values should be included as well. |
Returns
data : dict
of (str
, object
) items
(...)
wait_for_response_messageWaits for response message. Applicable for application command interactions.
This method is a coroutine.
Parameter | Type | Optional | Keyword only | Default | Description |
---|---|---|---|---|---|
timeout |
|
| The maximal time to wait for message before |
Returns
message : Message
The received message.
Raises
TimeoutError
Message was not received before timeout.
()
_add_response_waiterAdds the interaction event to response waiters.
Called when the interaction is application command one, to resolve it's .message
attribute when created.
(interaction_id)
_create_emptyCreates a new partial interaction event with it's attributes set as their default value.
Parameter | Type | Description |
---|---|---|
interaction_id |
| The interaction event's identifier. |
Returns
self : instance<cls>
()
_wait_for_async_task_completionWaits 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.