Interaction¶
- class InteractionCallbackType¶
This is located in discord.enums but i place it here.
InteractionCallbackType to react to an
Interaction
NAME
VALUE
DESCRIPTION
USAGE
EXAMPLE
- pong¶
1
ACK a
Ping
ACK a Ping to Discord
~
- msg_with_source¶
4
respond to an interaction with a message
Click for example
- deferred_msg_with_source¶
5
ACK an interaction and edit a response later, the user sees a loading state
Possible
response_type
for deferClick for example
- deferred_update_msg¶
6
for components, ACK an interaction and edit the original message later; the user does not see a loading state
Possible
response_type
for deferClick for example
- update_msg¶
7
for components, edit the message the component was attached to
Click for example
- class Interaction¶
Warning
Do not initiate this Class manually
Represents an interaction created in discord like click an
Button
or select an option ofSelectMenu
Note
For general information’s about Interactions visit the Discord-API-Documentation of the discord-api.
- author¶
A
Member
that invoked the interaction. Ifchannel
is a private channel or the user has left the guild, then it is aUser
instead.
- message¶
The message the component was attached to. This will be
EphemeralMessage
if thecomponent_type
is notNone
or the message the component is attached to isephemeral
.Note
In this version, this parameter should always be an object of type
discord.Message
(orEphemeralMessage
if the message is ephemeral) because it only gets initiated when the interaction_type is higher than 2.
- channel¶
The Channel the interaction was created in this is aiter an object of
discord.TextChannel
if it’s inside a guild else it’s an object of typediscord.DMChannel
.
- guild¶
The guild associated with the interaction; aiter an object of type
discord.Guild
, except the interaction was inside an dm-channel then this would be equal toNone
- component¶
The component that invoked this interaction: Aiter an object of type
Button
orSelectMenu
if the message is not ephemeral else typeButtonClick
orSelectionSelect
Note
If this is passed in an
[on_][raw_]button_click
or[on_][raw_]selection_select
Event there would be a second parameter that includes this attribute.
- created_at¶
Returns the Interaction’s creation time in UTC.
- defer(response_type: Literal[5, 6] = InteractionCallbackType.deferred_update_msg, hidden: bool = False)¶
-
‘Defers’ the response.
If
response_type
isInteractionCallbackType.deferred_msg_with_source
it shows a loading state to the user.- Parameters
response_type – Optional[typing.Literal[5, 6]] The type to response with, aiter
InteractionCallbackType.deferred_msg_with_source
orInteractionCallbackType.deferred_update_msg
(e.g. 5 or 6)hidden –
Optional[bool] Whether to defer ephemerally(only the
author
of the interaction can see the message)Note
Important
If you doesn’t respond with an message using
respond()
or edit the original message usingedit()
within less than 3 seconds, discord will indicates that the interaction failed and the interaction-token will be invalidated. To provide this us this methodNote
A Token will be Valid for 15 Minutes so you could edit the original
message
withedit()
,respond()
or doing anything other with this interaction for 15 minutes. after that time you have to edit the original message with the Methodeedit
of themessage
and sending new messages with thesend
Methode ofchannel
(you could not do this hidden as it isn’t an interaction-response anymore)
- edit(**fields)¶
-
Edit the
Message
the component is attached to, if the interaction is not deferred it will defer automatic.Note
If you have not yet deferred or deferred with type
InteractionCallbackType.deferred_update_msg
, edit the message to which the component is attached, otherwise edit the callback message.- Parameters
**fields – The fields of the original message to replace. You could pass the same Parameters as using
discord.Message.edit()
- respond(**kwargs)¶
-
You could pass the same Parameters as using
discord.Messageable.send()
but there are one more optional: Responds to an interaction by sending a message that can be made visible only to the person who invoked the interaction by setting thehidden
toTrue
.- Parameters
hidden –
Optional[
bool
] If set toTrue
, the message will be only visible(e.g. ephemeral) for theauthor
of the Interaction and will disappears if theauthor
click ondelete this message
, the message go out of his view or he reloads the client.Note
If you send an
hidden
(ephemeral)-respond, discord don’t returns any data like an message you could edit, but you could receive Interactions when the Author interact with an component in the message.- Returns
Union[
discord.Message
,EphemeralMessage
]
- class ButtonClick¶
The object that contains a
Interaction.component
if it is of type 2 and the message is ephemeral.
- class SelectionSelect¶
The object containing a
Interaction.component
contains, if it is of type 3 and the message is ephemeral.- custom_id¶
Union[
str
,int
]The
custom_id
of theSelectMenu
. If thecustom_id
is a number it is returned as an integer, otherwise a string.
- values¶
List[Union[
str
,int
]] A list of the options that have been selected. If thevalue
is a number it is returned as an integer, otherwise a string
- class EphemeralMessage¶
Since Discord doesn’t return anything when we send a ephemeral message, this class has no attributes and you can’t do anything with it.