BaseInteraction
- asyncedit
- defget_followup
- asyncget_original_callback
- asyncrespond
- asyncrespond_with_modal
- class discord.BaseInteraction
Bases:
object
The Base-Class for a discord-interaction like klick a
Button
, select (an) option(s) ofSelectMenu
or using an application-command in discord For more general information’s about Interactions visit the Documentation of the Discord-APIThe following attributes are always available:
- entitlements
For monetized apps entitlements of the user who triggered the interaction and optionally, if any.
This is available for all interaction types.
- Type:
Optional[List[
Entitlement
]]
- data
Some internal needed metadata for the interaction, depending on the type.
- Type:
InteractionData
- author_locale
The locale of the user who triggered the interaction.
- Type:
Optional[
Locale
]
- guild_locale
The locale of the guild where the interaction was triggered.
- Type:
Optional[
Locale
]
- guild_id
The id of the guild where the interaction was triggered, if any.
- Type:
Optional[
int
]
- app_permissions
The permissions of the bot in the channel where the interaction was triggered, if it was in a guild.
This is similar to interaction.channel.permissions_for(interaction.guild.me) but calculated on discord side.
- Type:
Optional[
Permissions
]
- author_permissions
The author’s permissions in the channel where the interaction was triggered, if it was in a guild.
This is similar to interaction.channel.permissions_for(interaction.author), but calculated on discord side.
- Type:
Optional[
Permissions
]
- property callback_message
The initial interaction response message, if any. (
@original
)- Type:
Optional[Union[
Message
,EphemeralMessage
]
- await edit(*, content=MISSING, embed=MISSING, embeds=MISSING, components=MISSING, attachments=MISSING, keep_existing_attachments=False, delete_after=None, allowed_mentions=MISSING, suppress_embeds=False)
This function is a coroutine.
Responds to the interaction by editing the original (
message
) orcallback_message
, depending on thetype
.- Parameters:
content (Optional[
str
]) – The new content to replace the message with. Could beNone
to remove the content.embed (Optional[
Embed
]) – The new embed to replace the original with. Could beNone
to remove all embeds.embeds (Optional[List[
Embed
]]) –A list containing up to 10 embeds to send. If
None
or empty, all embeds will be removed.If passed,
embed
does also count towards the limit of 10 embeds.components (List[Union[
ActionRow
, List[Union[Button
, Select]]]]) – A list of up to fiveActionRow
orlist
, each containing up to fiveButton
or one Select like object.attachments (List[Union[
Attachment
,File
]]) –A list containing previous attachments to keep as well as new files to upload. You can use
keep_existing_attachments
to auto-add the existing attachments to the list. IfNone
or empty, all attachments will be removed.Note
New files will always appear under existing ones.
keep_existing_attachments (
bool
) –Whether to auto-add existing attachments to
attachments
, defaultFalse
.Note
Only needed when
attachments
are passed, otherwise will be ignored.suppress_embeds (
bool
) – Whether to suppress embeds for the message. This removes all the embeds if set toTrue
. If set toFalse
this brings the embeds back if they were suppressed.delete_after (Optional[
float
]) – If provided, the number of seconds to wait in the background before deleting the response we just edited. If the deletion fails, then it is silently ignored.allowed_mentions (Optional[
AllowedMentions
]) – Controls the mentions being processed in this message. If this is passed, then the object is merged withallowed_mentions
. The merging behaviour only overrides attributes that have been explicitly passed to the object, otherwise it uses the attributes set inallowed_mentions
. If no object is passed at all then the defaults given byallowed_mentions
are used instead.
- Raises:
TypeError – The interaction was already responded to with a modal, or it is an application-command that was not responded to.
NotFound: – The interaction is expired.
HTTPException – Editing the message failed.
- Returns:
The edited message.
- Return type:
Union[
Message
,EphemeralMessage
]
- await respond(content=None, *, tts=False, embed=None, embeds=None, components=None, file=None, files=None, delete_after=None, allowed_mentions=None, suppress_embeds=False, suppress_notifications=False, hidden=False)
This function is a coroutine.
Responds to an interaction by sending a message.
- Parameters:
content (
str
) – The content of the message to send.tts (
bool
) – Indicates if the message should be sent using text-to-speech.embed (
Embed
) – The rich embed for the content.embeds (List[
Embed
]) –A list containing up to 10 embeds.
If passed,
embed
also counts towards the limit of 10.components (List[Union[
ActionRow
, List[Union[Button
, Select]]]]) – A list of up to fiveButton
or one Select like object.file (
File
) – The file to upload.files (List[
File
]) – Alist
of files to upload. Must be a maximum of 10.suppress_embeds (
bool
) – Whether to suppress embeds for the message.suppress_notifications (
bool
) – Whether to suppress desktop- & push-notifications for the post starter-message.delete_after (
float
) – If provided, the number of seconds to wait in the background before deleting the response we just sent. If the deletion fails, then it is silently ignored.allowed_mentions (
AllowedMentions
) – Controls the mentions being processed in this message. If this is passed, then the object is merged withallowed_mentions
. The merging behaviour only overrides attributes that have been explicitly passed to the object, otherwise it uses the attributes set inallowed_mentions
. If no object is passed at all then the defaults given byallowed_mentions
are used instead.hidden (Optional[
bool
]) – IfTrue
the message will be only visible for the performer of the interaction (e.g.author
).
- Raises:
TypeError – This interaction was already responded to with a modal.
NotFound – The interaction has expired.
HTTPException – Responding to the interaction failed.
- await respond_with_modal(modal)
This function is a coroutine. Respond to an interaction with a popup modal.
- Parameters:
modal (
Modal
) – The modal to send.- Raises:
AlreadyResponded – This interaction was already responded to.
HTTPException – Responding to the interaction failed.
- await get_original_callback(raw=False)
This function is a coroutine. Fetch the original callback-message of the interaction.
Warning
This is an API-Call and should be used carefully
- Parameters:
raw (Optional[
bool
]) – Whether to return the raw data from the api instead of aMessage
/EphemeralMessage
.- Returns:
The original callback-message of the interaction.
- Return type:
- get_followup(id)
Gets a followup message of this interaction with the given
id
.- Parameters:
id (
int
) – The id of the followup message.- Returns:
The followup or
None
if there is none.- Return type:
Optional[Union[
Message
,EphemeralMessage
]]
- property author
The
Member
that invoked the interaction. Ifchannel
is of typeprivate
or the user has left the guild, then it is aUser
instead.
- property channel
- Union[
TextChannel
,ThreadChannel
,DMChannel
,VoiceChannel
,ForumPost
,PartialMessageable
]: The channel where the interaction was invoked in.
- property guild
The guild the interaction was invoked in, if there is one.
- Type:
Optional[
Guild
]
ApplicationCommandInteraction
- asyncdefer
- asyncedit
- defget_followup
- asyncget_original_callback
- asyncrespond
- asyncrespond_with_modal
- asyncrespond_with_premium_required
- class discord.ApplicationCommandInteraction
Bases:
BaseInteraction
Holds the data of an interaction when a ~discord.SlashCommand,
UserCommand
orMessageCommand
is used and allows responding to it.- messages
A mapping of message id’s to the message objects that were sent using
respond
.- Type:
Dict[
int
, Union[Message
,EphemeralMessage
]]
- author_locale
The locale of the user who triggered the interaction.
- Type:
Optional[
Locale
]
- guild_locale
The locale of the guild where the interaction was triggered.
- Type:
Optional[
Locale
]
- guild_id
The id of the guild where the interaction was triggered, if any.
- Type:
Optional[
int
]
- app_permissions
The permissions of the bot in the channel where the interaction was triggered, if it was in a guild.
- Type:
Optional[
Permissions
]
- property command
Union[
SlashCommand
,UserCommand
,MessageCommand
]: The application-command that was invoked.
- await defer(hidden=False)
Defers the interaction, the user sees a loading state
- Parameters:
hidden (Optional[
bool
]) – Weather only the author of the command should see this- Raises:
AlreadyResponded – The interaction has already been responded to.
UnknownInteraction – The interaction has expired.
- Returns:
The Message containing the loading state
- Return type:
Union[
EphemeralMessage
]
This function is a coroutine. Respond with an upgrade button, only available for apps with monetized apps enabled.
- property author
The
Member
that invoked the interaction. Ifchannel
is of typeprivate
or the user has left the guild, then it is aUser
instead.
- property callback_message
The initial interaction response message, if any. (
@original
)- Type:
Optional[Union[
Message
,EphemeralMessage
]
- property channel
- Union[
TextChannel
,ThreadChannel
,DMChannel
,VoiceChannel
,ForumPost
,PartialMessageable
]: The channel where the interaction was invoked in.
- await edit(*, content=MISSING, embed=MISSING, embeds=MISSING, components=MISSING, attachments=MISSING, keep_existing_attachments=False, delete_after=None, allowed_mentions=MISSING, suppress_embeds=False)
This function is a coroutine.
Responds to the interaction by editing the original (
message
) orcallback_message
, depending on thetype
.- Parameters:
content (Optional[
str
]) – The new content to replace the message with. Could beNone
to remove the content.embed (Optional[
Embed
]) – The new embed to replace the original with. Could beNone
to remove all embeds.embeds (Optional[List[
Embed
]]) –A list containing up to 10 embeds to send. If
None
or empty, all embeds will be removed.If passed,
embed
does also count towards the limit of 10 embeds.components (List[Union[
ActionRow
, List[Union[Button
, Select]]]]) – A list of up to fiveActionRow
orlist
, each containing up to fiveButton
or one Select like object.attachments (List[Union[
Attachment
,File
]]) –A list containing previous attachments to keep as well as new files to upload. You can use
keep_existing_attachments
to auto-add the existing attachments to the list. IfNone
or empty, all attachments will be removed.Note
New files will always appear under existing ones.
keep_existing_attachments (
bool
) –Whether to auto-add existing attachments to
attachments
, defaultFalse
.Note
Only needed when
attachments
are passed, otherwise will be ignored.suppress_embeds (
bool
) – Whether to suppress embeds for the message. This removes all the embeds if set toTrue
. If set toFalse
this brings the embeds back if they were suppressed.delete_after (Optional[
float
]) – If provided, the number of seconds to wait in the background before deleting the response we just edited. If the deletion fails, then it is silently ignored.allowed_mentions (Optional[
AllowedMentions
]) – Controls the mentions being processed in this message. If this is passed, then the object is merged withallowed_mentions
. The merging behaviour only overrides attributes that have been explicitly passed to the object, otherwise it uses the attributes set inallowed_mentions
. If no object is passed at all then the defaults given byallowed_mentions
are used instead.
- Raises:
TypeError – The interaction was already responded to with a modal, or it is an application-command that was not responded to.
NotFound: – The interaction is expired.
HTTPException – Editing the message failed.
- Returns:
The edited message.
- Return type:
Union[
Message
,EphemeralMessage
]
- get_followup(id)
Gets a followup message of this interaction with the given
id
.- Parameters:
id (
int
) – The id of the followup message.- Returns:
The followup or
None
if there is none.- Return type:
Optional[Union[
Message
,EphemeralMessage
]]
- await get_original_callback(raw=False)
This function is a coroutine. Fetch the original callback-message of the interaction.
Warning
This is an API-Call and should be used carefully
- Parameters:
raw (Optional[
bool
]) – Whether to return the raw data from the api instead of aMessage
/EphemeralMessage
.- Returns:
The original callback-message of the interaction.
- Return type:
- property guild
The guild the interaction was invoked in, if there is one.
- Type:
Optional[
Guild
]
- await respond(content=None, *, tts=False, embed=None, embeds=None, components=None, file=None, files=None, delete_after=None, allowed_mentions=None, suppress_embeds=False, suppress_notifications=False, hidden=False)
This function is a coroutine.
Responds to an interaction by sending a message.
- Parameters:
content (
str
) – The content of the message to send.tts (
bool
) – Indicates if the message should be sent using text-to-speech.embed (
Embed
) – The rich embed for the content.embeds (List[
Embed
]) –A list containing up to 10 embeds.
If passed,
embed
also counts towards the limit of 10.components (List[Union[
ActionRow
, List[Union[Button
, Select]]]]) – A list of up to fiveButton
or one Select like object.file (
File
) – The file to upload.files (List[
File
]) – Alist
of files to upload. Must be a maximum of 10.suppress_embeds (
bool
) – Whether to suppress embeds for the message.suppress_notifications (
bool
) – Whether to suppress desktop- & push-notifications for the post starter-message.delete_after (
float
) – If provided, the number of seconds to wait in the background before deleting the response we just sent. If the deletion fails, then it is silently ignored.allowed_mentions (
AllowedMentions
) – Controls the mentions being processed in this message. If this is passed, then the object is merged withallowed_mentions
. The merging behaviour only overrides attributes that have been explicitly passed to the object, otherwise it uses the attributes set inallowed_mentions
. If no object is passed at all then the defaults given byallowed_mentions
are used instead.hidden (Optional[
bool
]) – IfTrue
the message will be only visible for the performer of the interaction (e.g.author
).
- Raises:
TypeError – This interaction was already responded to with a modal.
NotFound – The interaction has expired.
HTTPException – Responding to the interaction failed.
- await respond_with_modal(modal)
This function is a coroutine. Respond to an interaction with a popup modal.
- Parameters:
modal (
Modal
) – The modal to send.- Raises:
AlreadyResponded – This interaction was already responded to.
HTTPException – Responding to the interaction failed.
ComponentInteraction
- asyncdefer
- asyncedit
- defget_followup
- asyncget_original_callback
- asyncrespond
- asyncrespond_with_modal
- asyncrespond_with_premium_required
- class discord.ComponentInteraction
Bases:
BaseInteraction
Holds the data of an interaction with a button or select and allows responding to it.
- messages
A mapping of message id’s to the message objects that were sent using
respond
.- Type:
Dict[
int
, Union[Message
,EphemeralMessage
]]
- author_locale
The locale of the user who triggered the interaction.
- Type:
Optional[
Locale
]
- guild_locale
The locale of the guild where the interaction was triggered.
- Type:
Optional[
Locale
]
- message
The message the component is attached to.
- Type:
Optional[Union[
Message
,EphemeralMessage
]
- cached_message
The cached version of
message
, if any.- Type:
Optional[Union[
Message
,EphemeralMessage
]
- guild_id
The id of the guild where the interaction was triggered, if any.
- Type:
Optional[
int
]
- app_permissions
The permissions of the bot in the channel where the interaction was triggered, if it was in a guild.
- Type:
Optional[
Permissions
]
- match
The RegEx Match result of the custom_id of the component, if an
on_click
oron_select
decorator was used.- Type:
Optional[
Match
]
Whether the
message
has theephemeral()
flag.- Type:
- await defer(type=('deferred_update_msg', 6), hidden=False)
Defers the interaction.
- Parameters:
type (Union[Literal[5, 6]]) – Use
5
to edit the original message later and6
to let the user sees a loading state and edit it later.hidden (Optional[
bool
]) –Weather only the author of the command should see this, default
True
Note
Only for
deferred_msg_with_source
(5
).
- Raises:
AlreadyResponded – The interaction has already been responded to.
UnknownInteraction – The interaction has expired.
- Returns:
The message containing the loading-state if
deferred_msg_with_source
(5
) is used, elseNone
.- Return type:
Optional[Union[
EphemeralMessage
]]
This function is a coroutine. Respond with an upgrade button, only available for apps with monetized apps enabled.
- property author
The
Member
that invoked the interaction. Ifchannel
is of typeprivate
or the user has left the guild, then it is aUser
instead.
- property callback_message
The initial interaction response message, if any. (
@original
)- Type:
Optional[Union[
Message
,EphemeralMessage
]
- property channel
- Union[
TextChannel
,ThreadChannel
,DMChannel
,VoiceChannel
,ForumPost
,PartialMessageable
]: The channel where the interaction was invoked in.
- await edit(*, content=MISSING, embed=MISSING, embeds=MISSING, components=MISSING, attachments=MISSING, keep_existing_attachments=False, delete_after=None, allowed_mentions=MISSING, suppress_embeds=False)
This function is a coroutine.
Responds to the interaction by editing the original (
message
) orcallback_message
, depending on thetype
.- Parameters:
content (Optional[
str
]) – The new content to replace the message with. Could beNone
to remove the content.embed (Optional[
Embed
]) – The new embed to replace the original with. Could beNone
to remove all embeds.embeds (Optional[List[
Embed
]]) –A list containing up to 10 embeds to send. If
None
or empty, all embeds will be removed.If passed,
embed
does also count towards the limit of 10 embeds.components (List[Union[
ActionRow
, List[Union[Button
, Select]]]]) – A list of up to fiveActionRow
orlist
, each containing up to fiveButton
or one Select like object.attachments (List[Union[
Attachment
,File
]]) –A list containing previous attachments to keep as well as new files to upload. You can use
keep_existing_attachments
to auto-add the existing attachments to the list. IfNone
or empty, all attachments will be removed.Note
New files will always appear under existing ones.
keep_existing_attachments (
bool
) –Whether to auto-add existing attachments to
attachments
, defaultFalse
.Note
Only needed when
attachments
are passed, otherwise will be ignored.suppress_embeds (
bool
) – Whether to suppress embeds for the message. This removes all the embeds if set toTrue
. If set toFalse
this brings the embeds back if they were suppressed.delete_after (Optional[
float
]) – If provided, the number of seconds to wait in the background before deleting the response we just edited. If the deletion fails, then it is silently ignored.allowed_mentions (Optional[
AllowedMentions
]) – Controls the mentions being processed in this message. If this is passed, then the object is merged withallowed_mentions
. The merging behaviour only overrides attributes that have been explicitly passed to the object, otherwise it uses the attributes set inallowed_mentions
. If no object is passed at all then the defaults given byallowed_mentions
are used instead.
- Raises:
TypeError – The interaction was already responded to with a modal, or it is an application-command that was not responded to.
NotFound: – The interaction is expired.
HTTPException – Editing the message failed.
- Returns:
The edited message.
- Return type:
Union[
Message
,EphemeralMessage
]
- get_followup(id)
Gets a followup message of this interaction with the given
id
.- Parameters:
id (
int
) – The id of the followup message.- Returns:
The followup or
None
if there is none.- Return type:
Optional[Union[
Message
,EphemeralMessage
]]
- await get_original_callback(raw=False)
This function is a coroutine. Fetch the original callback-message of the interaction.
Warning
This is an API-Call and should be used carefully
- Parameters:
raw (Optional[
bool
]) – Whether to return the raw data from the api instead of aMessage
/EphemeralMessage
.- Returns:
The original callback-message of the interaction.
- Return type:
- property guild
The guild the interaction was invoked in, if there is one.
- Type:
Optional[
Guild
]
- await respond(content=None, *, tts=False, embed=None, embeds=None, components=None, file=None, files=None, delete_after=None, allowed_mentions=None, suppress_embeds=False, suppress_notifications=False, hidden=False)
This function is a coroutine.
Responds to an interaction by sending a message.
- Parameters:
content (
str
) – The content of the message to send.tts (
bool
) – Indicates if the message should be sent using text-to-speech.embed (
Embed
) – The rich embed for the content.embeds (List[
Embed
]) –A list containing up to 10 embeds.
If passed,
embed
also counts towards the limit of 10.components (List[Union[
ActionRow
, List[Union[Button
, Select]]]]) – A list of up to fiveButton
or one Select like object.file (
File
) – The file to upload.files (List[
File
]) – Alist
of files to upload. Must be a maximum of 10.suppress_embeds (
bool
) – Whether to suppress embeds for the message.suppress_notifications (
bool
) – Whether to suppress desktop- & push-notifications for the post starter-message.delete_after (
float
) – If provided, the number of seconds to wait in the background before deleting the response we just sent. If the deletion fails, then it is silently ignored.allowed_mentions (
AllowedMentions
) – Controls the mentions being processed in this message. If this is passed, then the object is merged withallowed_mentions
. The merging behaviour only overrides attributes that have been explicitly passed to the object, otherwise it uses the attributes set inallowed_mentions
. If no object is passed at all then the defaults given byallowed_mentions
are used instead.hidden (Optional[
bool
]) – IfTrue
the message will be only visible for the performer of the interaction (e.g.author
).
- Raises:
TypeError – This interaction was already responded to with a modal.
NotFound – The interaction has expired.
HTTPException – Responding to the interaction failed.
- await respond_with_modal(modal)
This function is a coroutine. Respond to an interaction with a popup modal.
- Parameters:
modal (
Modal
) – The modal to send.- Raises:
AlreadyResponded – This interaction was already responded to.
HTTPException – Responding to the interaction failed.
AutocompleteInteraction
- asyncget_original_callback
- asyncsend_choices
- defsuggest
- class discord.AutocompleteInteraction
Bases:
BaseInteraction
Holds the data of an application command autocomplete interaction that will be received when autocomplete for a
SlashCommandOption
withautocomplete
is set toTrue
.To respond with the autocomplete choices, use
send_choices()
.- author_locale
The locale of the user who triggered the interaction.
- Type:
Optional[
Locale
]
- guild_locale
The locale of the guild where the interaction was triggered.
- Type:
Optional[
Locale
]
- guild_id
The id of the guild where the interaction was triggered, if any.
- Type:
Optional[
int
]
- app_permissions
The permissions of the bot in the channel where the interaction was triggered, if it was in a guild.
- Type:
Optional[
Permissions
]
- property command
The slash-command for wich autocomplete was triggered.
- Type:
Optional[
SlashCommand
]
- await send_choices(choices)
Respond to the interaction with the choices the user should have.
- Parameters:
choices (List[
SlashCommandOptionChoice
]) – A list of maximum 25 options the user could choose from.- Raises:
ValueError – When more than 25 choices are passed.
NotFound – You have been waited to long with responding to the interaction.
- await suggest(choices)
An aliase for
send_choices()
- property author
The
Member
that invoked the interaction. Ifchannel
is of typeprivate
or the user has left the guild, then it is aUser
instead.
- property callback_message
The initial interaction response message, if any. (
@original
)- Type:
Optional[Union[
Message
,EphemeralMessage
]
- property channel
- Union[
TextChannel
,ThreadChannel
,DMChannel
,VoiceChannel
,ForumPost
,PartialMessageable
]: The channel where the interaction was invoked in.
- await get_original_callback(raw=False)
This function is a coroutine. Fetch the original callback-message of the interaction.
Warning
This is an API-Call and should be used carefully
- Parameters:
raw (Optional[
bool
]) – Whether to return the raw data from the api instead of aMessage
/EphemeralMessage
.- Returns:
The original callback-message of the interaction.
- Return type:
- property guild
The guild the interaction was invoked in, if there is one.
- Type:
Optional[
Guild
]
ModalSubmitInteraction
- asyncedit
- defget_field
- defget_followup
- asyncget_original_callback
- asyncrespond
- asyncrespond_with_premium_required
- class discord.ModalSubmitInteraction(state, data)
Bases:
BaseInteraction
Holds the data of an interaction that will be received when the
Submit
button of aModal
is pressed and allows responding to it.Note
You can’t respond to a modal submit interaction with another modal.
- messages
A mapping of message id’s to the message objects that were sent using
respond
.- Type:
Dict[
int
, Union[Message
,EphemeralMessage
]]
- author_locale
The locale of the user who triggered the interaction.
- Type:
Optional[
Locale
]
- guild_locale
The locale of the guild where the interaction was triggered.
- Type:
Optional[
Locale
]
- cached_message
The cached version of
message
, if any.- Type:
Optional[Union[
Message
,EphemeralMessage
]
- guild_id
The id of the guild where the interaction was triggered, if any.
- Type:
Optional[
int
]
- app_permissions
The permissions of the bot in the channel where the interaction was triggered, if it was in a guild.
- Type:
Optional[
Permissions
]
- match
The RegEx Match result of the custom_id of the modal, if an
on_submit
decorator was used.- Type:
Optional[Match]
- get_field(custom_id)
Gets the field wich
custom_id
match, if any.
This function is a coroutine. Respond with an upgrade button, only available for apps with monetized apps enabled.
- property author
The
Member
that invoked the interaction. Ifchannel
is of typeprivate
or the user has left the guild, then it is aUser
instead.
- property callback_message
The initial interaction response message, if any. (
@original
)- Type:
Optional[Union[
Message
,EphemeralMessage
]
- property channel
- Union[
TextChannel
,ThreadChannel
,DMChannel
,VoiceChannel
,ForumPost
,PartialMessageable
]: The channel where the interaction was invoked in.
- await edit(*, content=MISSING, embed=MISSING, embeds=MISSING, components=MISSING, attachments=MISSING, keep_existing_attachments=False, delete_after=None, allowed_mentions=MISSING, suppress_embeds=False)
This function is a coroutine.
Responds to the interaction by editing the original (
message
) orcallback_message
, depending on thetype
.- Parameters:
content (Optional[
str
]) – The new content to replace the message with. Could beNone
to remove the content.embed (Optional[
Embed
]) – The new embed to replace the original with. Could beNone
to remove all embeds.embeds (Optional[List[
Embed
]]) –A list containing up to 10 embeds to send. If
None
or empty, all embeds will be removed.If passed,
embed
does also count towards the limit of 10 embeds.components (List[Union[
ActionRow
, List[Union[Button
, Select]]]]) – A list of up to fiveActionRow
orlist
, each containing up to fiveButton
or one Select like object.attachments (List[Union[
Attachment
,File
]]) –A list containing previous attachments to keep as well as new files to upload. You can use
keep_existing_attachments
to auto-add the existing attachments to the list. IfNone
or empty, all attachments will be removed.Note
New files will always appear under existing ones.
keep_existing_attachments (
bool
) –Whether to auto-add existing attachments to
attachments
, defaultFalse
.Note
Only needed when
attachments
are passed, otherwise will be ignored.suppress_embeds (
bool
) – Whether to suppress embeds for the message. This removes all the embeds if set toTrue
. If set toFalse
this brings the embeds back if they were suppressed.delete_after (Optional[
float
]) – If provided, the number of seconds to wait in the background before deleting the response we just edited. If the deletion fails, then it is silently ignored.allowed_mentions (Optional[
AllowedMentions
]) – Controls the mentions being processed in this message. If this is passed, then the object is merged withallowed_mentions
. The merging behaviour only overrides attributes that have been explicitly passed to the object, otherwise it uses the attributes set inallowed_mentions
. If no object is passed at all then the defaults given byallowed_mentions
are used instead.
- Raises:
TypeError – The interaction was already responded to with a modal, or it is an application-command that was not responded to.
NotFound: – The interaction is expired.
HTTPException – Editing the message failed.
- Returns:
The edited message.
- Return type:
Union[
Message
,EphemeralMessage
]
- get_followup(id)
Gets a followup message of this interaction with the given
id
.- Parameters:
id (
int
) – The id of the followup message.- Returns:
The followup or
None
if there is none.- Return type:
Optional[Union[
Message
,EphemeralMessage
]]
- await get_original_callback(raw=False)
This function is a coroutine. Fetch the original callback-message of the interaction.
Warning
This is an API-Call and should be used carefully
- Parameters:
raw (Optional[
bool
]) – Whether to return the raw data from the api instead of aMessage
/EphemeralMessage
.- Returns:
The original callback-message of the interaction.
- Return type:
- property guild
The guild the interaction was invoked in, if there is one.
- Type:
Optional[
Guild
]
- await respond(content=None, *, tts=False, embed=None, embeds=None, components=None, file=None, files=None, delete_after=None, allowed_mentions=None, suppress_embeds=False, suppress_notifications=False, hidden=False)
This function is a coroutine.
Responds to an interaction by sending a message.
- Parameters:
content (
str
) – The content of the message to send.tts (
bool
) – Indicates if the message should be sent using text-to-speech.embed (
Embed
) – The rich embed for the content.embeds (List[
Embed
]) –A list containing up to 10 embeds.
If passed,
embed
also counts towards the limit of 10.components (List[Union[
ActionRow
, List[Union[Button
, Select]]]]) – A list of up to fiveButton
or one Select like object.file (
File
) – The file to upload.files (List[
File
]) – Alist
of files to upload. Must be a maximum of 10.suppress_embeds (
bool
) – Whether to suppress embeds for the message.suppress_notifications (
bool
) – Whether to suppress desktop- & push-notifications for the post starter-message.delete_after (
float
) – If provided, the number of seconds to wait in the background before deleting the response we just sent. If the deletion fails, then it is silently ignored.allowed_mentions (
AllowedMentions
) – Controls the mentions being processed in this message. If this is passed, then the object is merged withallowed_mentions
. The merging behaviour only overrides attributes that have been explicitly passed to the object, otherwise it uses the attributes set inallowed_mentions
. If no object is passed at all then the defaults given byallowed_mentions
are used instead.hidden (Optional[
bool
]) – IfTrue
the message will be only visible for the performer of the interaction (e.g.author
).
- Raises:
TypeError – This interaction was already responded to with a modal.
NotFound – The interaction has expired.
HTTPException – Responding to the interaction failed.
Localizations
- deffrom_target
- defupdate
- class discord.Localizations
Bases:
object
Represents a
dict
with localized values. These are used for application-commands, options and choicesname_localizations
anddescription_localizations
See
Locale
for a list of available locals.Example
Localizations( en_US='Hello World!', de='Hallo Welt!', fr='Bonjour le monde!' uk='Привіт світ!' )
Using the full language name is also possible.
Localizations( english_us='Hello World!', german='Hallo Welt!', french='Bonjour le monde!' ukrainian='Привіт світ!' )
- Parameters:
kwargs (Any) –
Keyword only arguments in format
language='Value'
As language you could use any ofdiscord.Locale
s members. See table above.Note
Values follow the same restrictions as the target they are used for. e.g. description, name, etc.
- update(_Localizations__m)
Similar to
dict.update()
- from_target(target, *, default=None)
Returns the value for the local of the object (if it’s set), or
default`(:class:`None
)- Parameters:
target (Union[
Guild
,BaseInteraction
]) – The target witch locale to use. If it is of typeBaseInteraction
(or any subclass) it returns takes the local of the author.default (Optional[Any]) – The value or an object to return by default if there is no value for the locale of
target
set. Default toNone
orenglish_US
/english_GB
- Returns:
The value of the locale or
None
if there is no value for the locale set.- Return type:
Union[
str
, None]- Raises:
TypeError – If
target
is of the wrong type.
InteractionDataOption
- class discord.interactions.InteractionDataOption
Bases:
object
Represents a slash-command option passed via a command. By default, you only get in contact with this using
focused_option
.- property options
For sub-command (groups) the sub-command or the actual options
- Type:
Optional[List[
InteractionDataOption
]]