Interactions

This section documents everything related to interactions, which are used for communication between user and client. Common examples are message components and application commands.

Discord Models

Interaction

class disnake.Interaction[source]

A base class representing a user-initiated Discord interaction.

An interaction happens when a user performs an action that the client needs to be notified of. Current examples are application commands and components.

New in version 2.0.

data

The interaction’s raw data. This might be replaced with a more processed version in subclasses.

Type:

Mapping[str, Any]

id

The interaction’s ID.

Type:

int

type

The interaction’s type.

Type:

InteractionType

application_id

The application ID that the interaction was for.

Type:

int

guild_id

The guild ID the interaction was sent from.

Type:

Optional[int]

guild_locale

The selected language of the interaction’s guild. This value is only meaningful in guilds with COMMUNITY feature and receives a default value otherwise. If the interaction was in a DM, then this value is None.

New in version 2.4.

Changed in version 2.5: Changed to Locale instead of str.

Type:

Optional[Locale]

channel_id

The channel ID the interaction was sent from.

Type:

int

author

The user or member that sent the interaction.

Type:

Union[User, Member]

locale

The selected language of the interaction’s author.

New in version 2.4.

Changed in version 2.5: Changed to Locale instead of str.

Type:

Locale

token

The token to continue the interaction. These are valid for 15 minutes.

Type:

str

client

The interaction client.

Type:

Client

original_message()[source]

An alias of original_response().

edit_original_message()[source]

An alias of edit_original_response().

delete_original_message()[source]

An alias of delete_original_response().

property bot[source]

The bot handling the interaction.

Only applicable when used with Bot. This is an alias for client.

Type:

Bot

property created_at[source]

Returns the interaction’s creation time in UTC.

Type:

datetime.datetime

property user[source]

The user or member that sent the interaction. There is an alias for this named author.

Type:

Union[User, Member]

property guild[source]

The guild the interaction was sent from.

Type:

Optional[Guild]

me

Union[Member, ClientUser]: Similar to Guild.me except it may return the ClientUser in private message contexts.

channel

The channel the interaction was sent from.

Note that due to a Discord limitation, threads that the bot cannot access and DM channels are not resolved since there is no data to complete them. These are PartialMessageable instead.

If you want to compute the interaction author’s or bot’s permissions in the channel, consider using permissions or app_permissions instead.

Type:

Union[abc.GuildChannel, Thread, PartialMessageable]

property permissions[source]

The resolved permissions of the member in the channel, including overwrites.

In a guild context, this is provided directly by Discord.

In a non-guild context this will be an instance of Permissions.private_channel().

Type:

Permissions

property app_permissions[source]

The resolved permissions of the bot in the channel, including overwrites.

In a guild context, this is provided directly by Discord.

In a non-guild context this will be an instance of Permissions.private_channel().

New in version 2.6.

Type:

Permissions

response

Returns an object responsible for handling responding to the interaction.

A response can only be done once. If secondary messages need to be sent, consider using followup instead.

Type:

InteractionResponse

followup

Returns the follow up webhook for follow up interactions.

Type:

Webhook

expires_at

Returns the interaction’s expiration time in UTC.

This is exactly 15 minutes after the interaction was created.

New in version 2.5.

Type:

datetime.datetime

is_expired()[source]

Whether the interaction can still be used to make requests to Discord.

This does not take into account the 3 second limit for the initial response.

New in version 2.5.

Return type:

bool

await original_response()[source]

This function is a coroutine.

Fetches the original interaction response message associated with the interaction.

Here is a table with response types and their associated original response:

Response type

Original response

InteractionResponse.send_message()

The message you sent

InteractionResponse.edit_message()

The message you edited

InteractionResponse.defer()

The message with thinking state (bot is thinking…)

Other response types

None

Repeated calls to this will return a cached value.

Changed in version 2.6: This function was renamed from original_message.

Raises:

HTTPException – Fetching the original response message failed.

Returns:

The original interaction response message.

Return type:

InteractionMessage

await edit_original_response(content=..., *, embed=..., embeds=..., file=..., files=..., attachments=..., view=..., components=..., suppress_embeds=..., flags=..., allowed_mentions=None)[source]

This function is a coroutine.

Edits the original, previously sent interaction response message.

This is a lower level interface to InteractionMessage.edit() in case you do not want to fetch the message and save an HTTP request.

This method is also the only way to edit the original response if the message sent was ephemeral.

Note

If the original response message has embeds with images that were created from local files (using the file parameter with Embed.set_image() or Embed.set_thumbnail()), those images will be removed if the message’s attachments are edited in any way (i.e. by setting file/files/attachments, or adding an embed with local files).

Changed in version 2.6: This function was renamed from edit_original_message.

Parameters:
  • content (Optional[str]) – The content to edit the message with, or None to clear it.

  • embed (Optional[Embed]) – The new embed to replace the original with. This cannot be mixed with the embeds parameter. Could be None to remove the embed.

  • embeds (List[Embed]) – The new embeds to replace the original with. Must be a maximum of 10. This cannot be mixed with the embed parameter. To remove all embeds [] should be passed.

  • file (File) – The file to upload. This cannot be mixed with the files parameter. Files will be appended to the message, see the attachments parameter to remove/replace existing files.

  • files (List[File]) – A list of files to upload. This cannot be mixed with the file parameter. Files will be appended to the message, see the attachments parameter to remove/replace existing files.

  • attachments (Optional[List[Attachment]]) –

    A list of attachments to keep in the message. If [] or None is passed then all existing attachments are removed. Keeps existing attachments if not provided.

    New in version 2.2.

    Changed in version 2.5: Supports passing None to clear attachments.

  • view (Optional[View]) – The updated view to update this message with. This cannot be mixed with components. If None is passed then the view is removed.

  • components (Optional[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[disnake.ui.WrappedComponent]]]]]) –

    A list of components to update this message with. This cannot be mixed with view. If None is passed then the components are removed.

    New in version 2.4.

  • allowed_mentions (AllowedMentions) – Controls the mentions being processed in this message. See abc.Messageable.send() for more information.

  • suppress_embeds (bool) –

    Whether to suppress embeds for the message. This hides all the embeds from the UI if set to True. If set to False, this brings the embeds back if they were suppressed.

    New in version 2.7.

  • flags (MessageFlags) –

    The new flags to set for this message. Overrides existing flags. Only suppress_embeds is supported.

    If parameter suppress_embeds is provided, that will override the setting of MessageFlags.suppress_embeds.

    New in version 2.9.

Raises:
  • HTTPException – Editing the message failed.

  • Forbidden – Edited a message that is not yours.

  • TypeError – You specified both embed and embeds or file and files

  • ValueError – The length of embeds was invalid.

Returns:

The newly edited message.

Return type:

InteractionMessage

await delete_original_response(*, delay=None)[source]

This function is a coroutine.

Deletes the original interaction response message.

This is a lower level interface to InteractionMessage.delete() in case you do not want to fetch the message and save an HTTP request.

Changed in version 2.6: This function was renamed from delete_original_message.

Parameters:

delay (float) – If provided, the number of seconds to wait in the background before deleting the original response message. If the deletion fails, then it is silently ignored.

Raises:
await send(content=None, *, embed=..., embeds=..., file=..., files=..., allowed_mentions=..., view=..., components=..., tts=False, ephemeral=..., suppress_embeds=..., flags=..., delete_after=...)[source]

This function is a coroutine.

Sends a message using either response.send_message or followup.send.

If the interaction hasn’t been responded to yet, this method will call response.send_message. Otherwise, it will call followup.send.

Note

This method does not return a Message object. If you need a message object, use original_response() to fetch it, or use followup.send directly instead of this method if you’re sending a followup message.

Parameters:
  • content (Optional[str]) – The content of the message to send.

  • embed (Embed) – The rich embed for the content to send. This cannot be mixed with the embeds parameter.

  • embeds (List[Embed]) – A list of embeds to send with the content. Must be a maximum of 10. This cannot be mixed with the embed parameter.

  • file (File) – The file to upload. This cannot be mixed with the files parameter.

  • files (List[File]) – A list of files to upload. Must be a maximum of 10. This cannot be mixed with the file parameter.

  • allowed_mentions (AllowedMentions) – Controls the mentions being processed in this message. If this is passed, then the object is merged with Client.allowed_mentions. The merging behaviour only overrides attributes that have been explicitly passed to the object, otherwise it uses the attributes set in Client.allowed_mentions. If no object is passed at all then the defaults given by Client.allowed_mentions are used instead.

  • tts (bool) – Whether the message should be sent using text-to-speech.

  • view (disnake.ui.View) – The view to send with the message. This cannot be mixed with components.

  • components (Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[disnake.ui.WrappedComponent]]]]) –

    A list of components to send with the message. This cannot be mixed with view.

    New in version 2.4.

  • ephemeral (bool) – Whether the message should only be visible to the user who started the interaction. If a view is sent with an ephemeral message and it has no timeout set then the timeout is set to 15 minutes.

  • suppress_embeds (bool) –

    Whether to suppress embeds for the message. This hides all the embeds from the UI if set to True.

    New in version 2.5.

  • flags (MessageFlags) –

    The flags to set for this message. Only suppress_embeds, ephemeral and suppress_notifications are supported.

    If parameters suppress_embeds or ephemeral are provided, they will override the corresponding setting of this flags parameter.

    New in version 2.9.

  • delete_after (float) –

    If provided, the number of seconds to wait in the background before deleting the message we just sent. If the deletion fails, then it is silently ignored.

    Can be up to 15 minutes after the interaction was created (see also expires_at/is_expired).

    Changed in version 2.7: Added support for ephemeral responses.

Raises:

ApplicationCommandInteraction

class disnake.ApplicationCommandInteraction[source]

Represents an interaction with an application command.

Current examples are slash commands, user commands and message commands.

New in version 2.1.

id

The interaction’s ID.

Type:

int

type

The interaction’s type.

Type:

InteractionType

application_id

The application ID that the interaction was for.

Type:

int

guild_id

The guild ID the interaction was sent from.

Type:

Optional[int]

channel_id

The channel ID the interaction was sent from.

Type:

int

author

The user or member that sent the interaction.

Type:

Union[User, Member]

locale

The selected language of the interaction’s author.

New in version 2.4.

Changed in version 2.5: Changed to Locale instead of str.

Type:

Locale

guild_locale

The selected language of the interaction’s guild. This value is only meaningful in guilds with COMMUNITY feature and receives a default value otherwise. If the interaction was in a DM, then this value is None.

New in version 2.4.

Changed in version 2.5: Changed to Locale instead of str.

Type:

Optional[Locale]

token

The token to continue the interaction. These are valid for 15 minutes.

Type:

str

data

The wrapped interaction data.

Type:

ApplicationCommandInteractionData

client

The interaction client.

Type:

Client

application_command

The command invoked by the interaction.

Type:

InvokableApplicationCommand

command_failed

Whether the command failed to be checked or invoked.

Type:

bool

original_message()[source]

An alias of original_response().

edit_original_message()[source]

An alias of edit_original_response().

delete_original_message()[source]

An alias of delete_original_response().

property target[source]

The user or message targetted by a user or message command

Type:

Optional[Union[abc.User, Message]]

property options[source]

The full option tree, including nestings

Type:

Dict[str, Any]

property filled_options[source]

The options of the command (or sub-command) being invoked

Type:

Dict[str, Any]

property app_permissions[source]

The resolved permissions of the bot in the channel, including overwrites.

In a guild context, this is provided directly by Discord.

In a non-guild context this will be an instance of Permissions.private_channel().

New in version 2.6.

Type:

Permissions

property bot[source]

The bot handling the interaction.

Only applicable when used with Bot. This is an alias for client.

Type:

Bot

channel

The channel the interaction was sent from.

Note that due to a Discord limitation, threads that the bot cannot access and DM channels are not resolved since there is no data to complete them. These are PartialMessageable instead.

If you want to compute the interaction author’s or bot’s permissions in the channel, consider using permissions or app_permissions instead.

Type:

Union[abc.GuildChannel, Thread, PartialMessageable]

property created_at[source]

Returns the interaction’s creation time in UTC.

Type:

datetime.datetime

await delete_original_response(*, delay=None)[source]

This function is a coroutine.

Deletes the original interaction response message.

This is a lower level interface to InteractionMessage.delete() in case you do not want to fetch the message and save an HTTP request.

Changed in version 2.6: This function was renamed from delete_original_message.

Parameters:

delay (float) – If provided, the number of seconds to wait in the background before deleting the original response message. If the deletion fails, then it is silently ignored.

Raises:
await edit_original_response(content=..., *, embed=..., embeds=..., file=..., files=..., attachments=..., view=..., components=..., suppress_embeds=..., flags=..., allowed_mentions=None)[source]

This function is a coroutine.

Edits the original, previously sent interaction response message.

This is a lower level interface to InteractionMessage.edit() in case you do not want to fetch the message and save an HTTP request.

This method is also the only way to edit the original response if the message sent was ephemeral.

Note

If the original response message has embeds with images that were created from local files (using the file parameter with Embed.set_image() or Embed.set_thumbnail()), those images will be removed if the message’s attachments are edited in any way (i.e. by setting file/files/attachments, or adding an embed with local files).

Changed in version 2.6: This function was renamed from edit_original_message.

Parameters:
  • content (Optional[str]) – The content to edit the message with, or None to clear it.

  • embed (Optional[Embed]) – The new embed to replace the original with. This cannot be mixed with the embeds parameter. Could be None to remove the embed.

  • embeds (List[Embed]) – The new embeds to replace the original with. Must be a maximum of 10. This cannot be mixed with the embed parameter. To remove all embeds [] should be passed.

  • file (File) – The file to upload. This cannot be mixed with the files parameter. Files will be appended to the message, see the attachments parameter to remove/replace existing files.

  • files (List[File]) – A list of files to upload. This cannot be mixed with the file parameter. Files will be appended to the message, see the attachments parameter to remove/replace existing files.

  • attachments (Optional[List[Attachment]]) –

    A list of attachments to keep in the message. If [] or None is passed then all existing attachments are removed. Keeps existing attachments if not provided.

    New in version 2.2.

    Changed in version 2.5: Supports passing None to clear attachments.

  • view (Optional[View]) – The updated view to update this message with. This cannot be mixed with components. If None is passed then the view is removed.

  • components (Optional[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[disnake.ui.WrappedComponent]]]]]) –

    A list of components to update this message with. This cannot be mixed with view. If None is passed then the components are removed.

    New in version 2.4.

  • allowed_mentions (AllowedMentions) – Controls the mentions being processed in this message. See abc.Messageable.send() for more information.

  • suppress_embeds (bool) –

    Whether to suppress embeds for the message. This hides all the embeds from the UI if set to True. If set to False, this brings the embeds back if they were suppressed.

    New in version 2.7.

  • flags (MessageFlags) –

    The new flags to set for this message. Overrides existing flags. Only suppress_embeds is supported.

    If parameter suppress_embeds is provided, that will override the setting of MessageFlags.suppress_embeds.

    New in version 2.9.

Raises:
  • HTTPException – Editing the message failed.

  • Forbidden – Edited a message that is not yours.

  • TypeError – You specified both embed and embeds or file and files

  • ValueError – The length of embeds was invalid.

Returns:

The newly edited message.

Return type:

InteractionMessage

expires_at

Returns the interaction’s expiration time in UTC.

This is exactly 15 minutes after the interaction was created.

New in version 2.5.

Type:

datetime.datetime

followup

Returns the follow up webhook for follow up interactions.

Type:

Webhook

property guild[source]

The guild the interaction was sent from.

Type:

Optional[Guild]

is_expired()[source]

Whether the interaction can still be used to make requests to Discord.

This does not take into account the 3 second limit for the initial response.

New in version 2.5.

Return type:

bool

me

Union[Member, ClientUser]: Similar to Guild.me except it may return the ClientUser in private message contexts.

await original_response()[source]

This function is a coroutine.

Fetches the original interaction response message associated with the interaction.

Here is a table with response types and their associated original response:

Response type

Original response

InteractionResponse.send_message()

The message you sent

InteractionResponse.edit_message()

The message you edited

InteractionResponse.defer()

The message with thinking state (bot is thinking…)

Other response types

None

Repeated calls to this will return a cached value.

Changed in version 2.6: This function was renamed from original_message.

Raises:

HTTPException – Fetching the original response message failed.

Returns:

The original interaction response message.

Return type:

InteractionMessage

property permissions[source]

The resolved permissions of the member in the channel, including overwrites.

In a guild context, this is provided directly by Discord.

In a non-guild context this will be an instance of Permissions.private_channel().

Type:

Permissions

response

Returns an object responsible for handling responding to the interaction.

A response can only be done once. If secondary messages need to be sent, consider using followup instead.

Type:

InteractionResponse

await send(content=None, *, embed=..., embeds=..., file=..., files=..., allowed_mentions=..., view=..., components=..., tts=False, ephemeral=..., suppress_embeds=..., flags=..., delete_after=...)[source]

This function is a coroutine.

Sends a message using either response.send_message or followup.send.

If the interaction hasn’t been responded to yet, this method will call response.send_message. Otherwise, it will call followup.send.

Note

This method does not return a Message object. If you need a message object, use original_response() to fetch it, or use followup.send directly instead of this method if you’re sending a followup message.

Parameters:
  • content (Optional[str]) – The content of the message to send.

  • embed (Embed) – The rich embed for the content to send. This cannot be mixed with the embeds parameter.

  • embeds (List[Embed]) – A list of embeds to send with the content. Must be a maximum of 10. This cannot be mixed with the embed parameter.

  • file (File) – The file to upload. This cannot be mixed with the files parameter.

  • files (List[File]) – A list of files to upload. Must be a maximum of 10. This cannot be mixed with the file parameter.

  • allowed_mentions (AllowedMentions) – Controls the mentions being processed in this message. If this is passed, then the object is merged with Client.allowed_mentions. The merging behaviour only overrides attributes that have been explicitly passed to the object, otherwise it uses the attributes set in Client.allowed_mentions. If no object is passed at all then the defaults given by Client.allowed_mentions are used instead.

  • tts (bool) – Whether the message should be sent using text-to-speech.

  • view (disnake.ui.View) – The view to send with the message. This cannot be mixed with components.

  • components (Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[disnake.ui.WrappedComponent]]]]) –

    A list of components to send with the message. This cannot be mixed with view.

    New in version 2.4.

  • ephemeral (bool) – Whether the message should only be visible to the user who started the interaction. If a view is sent with an ephemeral message and it has no timeout set then the timeout is set to 15 minutes.

  • suppress_embeds (bool) –

    Whether to suppress embeds for the message. This hides all the embeds from the UI if set to True.

    New in version 2.5.

  • flags (MessageFlags) –

    The flags to set for this message. Only suppress_embeds, ephemeral and suppress_notifications are supported.

    If parameters suppress_embeds or ephemeral are provided, they will override the corresponding setting of this flags parameter.

    New in version 2.9.

  • delete_after (float) –

    If provided, the number of seconds to wait in the background before deleting the message we just sent. If the deletion fails, then it is silently ignored.

    Can be up to 15 minutes after the interaction was created (see also expires_at/is_expired).

    Changed in version 2.7: Added support for ephemeral responses.

Raises:
property user[source]

The user or member that sent the interaction. There is an alias for this named author.

Type:

Union[User, Member]

GuildCommandInteraction

class disnake.GuildCommandInteraction[source]

An ApplicationCommandInteraction subclass, primarily meant for annotations.

This prevents the command from being invoked in DMs by automatically setting ApplicationCommand.dm_permission to False for user/message commands and top-level slash commands.

Note that this does not apply to slash subcommands, subcommand groups, or autocomplete callbacks.

Additionally, annotations of some attributes are modified to match the expected types in guilds.

UserCommandInteraction

class disnake.UserCommandInteraction[source]

An ApplicationCommandInteraction subclass meant for annotations.

No runtime behavior is changed but annotations are modified to seem like the interaction is specifically a user command.

MessageCommandInteraction

class disnake.MessageCommandInteraction[source]

An ApplicationCommandInteraction subclass meant for annotations.

No runtime behavior is changed but annotations are modified to seem like the interaction is specifically a message command.

MessageInteraction

class disnake.MessageInteraction[source]

Represents an interaction with a message component.

Current examples are buttons and dropdowns.

New in version 2.1.

id

The interaction’s ID.

Type:

int

type

The interaction type.

Type:

InteractionType

application_id

The application ID that the interaction was for.

Type:

int

token

The token to continue the interaction. These are valid for 15 minutes.

Type:

str

guild_id

The guild ID the interaction was sent from.

Type:

Optional[int]

channel_id

The channel ID the interaction was sent from.

Type:

int

author

The user or member that sent the interaction.

Type:

Union[User, Member]

locale

The selected language of the interaction’s author.

New in version 2.4.

Changed in version 2.5: Changed to Locale instead of str.

Type:

Locale

guild_locale

The selected language of the interaction’s guild. This value is only meaningful in guilds with COMMUNITY feature and receives a default value otherwise. If the interaction was in a DM, then this value is None.

New in version 2.4.

Changed in version 2.5: Changed to Locale instead of str.

Type:

Optional[Locale]

message

The message that sent this interaction.

Type:

Optional[Message]

data

The wrapped interaction data.

Type:

MessageInteractionData

client

The interaction client.

Type:

Client

original_message()[source]

An alias of original_response().

edit_original_message()[source]

An alias of edit_original_response().

delete_original_message()[source]

An alias of delete_original_response().

property values[source]

The values the user selected.

For select menus of type string_select, these are just the string values the user selected. For other select menu types, these are the IDs of the selected entities.

See also resolved_values.

Type:

Optional[List[str]]

resolved_values

The (resolved) values the user selected.

For select menus of type string_select, this is equivalent to values. For other select menu types, these are full objects corresponding to the selected entities.

New in version 2.7.

Type:

Optional[Sequence[str, Member, User, Role, Union[abc.GuildChannel, Thread, PartialMessageable]]]

component

The component the user interacted with

Type:

Union[Button, BaseSelectMenu]

property app_permissions[source]

The resolved permissions of the bot in the channel, including overwrites.

In a guild context, this is provided directly by Discord.

In a non-guild context this will be an instance of Permissions.private_channel().

New in version 2.6.

Type:

Permissions

property bot[source]

The bot handling the interaction.

Only applicable when used with Bot. This is an alias for client.

Type:

Bot

channel

The channel the interaction was sent from.

Note that due to a Discord limitation, threads that the bot cannot access and DM channels are not resolved since there is no data to complete them. These are PartialMessageable instead.

If you want to compute the interaction author’s or bot’s permissions in the channel, consider using permissions or app_permissions instead.

Type:

Union[abc.GuildChannel, Thread, PartialMessageable]

property created_at[source]

Returns the interaction’s creation time in UTC.

Type:

datetime.datetime

await delete_original_response(*, delay=None)[source]

This function is a coroutine.

Deletes the original interaction response message.

This is a lower level interface to InteractionMessage.delete() in case you do not want to fetch the message and save an HTTP request.

Changed in version 2.6: This function was renamed from delete_original_message.

Parameters:

delay (float) – If provided, the number of seconds to wait in the background before deleting the original response message. If the deletion fails, then it is silently ignored.

Raises:
await edit_original_response(content=..., *, embed=..., embeds=..., file=..., files=..., attachments=..., view=..., components=..., suppress_embeds=..., flags=..., allowed_mentions=None)[source]

This function is a coroutine.

Edits the original, previously sent interaction response message.

This is a lower level interface to InteractionMessage.edit() in case you do not want to fetch the message and save an HTTP request.

This method is also the only way to edit the original response if the message sent was ephemeral.

Note

If the original response message has embeds with images that were created from local files (using the file parameter with Embed.set_image() or Embed.set_thumbnail()), those images will be removed if the message’s attachments are edited in any way (i.e. by setting file/files/attachments, or adding an embed with local files).

Changed in version 2.6: This function was renamed from edit_original_message.

Parameters:
  • content (Optional[str]) – The content to edit the message with, or None to clear it.

  • embed (Optional[Embed]) – The new embed to replace the original with. This cannot be mixed with the embeds parameter. Could be None to remove the embed.

  • embeds (List[Embed]) – The new embeds to replace the original with. Must be a maximum of 10. This cannot be mixed with the embed parameter. To remove all embeds [] should be passed.

  • file (File) – The file to upload. This cannot be mixed with the files parameter. Files will be appended to the message, see the attachments parameter to remove/replace existing files.

  • files (List[File]) – A list of files to upload. This cannot be mixed with the file parameter. Files will be appended to the message, see the attachments parameter to remove/replace existing files.

  • attachments (Optional[List[Attachment]]) –

    A list of attachments to keep in the message. If [] or None is passed then all existing attachments are removed. Keeps existing attachments if not provided.

    New in version 2.2.

    Changed in version 2.5: Supports passing None to clear attachments.

  • view (Optional[View]) – The updated view to update this message with. This cannot be mixed with components. If None is passed then the view is removed.

  • components (Optional[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[disnake.ui.WrappedComponent]]]]]) –

    A list of components to update this message with. This cannot be mixed with view. If None is passed then the components are removed.

    New in version 2.4.

  • allowed_mentions (AllowedMentions) – Controls the mentions being processed in this message. See abc.Messageable.send() for more information.

  • suppress_embeds (bool) –

    Whether to suppress embeds for the message. This hides all the embeds from the UI if set to True. If set to False, this brings the embeds back if they were suppressed.

    New in version 2.7.

  • flags (MessageFlags) –

    The new flags to set for this message. Overrides existing flags. Only suppress_embeds is supported.

    If parameter suppress_embeds is provided, that will override the setting of MessageFlags.suppress_embeds.

    New in version 2.9.

Raises:
  • HTTPException – Editing the message failed.

  • Forbidden – Edited a message that is not yours.

  • TypeError – You specified both embed and embeds or file and files

  • ValueError – The length of embeds was invalid.

Returns:

The newly edited message.

Return type:

InteractionMessage

expires_at

Returns the interaction’s expiration time in UTC.

This is exactly 15 minutes after the interaction was created.

New in version 2.5.

Type:

datetime.datetime

followup

Returns the follow up webhook for follow up interactions.

Type:

Webhook

property guild[source]

The guild the interaction was sent from.

Type:

Optional[Guild]

is_expired()[source]

Whether the interaction can still be used to make requests to Discord.

This does not take into account the 3 second limit for the initial response.

New in version 2.5.

Return type:

bool

me

Union[Member, ClientUser]: Similar to Guild.me except it may return the ClientUser in private message contexts.

await original_response()[source]

This function is a coroutine.

Fetches the original interaction response message associated with the interaction.

Here is a table with response types and their associated original response:

Response type

Original response

InteractionResponse.send_message()

The message you sent

InteractionResponse.edit_message()

The message you edited

InteractionResponse.defer()

The message with thinking state (bot is thinking…)

Other response types

None

Repeated calls to this will return a cached value.

Changed in version 2.6: This function was renamed from original_message.

Raises:

HTTPException – Fetching the original response message failed.

Returns:

The original interaction response message.

Return type:

InteractionMessage

property permissions[source]

The resolved permissions of the member in the channel, including overwrites.

In a guild context, this is provided directly by Discord.

In a non-guild context this will be an instance of Permissions.private_channel().

Type:

Permissions

response

Returns an object responsible for handling responding to the interaction.

A response can only be done once. If secondary messages need to be sent, consider using followup instead.

Type:

InteractionResponse

await send(content=None, *, embed=..., embeds=..., file=..., files=..., allowed_mentions=..., view=..., components=..., tts=False, ephemeral=..., suppress_embeds=..., flags=..., delete_after=...)[source]

This function is a coroutine.

Sends a message using either response.send_message or followup.send.

If the interaction hasn’t been responded to yet, this method will call response.send_message. Otherwise, it will call followup.send.

Note

This method does not return a Message object. If you need a message object, use original_response() to fetch it, or use followup.send directly instead of this method if you’re sending a followup message.

Parameters:
  • content (Optional[str]) – The content of the message to send.

  • embed (Embed) – The rich embed for the content to send. This cannot be mixed with the embeds parameter.

  • embeds (List[Embed]) – A list of embeds to send with the content. Must be a maximum of 10. This cannot be mixed with the embed parameter.

  • file (File) – The file to upload. This cannot be mixed with the files parameter.

  • files (List[File]) – A list of files to upload. Must be a maximum of 10. This cannot be mixed with the file parameter.

  • allowed_mentions (AllowedMentions) – Controls the mentions being processed in this message. If this is passed, then the object is merged with Client.allowed_mentions. The merging behaviour only overrides attributes that have been explicitly passed to the object, otherwise it uses the attributes set in Client.allowed_mentions. If no object is passed at all then the defaults given by Client.allowed_mentions are used instead.

  • tts (bool) – Whether the message should be sent using text-to-speech.

  • view (disnake.ui.View) – The view to send with the message. This cannot be mixed with components.

  • components (Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[disnake.ui.WrappedComponent]]]]) –

    A list of components to send with the message. This cannot be mixed with view.

    New in version 2.4.

  • ephemeral (bool) – Whether the message should only be visible to the user who started the interaction. If a view is sent with an ephemeral message and it has no timeout set then the timeout is set to 15 minutes.

  • suppress_embeds (bool) –

    Whether to suppress embeds for the message. This hides all the embeds from the UI if set to True.

    New in version 2.5.

  • flags (MessageFlags) –

    The flags to set for this message. Only suppress_embeds, ephemeral and suppress_notifications are supported.

    If parameters suppress_embeds or ephemeral are provided, they will override the corresponding setting of this flags parameter.

    New in version 2.9.

  • delete_after (float) –

    If provided, the number of seconds to wait in the background before deleting the message we just sent. If the deletion fails, then it is silently ignored.

    Can be up to 15 minutes after the interaction was created (see also expires_at/is_expired).

    Changed in version 2.7: Added support for ephemeral responses.

Raises:
property user[source]

The user or member that sent the interaction. There is an alias for this named author.

Type:

Union[User, Member]

ModalInteraction

class disnake.ModalInteraction[source]

Represents an interaction with a modal.

New in version 2.4.

id

The interaction’s ID.

Type:

int

type

The interaction type.

Type:

InteractionType

application_id

The application ID that the interaction was for.

Type:

int

token

The token to continue the interaction. These are valid for 15 minutes.

Type:

str

guild_id

The guild ID the interaction was sent from.

Type:

Optional[int]

channel_id

The channel ID the interaction was sent from.

Type:

int

author

The user or member that sent the interaction.

Type:

Union[User, Member]

locale

The selected language of the interaction’s author.

Changed in version 2.5: Changed to Locale instead of str.

Type:

Locale

guild_locale

The selected language of the interaction’s guild. This value is only meaningful in guilds with COMMUNITY feature and receives a default value otherwise. If the interaction was in a DM, then this value is None.

Changed in version 2.5: Changed to Locale instead of str.

Type:

Optional[Locale]

message

The message that this interaction’s modal originated from, if the modal was sent in response to a component interaction.

New in version 2.5.

Type:

Optional[Message]

data

The wrapped interaction data.

Type:

ModalInteractionData

client

The interaction client.

Type:

Client

original_message()[source]

An alias of original_response().

edit_original_message()[source]

An alias of edit_original_response().

delete_original_message()[source]

An alias of delete_original_response().

for ... in walk_raw_components()[source]

Returns a generator that yields raw component data from action rows one by one, as provided by Discord. This does not contain all fields of the components due to API limitations.

New in version 2.6.

Return type:

Generator[dict, None, None]

text_values

Returns the text values the user has entered in the modal. This is a dict of the form {custom_id: value}.

Type:

Dict[str, str]

property custom_id[source]

The custom ID of the modal.

Type:

str

property app_permissions[source]

The resolved permissions of the bot in the channel, including overwrites.

In a guild context, this is provided directly by Discord.

In a non-guild context this will be an instance of Permissions.private_channel().

New in version 2.6.

Type:

Permissions

property bot[source]

The bot handling the interaction.

Only applicable when used with Bot. This is an alias for client.

Type:

Bot

channel

The channel the interaction was sent from.

Note that due to a Discord limitation, threads that the bot cannot access and DM channels are not resolved since there is no data to complete them. These are PartialMessageable instead.

If you want to compute the interaction author’s or bot’s permissions in the channel, consider using permissions or app_permissions instead.

Type:

Union[abc.GuildChannel, Thread, PartialMessageable]

property created_at[source]

Returns the interaction’s creation time in UTC.

Type:

datetime.datetime

await delete_original_response(*, delay=None)[source]

This function is a coroutine.

Deletes the original interaction response message.

This is a lower level interface to InteractionMessage.delete() in case you do not want to fetch the message and save an HTTP request.

Changed in version 2.6: This function was renamed from delete_original_message.

Parameters:

delay (float) – If provided, the number of seconds to wait in the background before deleting the original response message. If the deletion fails, then it is silently ignored.

Raises:
await edit_original_response(content=..., *, embed=..., embeds=..., file=..., files=..., attachments=..., view=..., components=..., suppress_embeds=..., flags=..., allowed_mentions=None)[source]

This function is a coroutine.

Edits the original, previously sent interaction response message.

This is a lower level interface to InteractionMessage.edit() in case you do not want to fetch the message and save an HTTP request.

This method is also the only way to edit the original response if the message sent was ephemeral.

Note

If the original response message has embeds with images that were created from local files (using the file parameter with Embed.set_image() or Embed.set_thumbnail()), those images will be removed if the message’s attachments are edited in any way (i.e. by setting file/files/attachments, or adding an embed with local files).

Changed in version 2.6: This function was renamed from edit_original_message.

Parameters:
  • content (Optional[str]) – The content to edit the message with, or None to clear it.

  • embed (Optional[Embed]) – The new embed to replace the original with. This cannot be mixed with the embeds parameter. Could be None to remove the embed.

  • embeds (List[Embed]) – The new embeds to replace the original with. Must be a maximum of 10. This cannot be mixed with the embed parameter. To remove all embeds [] should be passed.

  • file (File) – The file to upload. This cannot be mixed with the files parameter. Files will be appended to the message, see the attachments parameter to remove/replace existing files.

  • files (List[File]) – A list of files to upload. This cannot be mixed with the file parameter. Files will be appended to the message, see the attachments parameter to remove/replace existing files.

  • attachments (Optional[List[Attachment]]) –

    A list of attachments to keep in the message. If [] or None is passed then all existing attachments are removed. Keeps existing attachments if not provided.

    New in version 2.2.

    Changed in version 2.5: Supports passing None to clear attachments.

  • view (Optional[View]) – The updated view to update this message with. This cannot be mixed with components. If None is passed then the view is removed.

  • components (Optional[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[disnake.ui.WrappedComponent]]]]]) –

    A list of components to update this message with. This cannot be mixed with view. If None is passed then the components are removed.

    New in version 2.4.

  • allowed_mentions (AllowedMentions) – Controls the mentions being processed in this message. See abc.Messageable.send() for more information.

  • suppress_embeds (bool) –

    Whether to suppress embeds for the message. This hides all the embeds from the UI if set to True. If set to False, this brings the embeds back if they were suppressed.

    New in version 2.7.

  • flags (MessageFlags) –

    The new flags to set for this message. Overrides existing flags. Only suppress_embeds is supported.

    If parameter suppress_embeds is provided, that will override the setting of MessageFlags.suppress_embeds.

    New in version 2.9.

Raises:
  • HTTPException – Editing the message failed.

  • Forbidden – Edited a message that is not yours.

  • TypeError – You specified both embed and embeds or file and files

  • ValueError – The length of embeds was invalid.

Returns:

The newly edited message.

Return type:

InteractionMessage

expires_at

Returns the interaction’s expiration time in UTC.

This is exactly 15 minutes after the interaction was created.

New in version 2.5.

Type:

datetime.datetime

followup

Returns the follow up webhook for follow up interactions.

Type:

Webhook

property guild[source]

The guild the interaction was sent from.

Type:

Optional[Guild]

is_expired()[source]

Whether the interaction can still be used to make requests to Discord.

This does not take into account the 3 second limit for the initial response.

New in version 2.5.

Return type:

bool

me

Union[Member, ClientUser]: Similar to Guild.me except it may return the ClientUser in private message contexts.

await original_response()[source]

This function is a coroutine.

Fetches the original interaction response message associated with the interaction.

Here is a table with response types and their associated original response:

Response type

Original response

InteractionResponse.send_message()

The message you sent

InteractionResponse.edit_message()

The message you edited

InteractionResponse.defer()

The message with thinking state (bot is thinking…)

Other response types

None

Repeated calls to this will return a cached value.

Changed in version 2.6: This function was renamed from original_message.

Raises:

HTTPException – Fetching the original response message failed.

Returns:

The original interaction response message.

Return type:

InteractionMessage

property permissions[source]

The resolved permissions of the member in the channel, including overwrites.

In a guild context, this is provided directly by Discord.

In a non-guild context this will be an instance of Permissions.private_channel().

Type:

Permissions

response

Returns an object responsible for handling responding to the interaction.

A response can only be done once. If secondary messages need to be sent, consider using followup instead.

Type:

InteractionResponse

await send(content=None, *, embed=..., embeds=..., file=..., files=..., allowed_mentions=..., view=..., components=..., tts=False, ephemeral=..., suppress_embeds=..., flags=..., delete_after=...)[source]

This function is a coroutine.

Sends a message using either response.send_message or followup.send.

If the interaction hasn’t been responded to yet, this method will call response.send_message. Otherwise, it will call followup.send.

Note

This method does not return a Message object. If you need a message object, use original_response() to fetch it, or use followup.send directly instead of this method if you’re sending a followup message.

Parameters:
  • content (Optional[str]) – The content of the message to send.

  • embed (Embed) – The rich embed for the content to send. This cannot be mixed with the embeds parameter.

  • embeds (List[Embed]) – A list of embeds to send with the content. Must be a maximum of 10. This cannot be mixed with the embed parameter.

  • file (File) – The file to upload. This cannot be mixed with the files parameter.

  • files (List[File]) – A list of files to upload. Must be a maximum of 10. This cannot be mixed with the file parameter.

  • allowed_mentions (AllowedMentions) – Controls the mentions being processed in this message. If this is passed, then the object is merged with Client.allowed_mentions. The merging behaviour only overrides attributes that have been explicitly passed to the object, otherwise it uses the attributes set in Client.allowed_mentions. If no object is passed at all then the defaults given by Client.allowed_mentions are used instead.

  • tts (bool) – Whether the message should be sent using text-to-speech.

  • view (disnake.ui.View) – The view to send with the message. This cannot be mixed with components.

  • components (Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[disnake.ui.WrappedComponent]]]]) –

    A list of components to send with the message. This cannot be mixed with view.

    New in version 2.4.

  • ephemeral (bool) – Whether the message should only be visible to the user who started the interaction. If a view is sent with an ephemeral message and it has no timeout set then the timeout is set to 15 minutes.

  • suppress_embeds (bool) –

    Whether to suppress embeds for the message. This hides all the embeds from the UI if set to True.

    New in version 2.5.

  • flags (MessageFlags) –

    The flags to set for this message. Only suppress_embeds, ephemeral and suppress_notifications are supported.

    If parameters suppress_embeds or ephemeral are provided, they will override the corresponding setting of this flags parameter.

    New in version 2.9.

  • delete_after (float) –

    If provided, the number of seconds to wait in the background before deleting the message we just sent. If the deletion fails, then it is silently ignored.

    Can be up to 15 minutes after the interaction was created (see also expires_at/is_expired).

    Changed in version 2.7: Added support for ephemeral responses.

Raises:
property user[source]

The user or member that sent the interaction. There is an alias for this named author.

Type:

Union[User, Member]

InteractionResponse

Attributes
Methods
class disnake.InteractionResponse[source]

Represents a Discord interaction response.

This type can be accessed through Interaction.response.

New in version 2.0.

property type[source]

If a response was successfully made, this is the type of the response.

New in version 2.6.

Type:

Optional[InteractionResponseType]

is_done()[source]

Whether an interaction response has been done before.

An interaction can only be responded to once.

Return type:

bool

await defer(*, with_message=..., ephemeral=...)[source]

This function is a coroutine.

Defers the interaction response.

This is typically used when the interaction is acknowledged and a secondary action will be done later.

Changed in version 2.5: Raises TypeError when an interaction cannot be deferred.

Parameters:
Raises:
await pong()[source]

This function is a coroutine.

Pongs the ping interaction.

This should rarely be used.

Raises:
await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., allowed_mentions=..., view=..., components=..., tts=False, ephemeral=..., suppress_embeds=..., flags=..., delete_after=...)[source]

This function is a coroutine.

Responds to this interaction by sending a message.

Parameters:
  • content (Optional[str]) – The content of the message to send.

  • embed (Embed) – The rich embed for the content to send. This cannot be mixed with the embeds parameter.

  • embeds (List[Embed]) – A list of embeds to send with the content. Must be a maximum of 10. This cannot be mixed with the embed parameter.

  • file (File) – The file to upload. This cannot be mixed with the files parameter.

  • files (List[File]) – A list of files to upload. Must be a maximum of 10. This cannot be mixed with the file parameter.

  • allowed_mentions (AllowedMentions) – Controls the mentions being processed in this message.

  • view (disnake.ui.View) – The view to send with the message. This cannot be mixed with components.

  • components (Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[disnake.ui.WrappedComponent]]]]) –

    A list of components to send with the message. This cannot be mixed with view.

    New in version 2.4.

  • tts (bool) – Whether the message should be sent using text-to-speech.

  • ephemeral (bool) – Whether the message should only be visible to the user who started the interaction. If a view is sent with an ephemeral message and it has no timeout set then the timeout is set to 15 minutes.

  • delete_after (float) –

    If provided, the number of seconds to wait in the background before deleting the message we just sent. If the deletion fails, then it is silently ignored.

    Can be up to 15 minutes after the interaction was created (see also Interaction.expires_at/is_expired).

    Changed in version 2.7: Added support for ephemeral responses.

  • suppress_embeds (bool) –

    Whether to suppress embeds for the message. This hides all the embeds from the UI if set to True.

    New in version 2.5.

  • flags (MessageFlags) –

    The flags to set for this message. Only suppress_embeds, ephemeral and suppress_notifications are supported.

    If parameters suppress_embeds or ephemeral are provided, they will override the corresponding setting of this flags parameter.

    New in version 2.9.

Raises:
await edit_message(content=..., *, embed=..., embeds=..., file=..., files=..., attachments=..., allowed_mentions=..., view=..., components=...)[source]

This function is a coroutine.

Responds to this interaction by editing the original message of a component interaction or modal interaction (if the modal was sent in response to a component interaction).

Changed in version 2.5: Now supports editing the original message of modal interactions that started from a component.

Note

If the original message has embeds with images that were created from local files (using the file parameter with Embed.set_image() or Embed.set_thumbnail()), those images will be removed if the message’s attachments are edited in any way (i.e. by setting file/files/attachments, or adding an embed with local files).

Parameters:
  • content (Optional[str]) – The new content to replace the message with. None removes the content.

  • embed (Optional[Embed]) – The new embed to replace the original with. This cannot be mixed with the embeds parameter. Could be None to remove the embed.

  • embeds (List[Embed]) – The new embeds to replace the original with. Must be a maximum of 10. This cannot be mixed with the embed parameter. To remove all embeds [] should be passed.

  • file (File) –

    The file to upload. This cannot be mixed with the files parameter. Files will be appended to the message.

    New in version 2.2.

  • files (List[File]) –

    A list of files to upload. This cannot be mixed with the file parameter. Files will be appended to the message.

    New in version 2.2.

  • attachments (Optional[List[Attachment]]) –

    A list of attachments to keep in the message. If [] or None is passed then all existing attachments are removed. Keeps existing attachments if not provided.

    New in version 2.4.

    Changed in version 2.5: Supports passing None to clear attachments.

  • allowed_mentions (AllowedMentions) – Controls the mentions being processed in this message.

  • view (Optional[View]) – The updated view to update this message with. This cannot be mixed with components. If None is passed then the view is removed.

  • components (Optional[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[disnake.ui.WrappedComponent]]]]]) –

    A list of components to update this message with. This cannot be mixed with view. If None is passed then the components are removed.

    New in version 2.4.

Raises:
await autocomplete(*, choices)[source]

This function is a coroutine.

Responds to this interaction by displaying a list of possible autocomplete results. Only works for autocomplete interactions.

Parameters:

choices (Union[List[OptionChoice], List[Union[str, int]], Dict[str, Union[str, int]]]) – The list of choices to suggest.

Raises:
await send_modal(modal=None, *, title=None, custom_id=None, components=None)[source]

This function is a coroutine.

Responds to this interaction by displaying a modal.

New in version 2.4.

Note

Not passing the modal parameter here will not register a callback, and a on_modal_submit() interaction will need to be handled manually.

Parameters:
Raises:

InteractionMessage

class disnake.InteractionMessage[source]

Represents the original interaction response message.

This allows you to edit or delete the message associated with the interaction response. To retrieve this object see Interaction.original_response().

This inherits from disnake.Message with changes to edit() and delete() to work.

New in version 2.0.

type

The type of message.

Type:

MessageType

author

A Member that sent the message. If channel is a private channel, then it is a User instead.

Type:

Union[Member, abc.User]

content

The actual contents of the message.

Type:

str

embeds

A list of embeds the message has.

Type:

List[Embed]

channel

The channel that the message was sent from. Could be a DMChannel or GroupChannel if it’s a private message.

Type:

Union[TextChannel, VoiceChannel, StageChannel, Thread, DMChannel, GroupChannel, PartialMessageable]

reference

The message that this message references. This is only applicable to message replies.

Type:

Optional[MessageReference]

interaction

The interaction that this message references. This exists only when the message is a response to an interaction without an existing message.

New in version 2.1.

Type:

Optional[InteractionReference]

mention_everyone

Specifies if the message mentions everyone.

Note

This does not check if the @everyone or the @here text is in the message itself. Rather this boolean indicates if either the @everyone or the @here text is in the message and it did end up mentioning.

Type:

bool

mentions

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

Type:

List[abc.User]

role_mentions

A list of Role that were mentioned. If the message is in a private message then the list is always empty.

Type:

List[Role]

id

The message ID.

Type:

int

webhook_id

The ID of the application that sent this message.

Type:

Optional[int]

attachments

A list of attachments given to a message.

Type:

List[Attachment]

pinned

Specifies if the message is currently pinned.

Type:

bool

flags

Extra features of the message.

Type:

MessageFlags

reactions

Reactions to a message. Reactions can be either custom emoji or standard unicode emoji.

Type:

List[Reaction]

stickers

A list of sticker items given to the message.

Type:

List[StickerItem]

components

A list of components in the message.

Type:

List[Component]

guild

The guild that the message belongs to, if applicable.

Type:

Optional[Guild]

await edit(content=..., *, embed=..., embeds=..., file=..., files=..., attachments=..., suppress_embeds=..., flags=..., allowed_mentions=..., view=..., components=...)[source]

This function is a coroutine.

Edits the message.

Note

If the original message has embeds with images that were created from local files (using the file parameter with Embed.set_image() or Embed.set_thumbnail()), those images will be removed if the message’s attachments are edited in any way (i.e. by setting file/files/attachments, or adding an embed with local files).

Parameters:
  • content (Optional[str]) – The content to edit the message with, or None to clear it.

  • embed (Optional[Embed]) – The new embed to replace the original with. This cannot be mixed with the embeds parameter. Could be None to remove the embed.

  • embeds (List[Embed]) – The new embeds to replace the original with. Must be a maximum of 10. This cannot be mixed with the embed parameter. To remove all embeds [] should be passed.

  • file (File) – The file to upload. This cannot be mixed with the files parameter. Files will be appended to the message, see the attachments parameter to remove/replace existing files.

  • files (List[File]) – A list of files to upload. This cannot be mixed with the file parameter. Files will be appended to the message, see the attachments parameter to remove/replace existing files.

  • attachments (Optional[List[Attachment]]) –

    A list of attachments to keep in the message. If [] or None is passed then all existing attachments are removed. Keeps existing attachments if not provided.

    New in version 2.2.

    Changed in version 2.5: Supports passing None to clear attachments.

  • view (Optional[View]) – The updated view to update this message with. This cannot be mixed with components. If None is passed then the view is removed.

  • components (Optional[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[Union[disnake.ui.ActionRow, disnake.ui.WrappedComponent, List[disnake.ui.WrappedComponent]]]]]) –

    A list of components to update this message with. This cannot be mixed with view. If None is passed then the components are removed.

    New in version 2.4.

  • suppress_embeds (bool) –

    Whether to suppress embeds for the message. This hides all the embeds from the UI if set to True. If set to False, this brings the embeds back if they were suppressed.

    New in version 2.7.

  • flags (MessageFlags) –

    The new flags to set for this message. Overrides existing flags. Only suppress_embeds is supported.

    If parameter suppress_embeds is provided, that will override the setting of MessageFlags.suppress_embeds.

    New in version 2.9.

  • allowed_mentions (AllowedMentions) – Controls the mentions being processed in this message. See abc.Messageable.send() for more information.

Raises:
  • HTTPException – Editing the message failed.

  • Forbidden – Edited a message that is not yours.

  • TypeError – You specified both embed and embeds or file and files

  • ValueError – The length of embeds was invalid.

Returns:

The newly edited message.

Return type:

InteractionMessage

await delete(*, delay=None)[source]

This function is a coroutine.

Deletes the message.

Parameters:

delay (Optional[float]) – If provided, the number of seconds to wait before deleting the message. The waiting is done in the background and deletion failures are ignored.

Raises:
  • Forbidden – You do not have proper permissions to delete the message.

  • NotFound – The message was deleted already.

  • HTTPException – Deleting the message failed.

await add_reaction(emoji)[source]

This function is a coroutine.

Adds a reaction to the message.

The emoji may be a unicode emoji or a custom guild Emoji.

You must have the read_message_history permission to use this. If nobody else has reacted to the message using this emoji, the add_reactions permission is required.

Changed in version 2.6: Raises TypeError instead of InvalidArgument.

Parameters:

emoji (Union[Emoji, Reaction, PartialEmoji, str]) – The emoji to react with.

Raises:
  • HTTPException – Adding the reaction failed.

  • Forbidden – You do not have the proper permissions to react to the message.

  • NotFound – The emoji you specified was not found.

  • TypeError – The emoji parameter is invalid.

channel_mentions

A list of abc.GuildChannel that were mentioned. If the message is in a private message then the list is always empty.

Type:

List[abc.GuildChannel]

clean_content

A property that returns the content in a “cleaned up” manner. This basically means that mentions are transformed into the way the client shows it. e.g. <#id> will transform into #name.

This will also transform @everyone and @here mentions into non-mentions.

Note

This does not affect markdown. If you want to escape or remove markdown then use utils.escape_markdown() or utils.remove_markdown() respectively, along with this function.

Type:

str

await clear_reaction(emoji)[source]

This function is a coroutine.

Clears a specific reaction from the message.

The emoji may be a unicode emoji or a custom guild Emoji.

You need the manage_messages permission to use this.

New in version 1.3.

Changed in version 2.6: Raises TypeError instead of InvalidArgument.

Parameters:

emoji (Union[Emoji, Reaction, PartialEmoji, str]) – The emoji to clear.

Raises:
  • HTTPException – Clearing the reaction failed.

  • Forbidden – You do not have the proper permissions to clear the reaction.

  • NotFound – The emoji you specified was not found.

  • TypeError – The emoji parameter is invalid.

await clear_reactions()[source]

This function is a coroutine.

Removes all the reactions from the message.

You need the manage_messages permission to use this.

Raises:
  • HTTPException – Removing the reactions failed.

  • Forbidden – You do not have the proper permissions to remove all the reactions.

await create_thread(*, name, auto_archive_duration=None, slowmode_delay=None, reason=None)[source]

This function is a coroutine.

Creates a public thread from this message.

You must have create_public_threads in order to create a public thread from a message.

The channel this message belongs in must be a TextChannel.

New in version 2.0.

Changed in version 2.6: Raises TypeError instead of InvalidArgument.

Parameters:
  • name (str) – The name of the thread.

  • auto_archive_duration (Union[int, ThreadArchiveDuration]) – The duration in minutes before a thread is automatically archived for inactivity. If not provided, the channel’s default auto archive duration is used. Must be one of 60, 1440, 4320, or 10080.

  • slowmode_delay (Optional[int]) –

    Specifies the slowmode rate limit for users in this thread, in seconds. A value of 0 disables slowmode. The maximum value possible is 21600. If set to None or not provided, slowmode is inherited from the parent’s default_thread_slowmode_delay.

    New in version 2.3.

  • reason (Optional[str]) –

    The reason for creating the thread. Shows up on the audit log.

    New in version 2.5.

Raises:
  • Forbidden – You do not have permissions to create a thread.

  • HTTPException – Creating the thread failed.

  • TypeError – This message does not have guild info attached.

Returns:

The created thread.

Return type:

Thread

property created_at[source]

The message’s creation time in UTC.

Type:

datetime.datetime

property edited_at[source]

An aware UTC datetime object containing the edited time of the message.

Type:

Optional[datetime.datetime]

is_system()[source]

Whether the message is a system message.

A system message is a message that is constructed entirely by the Discord API in response to something.

New in version 1.3.

Return type:

bool

property jump_url[source]

Returns a URL that allows the client to jump to this message.

Type:

str

await pin(*, reason=None)[source]

This function is a coroutine.

Pins the message.

You must have the manage_messages permission to do this in a non-private channel context.

This does not work with messages sent in a VoiceChannel or StageChannel.

Parameters:

reason (Optional[str]) –

The reason for pinning the message. Shows up on the audit log.

New in version 1.4.

Raises:
  • Forbidden – You do not have permissions to pin the message.

  • NotFound – The message or channel was not found or deleted.

  • HTTPException – Pinning the message failed, probably due to the channel having more than 50 pinned messages or the channel not supporting pins.

await publish()[source]

This function is a coroutine.

Publishes this message to your announcement channel.

You must have the send_messages permission to do this.

If the message is not your own then the manage_messages permission is also needed.

Raises:
  • Forbidden – You do not have the proper permissions to publish this message.

  • HTTPException – Publishing the message failed.

raw_channel_mentions

A property that returns an array of channel IDs matched with the syntax of <#channel_id> in the message content.

Type:

List[int]

raw_mentions

A property that returns an array of user IDs matched with the syntax of <@user_id> in the message content.

This allows you to receive the user IDs of mentioned users even in a private message context.

Type:

List[int]

raw_role_mentions

A property that returns an array of role IDs matched with the syntax of <@&role_id> in the message content.

Type:

List[int]

await remove_reaction(emoji, member)[source]

This function is a coroutine.

Removes a reaction by the member from the message.

The emoji may be a unicode emoji or a custom guild Emoji.

If the reaction is not your own (i.e. member parameter is not you) then the manage_messages permission is needed.

The member parameter must represent a member and meet the abc.Snowflake abc.

Changed in version 2.6: Raises TypeError instead of InvalidArgument.

Parameters:
Raises:
  • HTTPException – Removing the reaction failed.

  • Forbidden – You do not have the proper permissions to remove the reaction.

  • NotFound – The member or emoji you specified was not found.

  • TypeError – The emoji parameter is invalid.

await reply(content=None, *, fail_if_not_exists=True, **kwargs)[source]

This function is a coroutine.

A shortcut method to abc.Messageable.send() to reply to the Message.

New in version 1.6.

Changed in version 2.3: Added fail_if_not_exists keyword argument. Defaults to True.

Changed in version 2.6: Raises TypeError or ValueError instead of InvalidArgument.

Parameters:

fail_if_not_exists (bool) –

Whether replying using the message reference should raise HTTPException if the message no longer exists or Discord could not fetch the message.

New in version 2.3.

Raises:
  • HTTPException – Sending the message failed.

  • Forbidden – You do not have the proper permissions to send the message.

  • TypeError – You specified both embed and embeds, or file and files, or view and components.

  • ValueError – The files or embeds list is too large.

Returns:

The message that was sent.

Return type:

Message

system_content

A property that returns the content that is rendered regardless of the Message.type.

In the case of MessageType.default and MessageType.reply, this just returns the regular Message.content. Otherwise this returns an English message denoting the contents of the system message.

If the message type is unrecognised this method will return None.

Type:

Optional[str]

property thread[source]

The thread started from this message. None if no thread has been started.

New in version 2.4.

Type:

Optional[Thread]

to_reference(*, fail_if_not_exists=True)[source]

Creates a MessageReference from the current message.

New in version 1.6.

Parameters:

fail_if_not_exists (bool) –

Whether replying using the message reference should raise HTTPException if the message no longer exists or Discord could not fetch the message.

New in version 1.7.

Returns:

The reference to this message.

Return type:

MessageReference

await unpin(*, reason=None)[source]

This function is a coroutine.

Unpins the message.

You must have the manage_messages permission to do this in a non-private channel context.

Parameters:

reason (Optional[str]) –

The reason for unpinning the message. Shows up on the audit log.

New in version 1.4.

Raises:
  • Forbidden – You do not have permissions to unpin the message.

  • NotFound – The message or channel was not found or deleted.

  • HTTPException – Unpinning the message failed.

InteractionDataResolved

class disnake.InteractionDataResolved[source]

Represents the resolved data related to an interaction.

New in version 2.1.

Changed in version 2.7: Renamed from ApplicationCommandInteractionDataResolved to InteractionDataResolved.

members

A mapping of IDs to partial members (deaf and mute attributes are missing).

Type:

Dict[int, Member]

users

A mapping of IDs to users.

Type:

Dict[int, User]

roles

A mapping of IDs to roles.

Type:

Dict[int, Role]

channels

A mapping of IDs to partial channels (only id, name and permissions are included, threads also have thread_metadata and parent_id).

Type:

Dict[int, Union[abc.GuildChannel, Thread, PartialMessageable]]

messages

A mapping of IDs to messages.

Type:

Dict[int, Message]

attachments

A mapping of IDs to attachments.

New in version 2.4.

Type:

Dict[int, Attachment]

ApplicationCommandInteractionData

class disnake.ApplicationCommandInteractionData[source]

Represents the data of an interaction with an application command.

New in version 2.1.

id

The application command ID.

Type:

int

name

The application command name.

Type:

str

type

The application command type.

Type:

ApplicationCommandType

resolved

All resolved objects related to this interaction.

Type:

InteractionDataResolved

options

A list of options from the API.

Type:

List[ApplicationCommandInteractionDataOption]

target_id

ID of the user or message targetted by a user or message command

Type:

int

target

The user or message targetted by a user or message command

Type:

Union[User, Member, Message]

property focused_option[source]

The focused option

ApplicationCommandInteractionDataOption

class disnake.ApplicationCommandInteractionDataOption[source]

Represents the structure of an interaction data option from the API.

name

The option’s name.

Type:

str

type

The option’s type.

Type:

OptionType

value

The option’s value.

Type:

Any

options

The list of options of this option. Only exists for subcommands and groups.

Type:

List[ApplicationCommandInteractionDataOption]

focused

Whether this option is focused by the user. May be True in autocomplete interactions.

Type:

bool

MessageInteractionData

class disnake.MessageInteractionData[source]

Represents the data of an interaction with a message component.

New in version 2.1.

custom_id

The custom ID of the component.

Type:

str

component_type

The type of the component.

Type:

ComponentType

values

The values the user has selected in a select menu. For non-string select menus, this contains IDs for use with resolved.

Type:

Optional[List[str]]

resolved

All resolved objects related to this interaction.

New in version 2.7.

Type:

InteractionDataResolved

ModalInteractionData

Attributes
class disnake.ModalInteractionData[source]

Represents the data of an interaction with a modal.

New in version 2.4.

custom_id

The custom ID of the modal.

Type:

str

components

The raw component data of the modal interaction, as provided by Discord. This does not contain all fields of the components due to API limitations.

New in version 2.6.

Type:

List[dict]

Enumerations

InteractionType

class disnake.InteractionType[source]

Specifies the type of Interaction.

New in version 2.0.

ping

Represents Discord pinging to see if the interaction response server is alive.

application_command

Represents an application command interaction.

component

Represents a component based interaction, i.e. using the Discord Bot UI Kit.

application_command_autocomplete

Represents an application command autocomplete interaction.

modal_submit

Represents a modal submit interaction.

InteractionResponseType

class disnake.InteractionResponseType[source]

Specifies the response type for the interaction.

New in version 2.0.

pong

Pongs the interaction when given a ping.

See also InteractionResponse.pong()

channel_message

Respond to the interaction with a message.

See also InteractionResponse.send_message()

deferred_channel_message

Responds to the interaction with a message at a later time.

See also InteractionResponse.defer()

deferred_message_update

Acknowledges the component interaction with a promise that the message will update later (though there is no need to actually update the message).

See also InteractionResponse.defer()

message_update

Responds to the interaction by editing the message.

See also InteractionResponse.edit_message()

application_command_autocomplete_result

Responds to the autocomplete interaction with suggested choices.

See also InteractionResponse.autocomplete()

modal

Responds to the interaction by displaying a modal.

See also InteractionResponse.send_modal()

Events