BaseInteraction
- asyncedit
- defget_followup
- asyncget_original_callback
- asyncrespond
- asyncrespond_with_modal
- class discord.BaseInteraction
Bases:
objectThe Base-Class for a discord-interaction like clicking a
Button, select (an) option(s) ofSelectMenuor 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]]
- context
The context of the interaction, if any.
- Type:
Optional[
InteractionContextType]
- authorizing_guild_id
- Depending on the context of the interaction, the guild ID where the app integration was authorized to:
The value will be the guild ID if the interaction is triggered from a server
The value will be 0 if the interaction is triggered from a DM with the app’s bot user
See also
- Type:
Optional[
int]
- authorizing_user_id
The ID of the user the app integration is authorized to, if any.
See also
- Type:
Optional[
int]
- 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 authorizing_guild
- The guild where the app integration was
authorized to. If not cached this will return an
Objectwith the ID set to the guild ID.
Note
This is only available for interactions that were triggered in a guild, in a DM this will be
None.
- property authorizing_user
The user the app integration is authorized to, if any. If not cached this will return an
Objectwith the ID set to the user ID.
- property callback_message
The initial interaction response message, if any.
- 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 beNoneto remove the content.embed (Optional[
Embed]) – The new embed to replace the original with. Could beNoneto remove all embeds.embeds (Optional[List[
Embed]]) –A list containing up to 10 embeds to send. If
Noneor empty, all embeds will be removed.If passed,
embeddoes also count towards the limit of 10 embeds.components (List[Union[
ActionRow, List[Union[Button, Select]]]]) – A list of up to fiveActionRoworlist, each containing up to fiveButtonor 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_attachmentsto auto-add the existing attachments to the list. IfNoneor 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
attachmentsare 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 toFalsethis 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_mentionsare 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,
embedalso counts towards the limit of 10.components (List[Union[
ActionRow, List[Union[Button, Select]]]]) – A list of up to fiveButtonor one Select like object.file (
File) – The file to upload.files (List[
File]) – Alistof 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_mentionsare used instead.hidden (Optional[
bool]) – IfTruethe 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
Noneif there is none.- Return type:
Optional[Union[
Message,EphemeralMessage]]
- property author
The
Memberthat invoked the interaction. Ifchannelis of typeprivateor the user has left the guild, then it is aUserinstead.
- 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_launch_activity
- asyncrespond_with_modal
- asyncrespond_with_premium_required
- class discord.ApplicationCommandInteraction
Bases:
BaseInteractionHolds the data of an interaction when a ~discord.SlashCommand,
UserCommandorMessageCommandis 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. Deprecated Respond normal using
premiuminstead.Respond with an upgrade button, only available for apps with monetized apps enabled.
- await respond_with_launch_activity()
This function is a coroutine. Respond by launching the activity associated with the application. Only available for apps with Activities enabled.
- property author
The
Memberthat invoked the interaction. Ifchannelis of typeprivateor the user has left the guild, then it is aUserinstead.
- property authorizing_guild
- The guild where the app integration was
authorized to. If not cached this will return an
Objectwith the ID set to the guild ID.
Note
This is only available for interactions that were triggered in a guild, in a DM this will be
None.
- property authorizing_user
The user the app integration is authorized to, if any. If not cached this will return an
Objectwith the ID set to the user ID.
- property callback_message
The initial interaction response message, if any.
- 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 beNoneto remove the content.embed (Optional[
Embed]) – The new embed to replace the original with. Could beNoneto remove all embeds.embeds (Optional[List[
Embed]]) –A list containing up to 10 embeds to send. If
Noneor empty, all embeds will be removed.If passed,
embeddoes also count towards the limit of 10 embeds.components (List[Union[
ActionRow, List[Union[Button, Select]]]]) – A list of up to fiveActionRoworlist, each containing up to fiveButtonor 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_attachmentsto auto-add the existing attachments to the list. IfNoneor 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
attachmentsare 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 toFalsethis 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_mentionsare 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
Noneif 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,
embedalso counts towards the limit of 10.components (List[Union[
ActionRow, List[Union[Button, Select]]]]) – A list of up to fiveButtonor one Select like object.file (
File) – The file to upload.files (List[
File]) – Alistof 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_mentionsare used instead.hidden (Optional[
bool]) – IfTruethe 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_launch_activity
- asyncrespond_with_modal
- asyncrespond_with_premium_required
- class discord.ComponentInteraction
Bases:
BaseInteractionHolds 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_clickoron_selectdecorator was used.- Type:
Optional[
Match]
Whether the
messagehas theephemeral()flag.- Type:
- await defer(type=('deferred_update_msg', 6), hidden=False)
Defers the interaction.
- Parameters:
type (Union[Literal[5, 6]]) – Use
5to edit the original message later and6to 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
TrueNote
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.
- await respond_with_launch_activity()
This function is a coroutine. Respond by launching the activity associated with the application. Only available for apps with Activities enabled.
- property author
The
Memberthat invoked the interaction. Ifchannelis of typeprivateor the user has left the guild, then it is aUserinstead.
- property authorizing_guild
- The guild where the app integration was
authorized to. If not cached this will return an
Objectwith the ID set to the guild ID.
Note
This is only available for interactions that were triggered in a guild, in a DM this will be
None.
- property authorizing_user
The user the app integration is authorized to, if any. If not cached this will return an
Objectwith the ID set to the user ID.
- property callback_message
The initial interaction response message, if any.
- 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 beNoneto remove the content.embed (Optional[
Embed]) – The new embed to replace the original with. Could beNoneto remove all embeds.embeds (Optional[List[
Embed]]) –A list containing up to 10 embeds to send. If
Noneor empty, all embeds will be removed.If passed,
embeddoes also count towards the limit of 10 embeds.components (List[Union[
ActionRow, List[Union[Button, Select]]]]) – A list of up to fiveActionRoworlist, each containing up to fiveButtonor 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_attachmentsto auto-add the existing attachments to the list. IfNoneor 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
attachmentsare 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 toFalsethis 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_mentionsare 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
Noneif 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,
embedalso counts towards the limit of 10.components (List[Union[
ActionRow, List[Union[Button, Select]]]]) – A list of up to fiveButtonor one Select like object.file (
File) – The file to upload.files (List[
File]) – Alistof 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_mentionsare used instead.hidden (Optional[
bool]) – IfTruethe 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:
BaseInteractionHolds the data of an application command autocomplete interaction that will be received when autocomplete for a
SlashCommandOptionwithautocompleteis 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 which 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
Memberthat invoked the interaction. Ifchannelis of typeprivateor the user has left the guild, then it is aUserinstead.
- property authorizing_guild
- The guild where the app integration was
authorized to. If not cached this will return an
Objectwith the ID set to the guild ID.
Note
This is only available for interactions that were triggered in a guild, in a DM this will be
None.
- property authorizing_user
The user the app integration is authorized to, if any. If not cached this will return an
Objectwith the ID set to the user ID.
- property callback_message
The initial interaction response message, if any.
- 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]
ModalSubmitInteraction
- asyncedit
- defget_field
- defget_followup
- asyncget_original_callback
- asyncrespond
- asyncrespond_with_launch_activity
- asyncrespond_with_premium_required
- class discord.ModalSubmitInteraction(state, data)
Bases:
BaseInteractionHolds the data of an interaction that will be received when the
Submitbutton of aModalis 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_submitdecorator was used.- Type:
Optional[Match]
- get_field(custom_id)
Gets the field which
custom_idmatch, if any.
This function is a coroutine. Respond with an upgrade button, only available for apps with monetized apps enabled.
Note
You must respond with this one directly, without using any of
defer()orrespond().
- await respond_with_launch_activity()
This function is a coroutine. Respond by launching the activity associated with the application. Only available for apps with Activities enabled.
Note
You must respond with this one directly, without using any of
defer()orrespond().
- property author
The
Memberthat invoked the interaction. Ifchannelis of typeprivateor the user has left the guild, then it is aUserinstead.
- property authorizing_guild
- The guild where the app integration was
authorized to. If not cached this will return an
Objectwith the ID set to the guild ID.
Note
This is only available for interactions that were triggered in a guild, in a DM this will be
None.
- property authorizing_user
The user the app integration is authorized to, if any. If not cached this will return an
Objectwith the ID set to the user ID.
- property callback_message
The initial interaction response message, if any.
- 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 beNoneto remove the content.embed (Optional[
Embed]) – The new embed to replace the original with. Could beNoneto remove all embeds.embeds (Optional[List[
Embed]]) –A list containing up to 10 embeds to send. If
Noneor empty, all embeds will be removed.If passed,
embeddoes also count towards the limit of 10 embeds.components (List[Union[
ActionRow, List[Union[Button, Select]]]]) – A list of up to fiveActionRoworlist, each containing up to fiveButtonor 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_attachmentsto auto-add the existing attachments to the list. IfNoneor 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
attachmentsare 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 toFalsethis 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_mentionsare 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
Noneif 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,
embedalso counts towards the limit of 10.components (List[Union[
ActionRow, List[Union[Button, Select]]]]) – A list of up to fiveButtonor one Select like object.file (
File) – The file to upload.files (List[
File]) – Alistof 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_mentionsare used instead.hidden (Optional[
bool]) – IfTruethe 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:
objectRepresents a
dictwith localized values. These are used for application-commands, options and choicesname_localizationsanddescription_localizationsSee
Localefor 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.Locales 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
targetset. Default toNoneorenglish_US/english_GB
- Returns:
The value of the locale or
Noneif there is no value for the locale set.- Return type:
Union[
str, None]- Raises:
TypeError – If
targetis of the wrong type.
InteractionDataOption
- class discord.interactions.InteractionDataOption
Bases:
objectRepresents 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]]