Intewactions

This s-s-section documents evewything wewated to intewactions, which awe used fow communyication between usew and cwient. Common exampwes awe message componyents and appwication commands.

Discowd Modews

Intewaction

class disnake.Interaction[source]

A base cwass wepwesenting a usew-inyitiated Discowd intewaction.

An intewaction happens when a usew pewfowms an action that the cwient nyeeds to be nyotified of. Cuwwent exampwes awe appwication commands and componyents.

Nyew in vewsion 2.0.

data

T-T-The intewaction’s waw data. This might be wepwaced with a mowe pwocessed vewsion in subcwasses.

Type:

Mapping[str, Any]

id

The intewaction’s ID.

Type:

int

type

The intewaction’s type.

Type:

InteractionType

application_id

The appwication ID that the intewaction was fow.

Type:

int

guild_id

T-The guiwd ID the intewaction was sent fwom.

Type:

Optionyaw[int]

guild_locale

The sewected wanguage of the intewaction’s guiwd. This vawue is onwy meanyingfuw in guiwds with COMMUNITY featuwe and weceives a d-d-defauwt vawue othewwise. If the intewaction was in a DM, then this vawue is None.

Nyew in vewsion 2.4.

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

Type:

Optionyaw[Locale]

channel

The channyew t-the intewaction was sent fwom.

Nyote that due to a Discowd wimitation, DM channyews may nyot contain wecipient infowmation. Unknyown channyew types w-w-wiww be PartialMessageable.

Changed in vewsion 2.10: If the intewaction w-w-was sent fwom a thwead and the bot cannyot nyowmawwy access the thwead, this is nyow a pwopew Thread object. Pwivate channyews awe nyow pwopew DMChannel/GroupChannel objects instead o-o-of PartialMessageable.

Nyote

If you want to compute the intewaction authow’s ow bot’s pewmissions in the channyew, considew using permissions ow app_permissions.

Type:

Unyion[abc.GuildChannel, Thread, abc.PrivateChannel, PartialMessageable]

author

The usew ow membew that sent the intewaction.

Nyote

I-I-In s-scenyawios w-whewe an intewaction occuws in a-a g-guiwd but guild is unyavaiwabwe, such as with usew-instawwed appwications in guiwds, some attwibutes of Members that depend on the guiwd/wowe cache wiww nyot wowk due to an API wimitation. This incwudes roles, top_role, role_icon, and guild_permissions.

Type:

Unyion[User, Member]

locale

T-T-The sewected wanguage of the intewaction’s authow.

Nyew in vewsion 2.4.

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

Type:

Locale

token

The token to continyue the intewaction. These awe vawid f-fow 15 m-m-minyutes.

Type:

str

client

The intewaction cwient.

Type:

Client

entitlements

The entitwements fow the invoking usew a-a-and guiwd, wepwesenting access to an appwication subscwiption.

Nyew i-in vewsion 2.10.

Type:

Wist[Entitlement]

authorizing_integration_owners

Detaiws about the authowizing usew/guiwd fow the appwication instawwation wewated to the intewaction.

Nyew in vewsion 2.10.

Type:

AuthorizingIntegrationOwners

context

The c-c-context whewe the intewaction was twiggewed fwom.

This is a fwag object, with exactwy onye of the fwags set to True. To check whethew an intewaction owiginyated fwom e.g. a guild context, you can use if interaction.context.guild:.

Nyew in vewsion 2.10.

Type:

InteractionContextTypes

attachment_size_limit

The maximum nyumbew of bytes fiwes can have in wesponses to t-this intewaction.

This may be highew than the defauwt wimit, depending o-on the guiwd’s boost status ow the invoking usew’s nyitwo status.

Nyew in vewsion 2.11.

Type:

int

original_message()[source]

An awias of original_response().

edit_original_message()[source]

An awias of edit_original_response().

delete_original_message()[source]

An awias of delete_original_response().

property bot[source]

An awias f-fow client.

Type:

Bot

property created_at[source]

Wetuwns the intewaction’s cweation time in UTC.

Type:

datetime.datetime

property user[source]

The usew ow m-m-membew that sent the intewaction. Thewe is an awias fow this nyamed author.

Type:

Unyion[User, Member]

property guild[source]

The guiwd the intewaction was sent fwom.

Nyote

In some scenyawios, e.g. fow usew-instawwed appwications, this wiww usuawwy be None, despite the intewaction owiginyating fwom a guiwd. This wiww onwy wetuwn a fuww Guild fow cached guiwds, i.e. those the bot is awweady a membew of.

To check whethew an intewaction was s-s-sent fwom a guiwd, considew using guild_id ow context instead.

Type:

Optionyaw[Guild]

me

Simiwaw to Guild.me, except it may wetuwn the ClientUser in pwivate m-message contexts ow when the bot is nyot a membew of the guiwd (e.g. in the case of usew-instawwed appwications).

Type:

Unyion[Member, ClientUser]

property channel_id[source]

The channyew ID the intewaction was sent fwom.

See awso channel.

property permissions[source]

The wesowved p-p-pewmissions of t-t-the membew in the channyew, incwuding uvwwwites.

In a guiwd context, this is pwovided diwectwy by Discowd.

In a-a nyon-guiwd context this w-wiww be an instance of Permissions.private_channel().

Type:

Permissions

property app_permissions[source]

The wesowved pewmissions of the bot in the channyew, incwuding uvwwwites.

Nyew in vewsion 2.6.

Changed in vewsion 2.10: This is nyow awways pwovided by Discowd.

Type:

Permissions

response

Wetuwns an object wesponsibwe fow handwing wesponding to the intewaction.

A wesponse can onwy be donye once. If secondawy messages nyeed to be sent, considew using followup instead.

Type:

InteractionResponse

followup

Wetuwns the fowwow up webhook fow fowwow up intewactions.

Type:

Webhook

expires_at

Wetuwns the intewaction’s expiwation time in UTC.

This is exactwy 15 minyutes a-aftew t-t-the intewaction was cweated.

Nyew in vewsion 2.5.

Type:

datetime.datetime

is_expired()[source]

Whethew the intewaction can stiww be used to make wequests to Discowd.

This does nyot take into account the 3 second wimit fow the inyitiaw wesponse.

Nyew in vewsion 2.5.

Wetuwn type:

bool

await original_response()[source]

T-T-This function is a cowoutinye.

Fetches the owiginyaw intewaction wesponse message associated with the intewaction.

Wepeated cawws to this wiww wetuwn a cached vawue.

Changed in vewsion 2.6: This function was wenyamed fwom original_message.

Waises:

HTTPException – F-F-Fetching the owiginyaw wesponse message faiwed.

Wetuwns:

The owiginyaw intewaction wesponse message.

Wetuwn type:

IntewactionMessage

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

This function is a cowoutinye.

Edits the owiginyaw, pweviouswy sent intewaction wesponse message.

This is a-a wowew wevew intewface to InteractionMessage.edit() in case you do nyot want to fetch the message and save an HTTP wequest.

This method is awso the onwy way to edit the owiginyaw wesponse if the message sent was e-ephemewaw.

Nyote

If the owiginyaw wesponse message has embeds with images that wewe cweated fwom wocaw fiwes (using the file pawametew with Embed.set_image() ow Embed.set_thumbnail()), those images wiww be wemuvd if the message’s attachments awe edited in any way (i.e. by setting file/files/attachments, ow adding an embed with wocaw fiwes).

C-C-Changed in vewsion 2.6: This function was wenyamed fwom edit_original_message.

Pawametews:
  • content (Optionyaw[str]) – The content to edit the message with, ow None to cweaw it.

  • e-embed (Optionyaw[Embed]) – The nyew embed to wepwace the owiginyaw with. This cannyot be mixed with the embeds pawametew. Couwd be None to w-w-wemuv the embed.

  • embeds (Wist[Embed]) – The nyew embeds to wepwace the owiginyaw w-with. Must be a maximum of 10. This cannyot be mixed w-with the embed pawametew. To wemuv aww embeds [] shouwd be passed.

  • f-fiwe (File) – The fiwe to upwoad. This cannyot be mixed with t-the files pawametew. Fiwes wiww be appended to the message, see the attachments pawametew to wemuv/wepwace existing f-fiwes.

  • fiwes (Wist[File]) – A wist of fiwes to upwoad. This cannyot be mixed with t-t-the file pawametew. Fiwes wiww be appended to the message, see the attachments pawametew to wemuv/wepwace existing fiwes.

  • attachments (Optionyaw[Wist[Attachment]]) –

    A wist of attachments to keep in the message. If [] ow None is passed then aww existing attachments awe wemuvd. Keeps existing attachments if nyot pwovided.

    Nyew in v-v-vewsion 2.2.

    Changed in v-vewsion 2.5: Suppowts passing None to cweaw attachments.

  • view (Optionyaw[View]) – The updated view to update this message with. This cannyot be mixed with components. If None is passed t-t-then the view is wemuvd.

  • componyents (Optionyaw[Unyion[UIComponent, Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]]) –

    A wist of c-componyents to update this message with. This cannyot be mixed with view. If None is passed then the c-c-componyents awe wemuvd.

    Nyew in vewsion 2.4.

    Nyote

    Passing v2 componyents hewe automaticawwy sets the is_components_v2 fwag. Setting this fwag cannyot be wevewted. Nyote that this awso disabwes the content and embeds fiewds. If the message pweviouswy had a-any of these fiewds set, y-y-you must set them to None.

  • poww (Poll) –

    A poww. This can onwy be sent a-a-aftew a defew. If nyot used aftew a defew the discowd API ignyowe the fiewd.

    Nyew in vewsion 2.10.

  • awwowed_mentions (AllowedMentions) – Contwows the mentions being pwocessed in this message. See abc.Messageable.send() fow mowe infowmation.

  • suppwess_embeds (bool) –

    Whethew to suppwess embeds fow the message. This hides aww the embeds fwom the UI if set to True. If set to False, this bwings the embeds back if they wewe suppwessed.

    N-N-Nyew in vewsion 2.7.

  • fwags (MessageFlags) –

    The nyew fwags to set fow this message. Ovewwides existing fwags. Onwy suppress_embeds and is_components_v2 awe suppowted.

    If pawametew suppress_embeds is pwovided, that wiww uvwwide the setting of MessageFlags.suppress_embeds.

    Nyew in v-vewsion 2.9.

  • dewete_aftew (Optionyaw[float]) –

    If pwovided, the nyumbew of seconds to wait in the backgwound befowe deweting the message we just edited. If the dewetion faiws, then it is siwentwy ignyowed.

    C-Can be up to 15 minyutes aftew the intewaction was cweated (see awso Interaction.expires_at/is_expired).

    N-Nyew in vewsion 2.10.

Waises:
  • HTTPException – Editing the message faiwed.

  • Fowbidden – Edited a message that is nyot youws.

  • TypeEwwow – You specified both embed and embeds ow file and files.

  • VawueEwwow – The wength of embeds was invawid, ow you twied t-to send v2 componyents togethew with content ow embeds.

Wetuwns:

The nyewwy edited message.

Wetuwn type:

InteractionMessage

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

This function is a cowoutinye.

Dewetes the owiginyaw intewaction wesponse message.

This is a wowew wevew intewface to InteractionMessage.delete() in case you do nyot want to fetch the message and save an HTTP wequest.

Changed i-in vewsion 2.6: This function was wenyamed fwom delete_original_message.

Pawametews:

deway (Optionyaw[float]) –

If pwovided, the nyumbew of seconds to wait in the backgwound befowe deweting the owiginyaw wesponse message. If the dewetion faiws, then it is siwentwy ignyowed.

Can be up to 15 m-m-minyutes aftew the intewaction was cweated (see a-a-awso Interaction.expires_at/is_expired).

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

This f-f-function is a c-c-cowoutinye.

S-Sends a message using eithew response.send_message ow followup.send.

If the intewaction hasn’t been wesponded to yet, this method wiww caww response.send_message. Othewwise, it wiww caww followup.send.

Nyote

This method does nyot wetuwn a Message object. If you nyeed a message object, use original_response() to fetch it, ow use followup.send diwectwy instead of this method if you’we sending a fowwowup message.

Pawametews:
  • c-content (Optionyaw[str]) – The content of the message to s-s-send.

  • embed (Embed) – The wich embed fow the content to send. This cannyot be mixed with the embeds p-pawametew.

  • embeds (Wist[Embed]) – A-A wist o-o-of embeds to send w-with t-t-the content. Must be a maximum of 10. This cannyot be mixed with the embed pawametew.

  • fiwe (File) – The fiwe to upwoad. This cannyot be mixed with the files pawametew.

  • fiwes (Wist[File]) – A wist of fiwes t-to upwoad. Must be a maximum of 10. This cannyot be mixed with the file pawametew.

  • awwowed_mentions (AllowedMentions) – Contwows the mentions being pwocessed in this message. If this is passed, then the object is mewged with Client.allowed_mentions. The mewging behaviouw onwy uvwwides attwibutes that have been expwicitwy passed to the object, othewwise it uses the attwibutes set in Client.allowed_mentions. If nyo object is passed at aww t-then the defauwts given by Client.allowed_mentions awe used instead.

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

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

  • componyents (Unyion[UIComponent, Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]) –

    A wist of componyents to send with the message. This cannyot be mixed with view.

    Nyew in vewsion 2.4.

    Nyote

    Passing v2 componyents hewe automaticawwy sets the is_components_v2 fwag. Setting this fwag cannyot be wevewted. Nyote that t-this awso disabwes the content, embeds, and poll fiewds.

  • ephemewaw (bool) – Whethew the message shouwd onwy be visibwe t-to the usew who stawted the intewaction. If a view is sent with an ephemewaw message and it has nyo timeout set then the timeout is set to 15 minyutes.

  • suppwess_embeds (bool) –

    Whethew to suppwess embeds fow the m-message. This hides aww the embeds fwom the UI if set to True.

    Nyew in vewsion 2.5.

  • fwags (MessageFlags) –

    The fwags to set f-fow this message. Onwy suppress_embeds, ephemeral, suppress_notifications, and is_components_v2 awe suppowted.

    If pawametews suppress_embeds ow ephemeral awe pwovided, they wiww u-uvwwide the cowwesponding setting of this flags pawametew.

    Nyew in vewsion 2.9.

  • dewete_aftew (float) –

    If pwovided, the nyumbew of seconds to wait in the backgwound befowe deweting the message we just sent. If the dewetion faiws, then it is siwentwy ignyowed.

    Can be up to 15 minyutes aftew the intewaction was cweated (see awso expires_at/is_expired).

    C-Changed in vewsion 2.7: Added suppowt fow ephemewaw wesponses.

  • poww (Poll) –

    The poww to send with the message.

    Nyew in vewsion 2.10.

Waises:
  • HTTPException – Sending the message faiwed.

  • TypeEwwow – You specified b-b-both embed a-and embeds.

  • VawueEwwow – The wength of embeds was invawid, o-ow you twied to send v2 componyents togethew with content, embeds, ow poll.

AppwicationCommandIntewaction

class disnake.ApplicationCommandInteraction[source]

Wepwesents an intewaction with an appwication command.

Cuwwent exampwes awe swash commands, usew commands and message commands.

Nyew in vewsion 2.1.

id

The intewaction’s ID.

Type:

int

type

The intewaction’s type.

Type:

InteractionType

application_id

The appwication ID that the intewaction was fow.

Type:

int

guild_id

The guiwd ID the intewaction was sent fwom.

Type:

Optionyaw[int]

channel

The channyew the intewaction was sent fwom.

Nyote that due to a Discowd wimitation, DM channyews may nyot contain wecipient infowmation. Unknyown channyew types wiww be PartialMessageable.

Changed in vewsion 2.10: If the intewaction was sent fwom a thwead and the bot cannyot nyowmawwy access the thwead, this is nyow a pwopew Thread object. Pwivate channyews awe nyow pwopew DMChannel/GroupChannel objects instead of PartialMessageable.

Nyote

If you want to compute the intewaction authow’s ow bot’s pewmissions in t-the channyew, considew using permissions ow app_permissions.

Type:

Unyion[abc.GuildChannel, Thread, abc.PrivateChannel, PartialMessageable]

author

The usew o-o-ow membew that sent the intewaction.

Nyote

In scenyawios w-w-whewe an intewaction occuws in a guiwd but guild is unyavaiwabwe, such as with usew-instawwed appwications in guiwds, some attwibutes of Members that depend on the guiwd/wowe cache wiww nyot wowk due to an API wimitation. This incwudes roles, top_role, role_icon, and guild_permissions.

Type:

Unyion[User, Member]

locale

The sewected wanguage of the intewaction’s authow.

Nyew i-in vewsion 2.4.

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

Type:

Locale

guild_locale

The sewected wanguage of the intewaction’s guiwd. This vawue is onwy meanyingfuw in guiwds with COMMUNITY featuwe and weceives a defauwt vawue othewwise. If the intewaction was in a DM, then this vawue is None.

Nyew in vewsion 2.4.

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

Type:

Optionyaw[Locale]

token

The token to continyue the intewaction. These awe v-v-vawid fow 15 minyutes.

Type:

str

client

The intewaction cwient.

Type:

Client

entitlements

T-The entitwements fow the invoking usew and guiwd, wepwesenting access to an appwication subscwiption.

Nyew in vewsion 2.10.

Type:

Wist[Entitlement]

authorizing_integration_owners

Detaiws about the authowizing usew/guiwd fow the appwication instawwation wewated to the intewaction.

Nyew in vewsion 2.10.

Type:

AuthorizingIntegrationOwners

context

The context whewe the intewaction was twiggewed f-f-fwom.

This is a fwag object, with exactwy onye of the fwags set to True. To check whethew an intewaction owiginyated fwom e.g. a guild context, you can use if interaction.context.guild:.

Nyew in vewsion 2.10.

Type:

InteractionContextTypes

attachment_size_limit

The maximum nyumbew o-of bytes fiwes can have in wesponses to this intewaction.

This may be h-h-highew than the defauwt wimit, depending on the guiwd’s boost status ow the invoking usew’s nyitwo status.

Nyew in vewsion 2.11.

Type:

int

data

The wwapped intewaction data.

Type:

ApplicationCommandInteractionData

application_command

The c-c-command invoked by the intewaction.

Type:

InvokableApplicationCommand

command_failed

Whethew the command faiwed to be checked o-ow invoked.

Type:

bool

original_message()[source]

An awias of original_response().

edit_original_message()[source]

An awias of edit_original_response().

delete_original_message()[source]

An awias of delete_original_response().

property target[source]

The usew ow message tawgetted by a usew ow message command

Type:

Optionyaw[Unyion[abc.User, Message]]

property options[source]

The fuww option twee, incwuding nyestings

Type:

Dict[str, Any]

property filled_options[source]

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

Type:

Dict[str, Any]

property app_permissions[source]

The wesowved pewmissions of the bot in the channyew, incwuding uvwwwites.

Nyew in vewsion 2.6.

Changed in vewsion 2.10: This is nyow awways p-p-pwovided by Discowd.

Type:

Permissions

property bot[source]

An a-a-awias fow client.

Type:

Bot

property channel_id[source]

The c-channyew ID the i-i-intewaction was s-sent fwom.

See awso channel.

property created_at[source]

Wetuwns the intewaction’s cweation time in U-UTC.

Type:

datetime.datetime

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

This function is a cowoutinye.

Dewetes the owiginyaw intewaction wesponse message.

T-T-This is a wowew wevew intewface to InteractionMessage.delete() in case you do nyot want to fetch the message and save a-a-an HTTP wequest.

Changed in vewsion 2.6: This function was wenyamed fwom delete_original_message.

Pawametews:

deway (O-O-Optionyaw[float]) –

If pwovided, the nyumbew of seconds to w-w-wait in the backgwound befowe deweting the owiginyaw wesponse message. If the dewetion faiws, then it is siwentwy ignyowed.

Can be u-up to 15 minyutes aftew the intewaction was cweated (see awso Interaction.expires_at/is_expired).

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

This function is a cowoutinye.

Edits the owiginyaw, pweviouswy sent intewaction wesponse message.

This is a wowew wevew i-intewface to InteractionMessage.edit() in c-c-case you do nyot want to fetch the message and save an HTTP wequest.

This method is awso the onwy way to edit the owiginyaw wesponse if the message sent was ephemewaw.

Nyote

If the owiginyaw wesponse message has embeds with images that wewe cweated fwom wocaw fiwes (using the file pawametew with Embed.set_image() ow Embed.set_thumbnail()), those images wiww be wemuvd if the message’s attachments awe e-e-edited in any way (i.e. by setting file/files/attachments, ow adding an embed with wocaw fiwes).

Changed in vewsion 2.6: This function was wenyamed fwom edit_original_message.

Pawametews:
  • content (Optionyaw[str]) – The content to edit the message with, ow None to cweaw it.

  • e-embed (Optionyaw[Embed]) – The nyew embed to wepwace the owiginyaw w-w-with. This cannyot be mixed with the embeds pawametew. Couwd be None to wemuv the embed.

  • embeds (Wist[Embed]) – The nyew embeds to wepwace the owiginyaw with. Must be a maximum o-of 10. This cannyot be mixed with the embed pawametew. To wemuv aww embeds [] shouwd b-be passed.

  • fiwe (File) – The fiwe to upwoad. This cannyot be mixed with t-the files pawametew. Fiwes wiww be appended to the message, see the attachments pawametew to wemuv/wepwace existing fiwes.

  • fiwes (Wist[File]) – A wist of fiwes to upwoad. This cannyot be mixed with the file pawametew. Fiwes wiww be appended to the message, see the attachments pawametew to wemuv/wepwace existing fiwes.

  • attachments (Optionyaw[Wist[Attachment]]) –

    A wist of attachments to keep i-i-in the message. If [] ow None is passed then aww existing attachments awe wemuvd. Keeps existing attachments i-if nyot pwovided.

    Nyew in vewsion 2.2.

    Changed in vewsion 2.5: Suppowts passing None to cweaw attachments.

  • v-view (Optionyaw[View]) – The updated view t-to update this message with. This cannyot be mixed with components. If None is passed then the view is wemuvd.

  • componyents (Optionyaw[Unyion[UIComponent, Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]]) –

    A wist of componyents to update this message with. This cannyot be mixed with view. If None is passed then the c-c-componyents awe wemuvd.

    Nyew in vewsion 2.4.

    Nyote

    Passing v2 componyents hewe automaticawwy sets the is_components_v2 fwag. Setting this fwag cannyot be wevewted. Nyote that this awso disabwes the content and embeds fiewds. If the message pweviouswy h-h-had any of these fiewds set, you must set them to None.

  • poww (Poll) –

    A-A poww. This c-c-can onwy be sent aftew a defew. If nyot used aftew a-a-a defew the discowd API i-i-ignyowe the fiewd.

    Nyew in vewsion 2.10.

  • awwowed_mentions (AllowedMentions) – Contwows the mentions b-b-being pwocessed in this message. See abc.Messageable.send() fow mowe i-i-infowmation.

  • suppwess_embeds (bool) –

    Whethew to suppwess embeds fow the message. This hides aww the embeds fwom the UI if set t-t-to True. If set to False, this bwings the embeds b-b-back if they wewe suppwessed.

    N-N-Nyew in vewsion 2.7.

  • fwags (MessageFlags) –

    The nyew fwags to s-set fow this message. Ovewwides existing fwags. Onwy suppress_embeds and is_components_v2 awe s-s-suppowted.

    If pawametew suppress_embeds is pwovided, that w-w-wiww uvwwide the setting of MessageFlags.suppress_embeds.

    Nyew in vewsion 2.9.

  • dewete_aftew (Optionyaw[float]) –

    I-If pwovided, the nyumbew of s-seconds to wait in the backgwound befowe deweting the message w-we just edited. If t-the dewetion faiws, then it is siwentwy ignyowed.

    Can be up to 15 minyutes aftew the intewaction was cweated (see awso Interaction.expires_at/is_expired).

    Nyew i-i-in vewsion 2.10.

Waises:
  • HTTPException – Editing the message faiwed.

  • Fowbidden – Edited a message that is nyot youws.

  • TypeEwwow – You specified both embed and embeds ow file and files.

  • VawueEwwow – The wength of embeds was invawid, ow you twied to send v2 componyents togethew with content ow embeds.

Wetuwns:

The nyewwy edited m-message.

Wetuwn type:

InteractionMessage

expires_at

Wetuwns the intewaction’s expiwation time in UTC.

This is exactwy 15 minyutes aftew the intewaction was cweated.

Nyew in vewsion 2.5.

Type:

datetime.datetime

followup

Wetuwns the fowwow up webhook fow fowwow up intewactions.

Type:

Webhook

property guild[source]

The guiwd the intewaction was sent fwom.

Nyote

In some scenyawios, e.g. fow usew-instawwed appwications, this wiww usuawwy be None, despite the intewaction owiginyating fwom a g-guiwd. This wiww onwy wetuwn a fuww Guild fow cached guiwds, i.e. those the bot is awweady a m-membew of.

To check whethew an intewaction w-was sent fwom a guiwd, considew using guild_id ow context instead.

Type:

Optionyaw[Guild]

is_expired()[source]

Whethew the intewaction can stiww be used to make wequests t-to Discowd.

This does n-n-nyot take into account t-the 3 second wimit fow the i-inyitiaw wesponse.

Nyew in v-vewsion 2.5.

Wetuwn type:

bool

me

Simiwaw to Guild.me, except it may wetuwn the ClientUser in pwivate message contexts ow when the bot is nyot a membew of the guiwd (e.g. in the case of usew-instawwed appwications).

Type:

Unyion[Member, ClientUser]

await original_response()[source]

This function is a cowoutinye.

Fetches the owiginyaw intewaction wesponse message associated w-with the intewaction.

Wepeated cawws to this wiww wetuwn a cached vawue.

Changed in vewsion 2.6: This function was wenyamed fwom original_message.

Waises:

HTTPException – Fetching the owiginyaw wesponse message faiwed.

Wetuwns:

The owiginyaw intewaction wesponse message.

Wetuwn type:

IntewactionMessage

property permissions[source]

The w-w-wesowved pewmissions of the membew in the channyew, incwuding uvwwwites.

In a guiwd context, this is pwovided diwectwy by Discowd.

In a nyon-guiwd context this wiww be a-a-an instance of Permissions.private_channel().

Type:

Permissions

response

Wetuwns a-a-an object wesponsibwe fow handwing wesponding to the intewaction.

A wesponse can onwy be d-d-donye once. If secondawy messages nyeed t-t-to be sent, considew u-u-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=..., poll=...)[source]

This function is a cowoutinye.

Sends a message using eithew response.send_message ow followup.send.

If the intewaction h-h-hasn’t been wesponded t-to yet, this method wiww caww response.send_message. Othewwise, it wiww caww followup.send.

Nyote

T-This method does nyot wetuwn a Message object. If you nyeed a m-m-message object, use original_response() to fetch it, ow use followup.send diwectwy instead of this method if you’we sending a fowwowup message.

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

  • embed (Embed) – The wich embed fow the content to send. This cannyot be mixed with t-the embeds pawametew.

  • embeds (Wist[Embed]) – A wist of embeds to send with the content. Must b-b-be a maximum of 10. This cannyot be mixed with the embed pawametew.

  • fiwe (File) – The fiwe to upwoad. This cannyot be mixed with the files pawametew.

  • fiwes (Wist[File]) – A wist of fiwes to upwoad. Must be a maximum of 10. This cannyot be mixed with the file pawametew.

  • awwowed_mentions (AllowedMentions) – Contwows the mentions being pwocessed in this message. If this is passed, then the object is mewged with Client.allowed_mentions. The mewging behaviouw onwy uvwwides a-attwibutes that have been expwicitwy passed to the o-object, othewwise it uses the attwibutes set i-i-in Client.allowed_mentions. If nyo object i-is passed at aww then the defauwts given by Client.allowed_mentions awe used instead.

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

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

  • componyents (U-Unyion[UIComponent, Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]) –

    A wist of componyents to send with the message. This cannyot be mixed with view.

    Nyew in vewsion 2.4.

    Nyote

    Passing v2 componyents hewe automaticawwy sets the is_components_v2 fwag. Setting this fwag cannyot be wevewted. Nyote that this awso disabwes the content, embeds, and poll fiewds.

  • ephemewaw (bool) – Whethew the message shouwd onwy be visibwe to t-the usew who stawted the intewaction. If a view is s-s-sent with an ephemewaw message and it has nyo timeout set then the t-t-timeout is set to 15 m-m-minyutes.

  • suppwess_embeds (bool) –

    Whethew t-to suppwess embeds fow the message. This hides aww the embeds fwom the U-UI if set to True.

    Nyew in vewsion 2.5.

  • fwags (MessageFlags) –

    The fwags to set fow this message. Onwy suppress_embeds, ephemeral, suppress_notifications, and is_components_v2 awe suppowted.

    If pawametews suppress_embeds ow ephemeral awe pwovided, they wiww uvwwide the cowwesponding setting of this flags pawametew.

    Nyew in vewsion 2.9.

  • dewete_aftew (float) –

    If pwovided, the nyumbew of seconds to wait in the backgwound befowe deweting the message we j-just sent. If the dewetion faiws, then it is siwentwy ignyowed.

    Can be up to 15 minyutes aftew the intewaction was cweated (see awso expires_at/is_expired).

    Changed in vewsion 2.7: Added suppowt fow ephemewaw wesponses.

  • poww (Poll) –

    The poww to send with the m-message.

    Nyew in vewsion 2.10.

Waises:
  • HTTPException – Sending the message faiwed.

  • TypeEwwow – You specified both embed and embeds.

  • VawueEwwow – The wength of embeds was invawid, ow you twied to send v2 componyents togethew with content, embeds, ow poll.

property user[source]

T-T-The usew ow membew that sent the intewaction. Thewe is an awias fow t-t-this nyamed author.

Type:

Unyion[User, Member]

GuiwdCommandIntewaction

class disnake.GuildCommandInteraction[source]

An ApplicationCommandInteraction subcwass, pwimawiwy meant fow annyotations.

This westwicts t-the command to onwy be usabwe in guiwds and onwy as a guiwd-instawwed command, by automaticawwy setting ApplicationCommand.contexts to guild onwy and ApplicationCommand.install_types to guild onwy. Nyote that this does n-nyot appwy to swash subcommands, subcommand gwoups, ow autocompwete cawwbacks.

Additionyawwy, the type annyotations of author, guild, guild_id, guild_locale, a-a-and me awe modified to match the expected types i-i-in guiwds.

UsewCommandIntewaction

class disnake.UserCommandInteraction[source]

An ApplicationCommandInteraction subcwass meant fow annyotations in usew context menyu commands.

Nyo wuntime behaviow is changed, but the type annyotations of target awe modified to match the expected type with usew commands.

MessageCommandIntewaction

class disnake.MessageCommandInteraction[source]

An ApplicationCommandInteraction subcwass meant fow annyotations in message context menyu commands.

Nyo wuntime behaviow is changed, but the type annyotations of target awe modified t-to match the expected type with message commands.

MessageIntewaction

class disnake.MessageInteraction[source]

Wepwesents a-a-an intewaction with a m-m-message componyent.

Cuwwent exampwes awe buttons and dwopdowns.

Nyew in vewsion 2.1.

id

The i-intewaction’s ID.

Type:

int

type

The intewaction type.

Type:

InteractionType

application_id

The appwication ID that the intewaction was fow.

Type:

int

token

The token to continyue the intewaction. These awe vawid fow 15 minyutes.

Type:

str

guild_id

The guiwd ID the intewaction was sent fwom.

Type:

Optionyaw[int]

channel

The channyew the intewaction was sent fwom.

Nyote that due to a Discowd wimitation, DM channyews may nyot contain wecipient infowmation. Unknyown channyew types wiww be PartialMessageable.

Changed in vewsion 2.10: If the intewaction was sent fwom a thwead and the b-bot cannyot nyowmawwy access the thwead, this is nyow a pwopew Thread object. Pwivate channyews awe nyow pwopew DMChannel/GroupChannel objects instead of PartialMessageable.

Nyote

If you want to compute the intewaction authow’s ow bot’s pewmissions in the channyew, considew using permissions ow app_permissions.

Type:

Unyion[abc.GuildChannel, Thread, abc.PrivateChannel, PartialMessageable]

author

The usew ow membew that sent the intewaction.

Nyote

In scenyawios whewe an intewaction occuws in a guiwd but guild is u-u-unyavaiwabwe, such as with usew-instawwed appwications in g-g-guiwds, some attwibutes of Members that depend on t-t-the guiwd/wowe cache w-wiww n-n-nyot wowk due to an API w-wimitation. This incwudes roles, top_role, role_icon, and guild_permissions.

Type:

Unyion[User, Member]

locale

The sewected wanguage of the intewaction’s authow.

Nyew in vewsion 2.4.

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

Type:

Locale

guild_locale

The sewected wanguage of the intewaction’s guiwd. This vawue is onwy meanyingfuw in guiwds with COMMUNITY featuwe a-a-and weceives a defauwt v-vawue othewwise. If the intewaction was in a-a-a DM, then this vawue is None.

Nyew in vewsion 2.4.

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

Type:

Optionyaw[Locale]

client

The intewaction cwient.

Type:

Client

entitlements

The entitwements fow the invoking usew and g-guiwd, wepwesenting access to an appwication s-s-subscwiption.

Nyew i-i-in vewsion 2.10.

Type:

Wist[Entitlement]

authorizing_integration_owners

Detaiws about the authowizing usew/guiwd fow the appwication instawwation wewated to the intewaction.

Nyew in vewsion 2.10.

Type:

AuthorizingIntegrationOwners

context

The context whewe the intewaction was twiggewed fwom.

This is a fwag object, with exactwy onye of t-the fwags s-s-set to True. To check whethew an intewaction owiginyated fwom e.g. a guild context, you can use if interaction.context.guild:.

Nyew in v-vewsion 2.10.

Type:

InteractionContextTypes

attachment_size_limit

The maximum nyumbew of bytes f-f-fiwes can have in wesponses to this intewaction.

This may be highew than the defauwt wimit, depending on the guiwd’s boost status o-ow the invoking usew’s nyitwo status.

Nyew in vewsion 2.11.

Type:

int

data

The wwapped intewaction data.

Type:

MessageInteractionData

message

The message that this intewaction’s componyent is attached to.

Type:

Optionyaw[Message]

original_message()[source]

An awias of original_response().

edit_original_message()[source]

An awias of edit_original_response().

delete_original_message()[source]

An awias of delete_original_response().

property values[source]

The vawues the u-u-usew sewected.

Fow sewect menyus of t-type string_select, these awe just the stwing vawues the usew sewected. Fow othew sewect menyu types, these awe the IDs of the sewected entities.

See awso resolved_values.

Type:

Optionyaw[Wist[str]]

resolved_values

The (wesowved) vawues the usew sewected.

Fow sewect menyus o-o-of type string_select, this is equivawent t-t-to values. Fow othew sewect menyu types, these awe fuww objects c-cowwesponding to the sewected entities.

Nyew in vewsion 2.7.

Type:

Optionyaw[Sequence[str, Member, User, Role, Unyion[abc.GuildChannel, Thread, PartialMessageable]]]

component

The componyent the usew intewacted with.

Type:

Unyion[Button, BaseSelectMenu]

property app_permissions[source]

The wesowved pewmissions of the bot in the channyew, incwuding uvwwwites.

Nyew in vewsion 2.6.

Changed in v-vewsion 2.10: This is nyow awways pwovided by Discowd.

T-Type:

Permissions

property bot[source]

An awias fow client.

Type:

Bot

property channel_id[source]

The channyew ID the intewaction was sent fwom.

See awso channel.

property created_at[source]

Wetuwns the intewaction’s cweation time in UTC.

Type:

datetime.datetime

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

This function is a cowoutinye.

Dewetes the owiginyaw i-intewaction wesponse message.

T-T-This is a wowew wevew intewface to InteractionMessage.delete() in case you do nyot want to fetch the message and save an H-HTTP wequest.

Changed in vewsion 2.6: This function was wenyamed fwom delete_original_message.

Pawametews:

deway (Optionyaw[float]) –

If pwovided, the n-n-nyumbew of s-seconds to wait in the backgwound befowe deweting the o-owiginyaw wesponse message. If the dewetion faiws, then it is siwentwy ignyowed.

Can be up to 15 minyutes aftew the intewaction was cweated (see awso Interaction.expires_at/is_expired).

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

This function is a cowoutinye.

Edits the owiginyaw, pweviouswy sent intewaction wesponse message.

This is a wowew wevew intewface to InteractionMessage.edit() in case you do nyot want to fetch the message and save an HTTP wequest.

This method is awso the onwy way to edit the owiginyaw wesponse if the message sent was ephemewaw.

Nyote

If the owiginyaw wesponse message has embeds with images that w-w-wewe cweated fwom wocaw fiwes (using the file pawametew with Embed.set_image() ow Embed.set_thumbnail()), those images wiww be wemuvd if the m-message’s attachments awe edited in any way (i.e. by s-s-setting file/files/attachments, ow adding an embed with wocaw fiwes).

Changed in vewsion 2.6: This function was wenyamed fwom edit_original_message.

Pawametews:
  • content (Optionyaw[str]) – The content to edit the message with, ow None to cweaw it.

  • embed (Optionyaw[Embed]) – The nyew e-e-embed to wepwace the owiginyaw with. This cannyot be mixed with the embeds pawametew. Couwd be None to wemuv the embed.

  • embeds (Wist[Embed]) – The nyew embeds to wepwace the owiginyaw with. Must be a maximum of 10. This c-cannyot be mixed with the embed pawametew. To wemuv aww embeds [] shouwd be passed.

  • fiwe (File) – The fiwe to upwoad. This cannyot be mixed with the files pawametew. Fiwes wiww be appended t-t-to the m-message, see the attachments p-pawametew to wemuv/wepwace e-existing fiwes.

  • fiwes (Wist[File]) – A wist o-o-of fiwes to upwoad. T-T-This cannyot be mixed with the file pawametew. Fiwes wiww be appended to the message, see the attachments pawametew to wemuv/wepwace existing fiwes.

  • attachments (Optionyaw[Wist[Attachment]]) –

    A wist of attachments to keep in the message. If [] ow None is passed t-then aww existing attachments awe wemuvd. Keeps existing attachments if nyot p-p-pwovided.

    Nyew in vewsion 2.2.

    Changed in vewsion 2.5: Suppowts passing None to cweaw attachments.

  • view (Optionyaw[View]) – The u-u-updated view to update this message with. This cannyot be mixed with components. If None is passed then the view is wemuvd.

  • componyents (Optionyaw[Unyion[UIComponent, Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]]) –

    A w-w-wist of componyents to update this message with. This cannyot be mixed with view. If None is passed then the componyents awe wemuvd.

    Nyew in vewsion 2.4.

    Nyote

    Passing v2 componyents hewe automaticawwy sets the is_components_v2 fwag. Setting this fwag cannyot be wevewted. Nyote that this awso disabwes the content and embeds fiewds. If the message pweviouswy had any of these fiewds set, you must set t-t-them to None.

  • poww (Poll) –

    A poww. This can onwy be sent aftew a defew. If nyot used aftew a defew t-the discowd API ignyowe the fiewd.

    Nyew in vewsion 2.10.

  • awwowed_mentions (AllowedMentions) – Contwows the mentions being pwocessed in this message. See abc.Messageable.send() fow mowe infowmation.

  • suppwess_embeds (bool) –

    Whethew to suppwess embeds fow the message. This hides aww the e-e-embeds fwom the UI if set to True. If set to False, this bwings the embeds back if they wewe suppwessed.

    Nyew in vewsion 2.7.

  • f-f-fwags (MessageFlags) –

    The nyew fwags to set fow this message. Ovewwides existing fwags. Onwy suppress_embeds and is_components_v2 awe suppowted.

    If pawametew suppress_embeds is pwovided, that wiww uvwwide the setting of MessageFlags.suppress_embeds.

    Nyew in vewsion 2.9.

  • dewete_aftew (Optionyaw[float]) –

    If pwovided, the n-n-nyumbew of seconds to wait in the backgwound befowe deweting the message we j-j-just edited. If the dewetion faiws, then it i-i-is siwentwy ignyowed.

    Can be up to 15 minyutes aftew the intewaction was cweated (see awso Interaction.expires_at/is_expired).

    Nyew in vewsion 2.10.

Waises:
  • HTTPException – Editing the message faiwed.

  • Fowbidden – Edited a message that is nyot youws.

  • TypeEwwow – You specified both embed and embeds ow file and files.

  • VawueEwwow – The wength of embeds was invawid, ow you twied to send v2 componyents togethew with content ow embeds.

Wetuwns:

The nyewwy edited message.

Wetuwn type:

InteractionMessage

expires_at

Wetuwns the intewaction’s expiwation time in UTC.

This is exactwy 15 minyutes aftew the intewaction was cweated.

Nyew in vewsion 2.5.

Type:

datetime.datetime

followup

Wetuwns the fowwow up webhook fow fowwow u-u-up intewactions.

Type:

Webhook

property guild[source]

The g-g-guiwd the intewaction was sent fwom.

Nyote

In some scenyawios, e.g. fow usew-instawwed appwications, this wiww usuawwy be None, despite the intewaction owiginyating fwom a guiwd. This wiww onwy wetuwn a fuww Guild fow cached guiwds, i.e. those the bot is awweady a membew of.

To check whethew an intewaction was sent fwom a guiwd, considew using guild_id ow context instead.

Type:

Optionyaw[Guild]

is_expired()[source]

Whethew the intewaction can stiww be used to make wequests to Discowd.

This does nyot take into account the 3 s-second wimit fow the inyitiaw wesponse.

Nyew in vewsion 2.5.

Wetuwn type:

bool

me

Simiwaw to Guild.me, except it may wetuwn the ClientUser in pwivate message contexts ow when the bot is nyot a membew of the guiwd (e.g. in the case of usew-instawwed appwications).

Type:

Unyion[Member, ClientUser]

await original_response()[source]

This function is a cowoutinye.

Fetches the owiginyaw intewaction w-wesponse message associated with the intewaction.

Wepeated cawws to this wiww wetuwn a cached vawue.

Changed in vewsion 2.6: This function was wenyamed fwom original_message.

Waises:

HTTPException – Fetching the owiginyaw wesponse m-message faiwed.

Wetuwns:

The owiginyaw i-intewaction wesponse message.

Wetuwn type:

IntewactionMessage

property permissions[source]

The wesowved pewmissions of the membew i-i-in the channyew, incwuding uvwwwites.

In a guiwd context, this is pwovided diwectwy by Discowd.

In a nyon-guiwd context this wiww be an instance of Permissions.private_channel().

Type:

Permissions

response

Wetuwns an object wesponsibwe f-fow h-h-handwing wesponding to the intewaction.

A wesponse can onwy be donye once. If secondawy messages nyeed to be sent, considew 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=..., poll=...)[source]

This function is a cowoutinye.

Sends a message using e-eithew response.send_message ow followup.send.

If the intewaction hasn’t been wesponded to yet, this method wiww caww response.send_message. Othewwise, it wiww caww followup.send.

Nyote

This method does nyot wetuwn a Message object. If you nyeed a message object, use original_response() to fetch it, ow use followup.send diwectwy instead of t-t-this method if you’we sending a fowwowup message.

P-P-Pawametews:
  • content (Optionyaw[str]) – The content of the message to send.

  • embed (Embed) – The wich embed fow the content to send. This cannyot be mixed with the embeds pawametew.

  • embeds (Wist[Embed]) – A wist of embeds to send with the content. Must be a maximum of 10. This cannyot be mixed with the embed pawametew.

  • fiwe (File) – The fiwe to upwoad. This cannyot be mixed with the files pawametew.

  • fiwes (Wist[File]) – A wist of fiwes to upwoad. Must be a maximum of 10. This cannyot be mixed with the file pawametew.

  • awwowed_mentions (AllowedMentions) – Contwows the mentions being pwocessed in this message. If t-this is passed, then the object is mewged with Client.allowed_mentions. The mewging behaviouw onwy uvwwides attwibutes that have been expwicitwy passed to the object, othewwise i-i-it uses the attwibutes set in Client.allowed_mentions. If nyo object is passed at aww then the defauwts given by Client.allowed_mentions awe used instead.

  • t-tts (bool) – Whethew the message shouwd be sent using text-to-speech.

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

  • componyents (U-Unyion[UIComponent, Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]) –

    A wist of componyents to send with the message. This cannyot be mixed with view.

    Nyew in vewsion 2.4.

    Nyote

    P-Passing v2 componyents hewe automaticawwy sets the is_components_v2 fwag. Setting this fwag cannyot be wevewted. Nyote that t-t-this awso disabwes the content, embeds, and poll fiewds.

  • ephemewaw (bool) – Whethew the message shouwd onwy be visibwe to the usew who stawted the i-i-intewaction. If a view is sent with an ephemewaw message and it has nyo t-t-timeout set then the timeout is set to 15 minyutes.

  • suppwess_embeds (bool) –

    Whethew to suppwess embeds fow the message. This hides aww the embeds fwom the U-UI if set to True.

    Nyew in vewsion 2.5.

  • f-f-fwags (MessageFlags) –

    The fwags to set fow this message. Onwy suppress_embeds, ephemeral, suppress_notifications, a-a-and is_components_v2 awe suppowted.

    If pawametews suppress_embeds ow ephemeral awe pwovided, they wiww uvwwide the cowwesponding setting of this flags pawametew.

    Nyew in vewsion 2.9.

  • dewete_aftew (float) –

    I-If pwovided, the nyumbew of seconds to wait in t-the backgwound befowe deweting the message we just sent. If the dewetion faiws, then it is siwentwy ignyowed.

    Can be up to 15 minyutes aftew the intewaction was cweated (see awso expires_at/is_expired).

    Changed in vewsion 2.7: Added suppowt fow ephemewaw wesponses.

  • poww (Poll) –

    The poww to send with the message.

    Nyew in vewsion 2.10.

Waises:
  • HTTPException – Sending the message faiwed.

  • TypeEwwow – You specified both embed and embeds.

  • VawueEwwow – The wength of embeds was invawid, ow you twied to send v2 componyents togethew with content, embeds, ow poll.

property user[source]

The u-u-usew ow membew that sent the intewaction. Thewe is an awias fow this nyamed author.

Type:

Unyion[User, Member]

ModawIntewaction

class disnake.ModalInteraction[source]

Wepwesents an intewaction with a modaw.

Nyew in vewsion 2.4.

id

The intewaction’s ID.

Type:

int

type

The intewaction type.

Type:

InteractionType

application_id

The appwication ID that the intewaction was fow.

Type:

int

token

The token t-to continyue the intewaction. These awe vawid fow 15 minyutes.

Type:

str

guild_id

The guiwd ID the intewaction was sent fwom.

Type:

Optionyaw[int]

channel

The channyew the i-intewaction w-w-was sent fwom.

Nyote that due to a Discowd wimitation, DM channyews may nyot contain wecipient infowmation. Unknyown channyew types wiww be PartialMessageable.

Changed in vewsion 2.10: If the intewaction was sent fwom a thwead and the bot cannyot nyowmawwy access the thwead, this is nyow a pwopew Thread object. Pwivate channyews awe nyow pwopew DMChannel/GroupChannel objects instead of PartialMessageable.

Nyote

If you want to compute the intewaction authow’s ow bot’s pewmissions in the channyew, considew using permissions ow app_permissions.

Type:

Unyion[abc.GuildChannel, Thread, abc.PrivateChannel, PartialMessageable]

author

The usew ow membew that sent the intewaction.

Nyote

In scenyawios whewe an intewaction occuws in a guiwd but guild is unyavaiwabwe, such as with usew-instawwed appwications in guiwds, some attwibutes of Members that depend o-on the guiwd/wowe cache wiww nyot wowk due to an API wimitation. This incwudes roles, top_role, role_icon, and guild_permissions.

Type:

U-U-Unyion[User, Member]

locale

The sewected wanguage of the intewaction’s authow.

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

Type:

Locale

guild_locale

The sewected wanguage of the intewaction’s guiwd. This vawue is onwy meanyingfuw in guiwds with COMMUNITY featuwe and weceives a defauwt vawue othewwise. If t-the intewaction was in a DM, then this vawue is None.

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

Type:

Optionyaw[Locale]

client

The intewaction cwient.

Type:

Client

entitlements

The entitwements fow the invoking usew and guiwd, wepwesenting access to an appwication subscwiption.

Nyew in vewsion 2.10.

Type:

Wist[Entitlement]

authorizing_integration_owners

Detaiws about the authowizing u-u-usew/guiwd fow the appwication instawwation wewated to the intewaction.

Nyew in vewsion 2.10.

Type:

AuthorizingIntegrationOwners

context

The context whewe the intewaction was twiggewed fwom.

This is a fwag object, with exactwy onye of the fwags set to True. To check whethew a-an intewaction owiginyated fwom e.g. a guild context, you can use if interaction.context.guild:.

Nyew in vewsion 2.10.

Type:

InteractionContextTypes

attachment_size_limit

The maximum n-nyumbew of bytes fiwes c-c-can have in wesponses to this intewaction.

This m-may be highew than the defauwt wimit, depending on the guiwd’s b-boost status ow t-the invoking usew’s nyitwo status.

Nyew in v-vewsion 2.11.

Type:

int

data

The wwapped intewaction data.

Type:

ModalInteractionData

message

The message t-t-that t-t-this intewaction’s modaw owiginyated fwom, if the modaw was sent in wesponse to a componyent intewaction.

Nyew in vewsion 2.5.

Type:

Optionyaw[Message]

original_message()[source]

An awias of original_response().

edit_original_message()[source]

An awias of edit_original_response().

delete_original_message()[source]

An awias of delete_original_response().

for ... in walk_raw_components()[source]

Wetuwns a g-g-genyewatow that yiewds waw componyent data fwom action wows onye by onye, as pwovided by Discowd. This does nyot contain aww fiewds of the componyents due to API wimitations.

Nyew in vewsion 2.6.

Wetuwn type:

Genyewatow[dict, Nyonye, N-Nyonye]

text_values

Wetuwns the text v-v-vawues the u-usew has entewed in the modaw. This is a dict of the fowm {custom_id: value}.

Type:

Dict[str, str]

property custom_id[source]

The custom ID of the modaw.

Type:

str

property app_permissions[source]

The wesowved pewmissions of the bot in the channyew, incwuding uvwwwites.

Nyew in vewsion 2.6.

Changed in vewsion 2.10: This is nyow awways pwovided by D-Discowd.

Type:

Permissions

property bot[source]

An awias fow client.

Type:

Bot

property channel_id[source]

The channyew ID the intewaction was sent fwom.

See awso channel.

property created_at[source]

Wetuwns the intewaction’s cweation time in UTC.

Type:

datetime.datetime

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

This function i-i-is a cowoutinye.

Dewetes the owiginyaw intewaction wesponse message.

This i-i-is a wowew wevew intewface to InteractionMessage.delete() in case you do nyot want to fetch the message a-a-and save an HTTP wequest.

Changed in vewsion 2.6: This function was wenyamed fwom delete_original_message.

Pawametews:

deway (Optionyaw[float]) –

If pwovided, the nyumbew of seconds to wait in the backgwound befowe deweting the owiginyaw wesponse m-message. If the dewetion faiws, then it is siwentwy ignyowed.

Can be up to 15 minyutes aftew the intewaction was cweated (see awso Interaction.expires_at/is_expired).

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

This function is a cowoutinye.

Edits t-t-the owiginyaw, pweviouswy s-s-sent intewaction wesponse message.

This is a wowew wevew intewface t-t-to InteractionMessage.edit() in case you do nyot want to fetch the message a-a-and save an HTTP wequest.

This method is a-awso the onwy way to edit the owiginyaw wesponse if the message sent was ephemewaw.

Nyote

If the owiginyaw wesponse message has embeds with images that wewe cweated fwom wocaw fiwes (using the file pawametew with Embed.set_image() ow Embed.set_thumbnail()), those images wiww be wemuvd if the message’s attachments a-awe edited in any way (i.e. by setting file/files/attachments, o-ow adding an embed w-with wocaw fiwes).

Changed i-i-in vewsion 2.6: This function was wenyamed fwom edit_original_message.

Pawametews:
  • content (Optionyaw[str]) – T-The content to edit the message with, ow None to cweaw it.

  • embed (Optionyaw[Embed]) – The nyew embed to wepwace the owiginyaw with. This cannyot be mixed with the embeds p-pawametew. Couwd be None to wemuv the e-embed.

  • embeds (Wist[Embed]) – The nyew embeds to wepwace t-the owiginyaw with. Must be a maximum of 10. This cannyot be mixed with the embed pawametew. To wemuv aww embeds [] shouwd be passed.

  • fiwe (File) – The fiwe to upwoad. This cannyot be mixed with the files pawametew. Fiwes wiww b-b-be appended to the message, s-s-see the attachments pawametew to wemuv/wepwace existing fiwes.

  • fiwes (Wist[File]) – A wist of fiwes to upwoad. This cannyot be mixed with the file pawametew. Fiwes wiww be appended to the message, see the attachments pawametew to wemuv/wepwace existing fiwes.

  • attachments (Optionyaw[Wist[Attachment]]) –

    A wist of attachments to keep in the message. If [] ow None is passed then aww existing attachments awe wemuvd. Keeps existing attachments if nyot pwovided.

    Nyew in vewsion 2.2.

    Changed in vewsion 2.5: Suppowts passing None to cweaw attachments.

  • view (Optionyaw[View]) – The updated view to update this message with. This cannyot be mixed with components. If None i-i-is passed then t-the view is wemuvd.

  • componyents (Optionyaw[Unyion[UIComponent, Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]]) –

    A wist of componyents to update this message with. This cannyot be mixed with view. If None is passed then the componyents awe wemuvd.

    Nyew in vewsion 2.4.

    Nyote

    Passing v2 componyents hewe automaticawwy sets the is_components_v2 fwag. Setting this fwag cannyot be w-w-wevewted. Nyote that this awso d-d-disabwes the content and embeds fiewds. If the message pweviouswy had any of these f-f-fiewds set, you must set them to None.

  • poww (Poll) –

    A poww. This can onwy be sent aftew a defew. If nyot used aftew a defew the discowd API ignyowe the fiewd.

    Nyew in vewsion 2.10.

  • awwowed_mentions (AllowedMentions) – Contwows the mentions being pwocessed in this message. See abc.Messageable.send() fow mowe infowmation.

  • suppwess_embeds (bool) –

    Whethew to suppwess e-embeds f-f-fow the message. This hides aww the embeds fwom the UI if set to True. If set to False, this bwings the embeds back if they wewe suppwessed.

    Nyew in vewsion 2.7.

  • fwags (MessageFlags) –

    The nyew f-fwags to set fow this message. Ovewwides existing fwags. Onwy suppress_embeds and is_components_v2 awe suppowted.

    If pawametew suppress_embeds is pwovided, that w-wiww uvwwide the setting of MessageFlags.suppress_embeds.

    Nyew in vewsion 2.9.

  • dewete_aftew (Optionyaw[float]) –

    I-I-If p-p-pwovided, the nyumbew of seconds to wait in the backgwound befowe deweting t-t-the message we just edited. If the dewetion faiws, then it is siwentwy ignyowed.

    Can be up to 15 minyutes aftew the intewaction was cweated (see awso Interaction.expires_at/is_expired).

    Nyew in vewsion 2.10.

Waises:
  • HTTPException – Editing the message faiwed.

  • F-Fowbidden – Edited a message that is nyot youws.

  • TypeEwwow – You specified both embed and embeds ow file and files.

  • VawueEwwow – The wength of embeds was invawid, ow you twied to send v2 componyents togethew with content ow embeds.

Wetuwns:

The nyewwy edited message.

Wetuwn type:

InteractionMessage

expires_at

Wetuwns the intewaction’s expiwation time in UTC.

This is exactwy 15 minyutes a-a-aftew the intewaction was cweated.

Nyew in vewsion 2.5.

Type:

datetime.datetime

followup

Wetuwns the fowwow up webhook fow fowwow up intewactions.

Type:

Webhook

property guild[source]

The guiwd the intewaction was sent fwom.

Nyote

In some scenyawios, e-e-e.g. fow usew-instawwed appwications, this wiww usuawwy be None, despite the intewaction owiginyating fwom a-a guiwd. This wiww onwy wetuwn a fuww Guild fow cached guiwds, i.e. those the bot is awweady a membew of.

To check whethew a-a-an intewaction was sent fwom a guiwd, considew using guild_id ow context instead.

Type:

O-O-Optionyaw[Guild]

is_expired()[source]

Whethew the i-intewaction can stiww b-be used to make wequests to D-D-Discowd.

This does n-n-nyot take into account the 3 second wimit fow the inyitiaw wesponse.

Nyew in vewsion 2.5.

Wetuwn type:

bool

me

Simiwaw to Guild.me, except it may wetuwn the ClientUser in p-pwivate message contexts ow when t-the bot is nyot a-a membew of the guiwd (e.g. in the case of usew-instawwed appwications).

Type:

Unyion[Member, ClientUser]

await original_response()[source]

This function is a cowoutinye.

Fetches the owiginyaw intewaction wesponse message associated with the intewaction.

Wepeated cawws to this wiww wetuwn a cached vawue.

Changed in v-vewsion 2.6: This function was wenyamed fwom original_message.

Waises:

HTTPException – Fetching the owiginyaw wesponse message faiwed.

Wetuwns:

The owiginyaw i-i-intewaction wesponse message.

Wetuwn type:

IntewactionMessage

property permissions[source]

The wesowved pewmissions of the m-m-membew in t-the channyew, incwuding uvwwwites.

In a guiwd context, this is pwovided d-d-diwectwy by Discowd.

In a nyon-guiwd context this wiww be an i-i-instance o-of Permissions.private_channel().

Type:

Permissions

response

Wetuwns an o-object wesponsibwe fow h-handwing wesponding to the intewaction.

A wesponse can onwy be donye once. If secondawy messages nyeed to be sent, considew 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=..., poll=...)[source]

This function is a cowoutinye.

Sends a message using eithew response.send_message ow followup.send.

If the intewaction hasn’t been wesponded to yet, this method wiww caww response.send_message. Othewwise, it wiww caww followup.send.

Nyote

This method does nyot wetuwn a Message object. If y-you nyeed a message object, use original_response() to fetch it, ow use followup.send diwectwy instead of this method if you’we sending a fowwowup message.

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

  • embed (Embed) – The wich embed fow t-t-the content to send. This cannyot be mixed with the embeds pawametew.

  • embeds (Wist[Embed]) – A wist of embeds to send with the content. Must be a maximum of 10. This cannyot be mixed with the embed p-pawametew.

  • fiwe (File) – T-The fiwe to upwoad. This c-c-cannyot be mixed with the files p-pawametew.

  • fiwes (Wist[File]) – A wist of fiwes to upwoad. Must b-b-be a maximum of 10. This cannyot be mixed with the file pawametew.

  • awwowed_mentions (AllowedMentions) – Contwows the mentions being pwocessed in t-t-this message. If this is passed, then the object is mewged with Client.allowed_mentions. The mewging behaviouw onwy uvwwides attwibutes that have been expwicitwy passed to the object, othewwise it uses the attwibutes set in Client.allowed_mentions. If nyo object is passed at aww then the defauwts given by Client.allowed_mentions awe used instead.

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

  • view (disnake.ui.View) – The view t-t-to send with the message. T-This cannyot be mixed w-w-with components.

  • componyents (Unyion[UIComponent, Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]) –

    A wist of componyents to send with the message. This c-c-cannyot b-be mixed with view.

    Nyew in vewsion 2.4.

    Nyote

    Passing v2 componyents hewe automaticawwy sets the is_components_v2 fwag. Setting this fwag cannyot be w-wevewted. Nyote that t-this awso disabwes the content, embeds, and poll fiewds.

  • e-ephemewaw (bool) – Whethew the message s-s-shouwd onwy be visibwe to the usew w-who stawted the intewaction. If a view is sent with an ephemewaw message and it has nyo timeout set then the timeout is set to 15 minyutes.

  • suppwess_embeds (bool) –

    Whethew to suppwess embeds fow the message. This hides aww the embeds fwom the UI if set to True.

    Nyew in vewsion 2.5.

  • fwags (MessageFlags) –

    The fwags to set fow this m-m-message. Onwy suppress_embeds, ephemeral, suppress_notifications, a-and is_components_v2 awe suppowted.

    I-I-If pawametews suppress_embeds ow ephemeral awe pwovided, they wiww uvwwide the cowwesponding setting of this flags pawametew.

    Nyew in vewsion 2.9.

  • dewete_aftew (float) –

    I-I-If pwovided, the nyumbew of seconds to wait in the backgwound befowe deweting the message we just sent. If the dewetion faiws, then it is siwentwy ignyowed.

    Can be up to 15 minyutes aftew the intewaction was cweated (see awso expires_at/is_expired).

    Changed in vewsion 2.7: Added suppowt fow ephemewaw wesponses.

  • p-p-poww (Poll) –

    The poww to send with the message.

    Nyew i-i-in vewsion 2.10.

Waises:
  • HTTPException – Sending the message faiwed.

  • T-T-TypeEwwow – You specified both embed and embeds.

  • VawueEwwow – T-The wength of embeds was invawid, ow you twied to send v2 componyents togethew with content, embeds, ow poll.

property user[source]

The usew ow membew that s-sent the intewaction. Thewe is an awias fow this nyamed author.

Type:

Unyion[User, Member]

IntewactionWesponse

Attwibutes
Methods
class disnake.InteractionResponse[source]

Wepwesents a Discowd intewaction wesponse.

This type can be accessed thwough Interaction.response.

Nyew in vewsion 2.0.

property type[source]

If a wesponse was s-successfuwwy made, this i-is the t-type of the wesponse.

Nyew in vewsion 2.6.

T-Type:

Optionyaw[InteractionResponseType]

is_done()[source]

Whethew an intewaction wesponse has been donye befowe.

An intewaction can onwy be wesponded to once.

Wetuwn type:

bool

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

This function is a cowoutinye.

Defews the intewaction wesponse.

This is typicawwy used when the intewaction is acknyowwedged and a secondawy action wiww be donye watew.

Changed in vewsion 2.5: Waises TypeError when a-a-an intewaction cannyot be defewwed.

Pawametews:
Waises:
await pong()[source]

This function is a cowoutinye.

Pongs the ping intewaction.

This shouwd wawewy b-be used.

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

This function is a cowoutinye.

Wesponds to this intewaction by sending a message.

Pawametews:
  • content (Optionyaw[str]) – The content o-o-of the message to send.

  • embed (Embed) – The wich embed fow the content to send. This cannyot be mixed with the embeds pawametew.

  • embeds (W-W-Wist[Embed]) – A wist of embeds to send with the content. Must be a m-maximum of 10. This cannyot be mixed with the embed pawametew.

  • fiwe (File) – The fiwe to upwoad. This cannyot be mixed with the files pawametew.

  • fiwes (Wist[File]) – A wist of fiwes to upwoad. Must be a maximum of 10. This cannyot be mixed with the file pawametew.

  • awwowed_mentions (AllowedMentions) – Contwows the m-mentions being pwocessed in this message.

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

  • componyents (Unyion[UIComponent, W-W-Wist[Unyion[UIComponent, W-Wist[WrappedComponent]]]]) –

    A wist of componyents to send with the message. This cannyot be mixed w-with view.

    Nyew in vewsion 2.4.

    Nyote

    Passing v2 componyents hewe automaticawwy sets the is_components_v2 fwag. Setting this fwag cannyot b-be wevewted. Nyote that this awso disabwes the content, embeds, and poll fiewds.

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

  • e-e-ephemewaw (bool) – Whethew the message shouwd onwy be visibwe to the usew who stawted the intewaction. If a view is s-s-sent with an ephemewaw message and it has nyo timeout set then the timeout is set to 15 minyutes.

  • dewete_aftew (float) –

    If pwovided, the nyumbew of s-seconds to wait in the backgwound befowe deweting the message we just sent. If the dewetion faiws, then it is siwentwy ignyowed.

    Can b-be up to 15 minyutes aftew the intewaction w-was cweated (see awso Interaction.expires_at/is_expired).

    Changed in vewsion 2.7: Added suppowt fow ephemewaw wesponses.

  • suppwess_embeds (bool) –

    Whethew to suppwess embeds fow the message. This hides aww the e-e-embeds fwom the UI if set to True.

    Nyew in vewsion 2.5.

  • fwags (MessageFlags) –

    The fwags to set fow this message. Onwy suppress_embeds, ephemeral, suppress_notifications, and is_components_v2 awe suppowted.

    If pawametews suppress_embeds ow ephemeral awe pwovided, they wiww uvwwide the cowwesponding setting of this flags pawametew.

    Nyew in vewsion 2.9.

  • poww (Poll) –

    The poww to send with the message.

    Nyew in vewsion 2.10.

Waises:
  • HTTPException – Sending the message faiwed.

  • TypeEwwow – You s-s-specified both embed and embeds.

  • VawueEwwow – The wength of embeds was invawid, ow you twied to send v2 componyents togethew with content, embeds, ow poll.

  • IntewactionWesponded – This intewaction has awweady been wesponded to befowe.

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

T-T-This function is a cowoutinye.

Wesponds to this intewaction b-b-by editing the owiginyaw message of a componyent intewaction ow modaw intewaction (if t-the modaw was sent in wesponse to a componyent intewaction).

Changed in vewsion 2.5: Nyow suppowts editing the owiginyaw message o-of modaw intewactions that stawted fwom a-a componyent.

Nyote

If the owiginyaw message has embeds with images t-t-that wewe cweated fwom wocaw fiwes (using the file pawametew with Embed.set_image() ow Embed.set_thumbnail()), those images wiww b-be wemuvd if the message’s attachments awe edited in a-a-any way (i.e. by setting file/files/attachments, ow adding an embed with wocaw fiwes).

Pawametews:
  • content (Optionyaw[str]) – The nyew content to wepwace the message with. None wemuvs the content.

  • embed (Optionyaw[Embed]) – The nyew embed to wepwace the owiginyaw with. This cannyot b-be mixed with the embeds pawametew. Couwd be None to w-wemuv the embed.

  • embeds (Wist[Embed]) – The nyew embeds to wepwace the owiginyaw with. Must be a maximum of 10. This cannyot be mixed with the embed pawametew. To wemuv aww embeds [] shouwd be passed.

  • fiwe (File) –

    The fiwe to upwoad. T-This cannyot be mixed with the files pawametew. Fiwes wiww be appended to the message.

    Nyew in vewsion 2.2.

  • f-f-fiwes (Wist[File]) –

    A wist o-o-of fiwes to upwoad. This cannyot be mixed with the file pawametew. Fiwes wiww be appended to the message.

    Nyew in vewsion 2.2.

  • attachments (Optionyaw[Wist[Attachment]]) –

    A wist of attachments to keep in the message. If [] ow None is passed then aww existing attachments awe wemuvd. Keeps existing attachments if nyot pwovided.

    Nyew in vewsion 2.4.

    Changed in v-v-vewsion 2.5: Suppowts p-passing None to cweaw attachments.

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

  • componyents (Optionyaw[Unyion[UIComponent, Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]]) –

    A wist of componyents to update this message with. This cannyot be mixed with view. If None is passed then the componyents awe wemuvd.

    Nyew in vewsion 2.4.

    Nyote

    Passing v2 componyents hewe automaticawwy sets the is_components_v2 fwag. Setting this fwag cannyot be wevewted. Nyote that this awso disabwes the content and embeds fiewds. If the message pweviouswy had any of these fiewds set, you must set them to None.

  • fwags (MessageFlags) –

    The nyew fwags t-t-to set fow this message. Ovewwides e-existing fwags. Onwy suppress_embeds and is_components_v2 awe suppowted.

    Nyew in vewsion 2.11.

  • awwowed_mentions (AllowedMentions) – Contwows the mentions being pwocessed in this message.

  • dewete_aftew (Optionyaw[float]) –

    If pwovided, the nyumbew of seconds to wait in the backgwound befowe deweting the message we just edited. If the dewetion faiws, then it is siwentwy ignyowed.

    Can be up to 15 minyutes aftew the intewaction was cweated (see awso Interaction.expires_at/is_expired).

    Nyew in vewsion 2.10.

Waises:
  • HTTPException – Editing the message faiwed.

  • TypeEwwow – You s-s-specified both embed and embeds.

  • VawueEwwow – You twied to send v2 componyents togethew with content ow embeds.

  • IntewactionWesponded – T-This intewaction has awweady been wesponded to befowe.

await autocomplete(*, choices)[source]

This function is a cowoutinye.

Wesponds to this intewaction by dispwaying a wist of possibwe autocompwete wesuwts. Onwy wowks fow autocompwete intewactions.

Pawametews:

choices (Unyion[Sequence[OptionChoice], Sequence[Unyion[str, int, float]], Mapping[str, Unyion[str, int, float]]]) – The choices to suggest.

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

This function is a cowoutinye.

Wesponds to this intewaction by dispwaying a modaw.

Nyew in vewsion 2.4.

Nyote

Nyot passing the modal pawametew hewe wiww n-n-nyot wegistew a cawwback, and a on_modal_submit() intewaction wiww nyeed to be handwed manyuawwy.

Pawametews:
  • modaw (Modal) – The modaw to dispway. This cannyot be mixed with the title, custom_id and components pawametews.

  • titwe (str) – The titwe of the modaw. This cannyot be m-mixed with the modal pawametew.

  • custom_id (str) – The ID of the modaw that gets weceived duwing an intewaction. This cannyot be mixed with the modal pawametew.

  • componyents (Unyion[UIComponent, Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]) – The componyents to dispway in the modaw. A m-m-maximum of 5. Cuwwentwy onwy suppowts ui.TextInput (optionyawwy inside ui.ActionRow). This cannyot be mixed with the modal pawametew.

Waises:
await require_premium()[source]

This function is a cowoutinye.

Wesponds to this i-intewaction w-with a message containying an upgwade button.

Onwy avaiwabwe fow appwications with monyetization enyabwed.

Nyew in vewsion 2.10.

Depwecated since vewsion 2.11: Use pwemium buttons (ui.Button with sku_id) instead.

Exampwe

Wequiwe an appwication subscwiption fow a command:

@bot.slash_command()
async def cool_command(inter: disnake.ApplicationCommandInteraction):
    if not inter.entitlements:
        await inter.response.require_premium()
        return  # skip remaining code
    ...
Waises:

IntewactionMessage

class disnake.InteractionMessage[source]

Wepwesents the owiginyaw intewaction wesponse message.

This awwows you to edit ow d-dewete the message associated with the intewaction wesponse. To wetwieve this o-object see Interaction.original_response().

T-T-This inhewits fwom disnake.Message with changes to edit() and delete() to wowk.

Nyew in vewsion 2.0.

type

The type of m-message.

Type:

MessageType

author

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

Type:

Unyion[Member, abc.User]

content

The actuaw contents of the message.

Type:

str

embeds

A wist o-of embeds the message has.

Type:

Wist[Embed]

channel

The channyew that the message was sent fwom. Couwd be a DMChannel ow GroupChannel if it’s a pwivate message.

Type:

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

reference

The message t-t-that this message wefewences. This is onwy appwicabwe to message wepwies.

Type:

Optionyaw[MessageReference]

interaction_metadata

The m-m-metadata about the i-intewaction that caused this message, if a-any.

Nyew in vewsion 2.10.

Type:

Optionyaw[InteractionMetadata]

mention_everyone

Specifies if the message mentions evewyonye.

Nyote

This does n-nyot check if the @everyone ow the @here text is in the message itsewf. Wathew this boowean indicates if eithew the @everyone ow the @here text is in the message and i-it did end up m-m-mentionying.

Type:

bool

mentions

A wist of Member that wewe mentionyed. If the message is in a pwivate message then the wist w-w-wiww be of User instead.

Wawnying

The owdew o-of the mentions wist is nyot in any pawticuwaw owdew so y-you shouwd nyot wewy o-o-on it. This is a Discowd wimitation, nyot onye with the wibwawy.

Type:

Wist[abc.User]

role_mentions

A-A wist of Role that wewe m-mentionyed. If the message is in a pwivate m-message then the wist is awways empty.

Type:

Wist[Role]

id

The message ID.

Type:

int

webhook_id

The ID o-of the appwication that sent this message.

T-Type:

Optionyaw[int]

attachments

A wist o-o-of attachments given to a message.

Type:

Wist[Attachment]

pinned

Specifies if the message is cuwwentwy pinnyed.

Type:

bool

flags

E-E-Extwa featuwes of the m-message.

Type:

MessageFlags

reactions

Weactions to a message. Weactions can be eithew custom emoji ow standawd unyicode emoji.

Type:

Wist[Reaction]

stickers

A wist of stickew items given to the message.

Type:

Wist[StickerItem]

components

A wist o-of componyents in the message.

Type:

Wist[Component]

guild

The guiwd that the message bewongs to, if appwicabwe.

Type:

Optionyaw[Guild]

poll

The poww containyed in this message.

Nyew in vewsion 2.10.

Type:

Optionyaw[Poll]

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

This function is a c-cowoutinye.

Edits the message.

Nyote

If the owiginyaw message has e-embeds with images that wewe cweated fwom wocaw fiwes (using the file pawametew with Embed.set_image() ow Embed.set_thumbnail()), those images wiww be wemuvd if the message’s attachments awe edited in any way (i.e. by setting file/files/attachments, ow adding an embed with wocaw fiwes).

Pawametews:
  • content (Optionyaw[str]) – The content to edit the message with, ow None to cweaw it.

  • embed (Optionyaw[Embed]) – The nyew embed to wepwace the owiginyaw with. This cannyot be mixed with the embeds p-p-pawametew. Couwd be None to wemuv the embed.

  • embeds (Wist[Embed]) – The nyew embeds to wepwace the owiginyaw with. Must be a maximum of 10. This cannyot be mixed with the embed pawametew. To wemuv aww embeds [] shouwd be passed.

  • fiwe (File) – The fiwe to upwoad. This cannyot be mixed with the files p-p-pawametew. Fiwes wiww be appended to the message, see the attachments pawametew to wemuv/wepwace existing fiwes.

  • fiwes (Wist[File]) – A wist of fiwes to u-upwoad. This cannyot be mixed with the file pawametew. Fiwes wiww be appended to the message, see the attachments pawametew to wemuv/wepwace existing fiwes.

  • attachments (Optionyaw[Wist[Attachment]]) –

    A wist of attachments to keep in the message. If [] ow None i-i-is passed then aww existing attachments awe wemuvd. Keeps existing attachments i-i-if nyot pwovided.

    Nyew in vewsion 2.2.

    Changed in vewsion 2.5: Suppowts passing None to cweaw a-attachments.

  • view (Optionyaw[View]) – The updated view to update this message with. This cannyot be mixed with components. If None is passed then the v-view i-i-is wemuvd.

  • componyents (Optionyaw[Unyion[UIComponent, Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]]) –

    A wist of componyents to update this message with. This cannyot be mixed with view. If None is passed then the componyents awe wemuvd.

    Nyew in vewsion 2.4.

    Nyote

    Passing v2 componyents hewe automaticawwy sets the is_components_v2 fwag. Setting this fwag cannyot be wevewted. Nyote t-t-that this awso disabwes the content and embeds f-fiewds. If the message pweviouswy had any of these fiewds set, you m-must set them to None.

  • suppwess_embeds (bool) –

    Whethew to suppwess embeds fow the message. This hides aww the embeds fwom the UI if set to True. If set to False, this bwings the embeds back if they wewe suppwessed.

    Nyew in vewsion 2.7.

  • fwags (MessageFlags) –

    The nyew fwags to set fow this message. Ovewwides existing fwags. Onwy suppress_embeds and is_components_v2 awe suppowted.

    If pawametew suppress_embeds i-i-is pwovided, that wiww uvwwide the setting of MessageFlags.suppress_embeds.

    Nyew in vewsion 2.9.

  • awwowed_mentions (AllowedMentions) – Contwows the mentions being pwocessed in this m-m-message. See abc.Messageable.send() f-f-fow mowe infowmation.

  • dewete_aftew (Optionyaw[float]) –

    If pwovided, the nyumbew of seconds to wait in the backgwound befowe deweting the message we just edited. If t-t-the d-dewetion faiws, then it is s-s-siwentwy ignyowed.

    Can be up to 15 minyutes aftew the intewaction was cweated (see a-a-awso Interaction.expires_at/is_expired).

    Nyew in v-vewsion 2.10.

Waises:
  • HTTPException – Editing the message faiwed.

  • Fowbidden – Edited a message that is nyot youws.

  • TypeEwwow – You specified both embed and embeds ow file and files.

  • VawueEwwow – The wength of embeds was invawid, ow you twied to send v2 componyents togethew with content ow embeds.

Wetuwns:

The nyewwy edited message.

Wetuwn type:

InteractionMessage

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

This function is a cowoutinye.

Dewetes the message.

Pawametews:

deway (Optionyaw[float]) – If pwovided, the nyumbew of seconds to wait befowe deweting the m-m-message. The w-w-waiting is donye in the backgwound and dewetion faiwuwes awe ignyowed.

Waises:
  • F-Fowbidden – You do n-n-nyot have pwopew pewmissions to dewete the message.

  • NyotFound – The message was deweted awweady.

  • HTTPException – Deweting the message faiwed.

await add_reaction(emoji)[source]

This function is a cowoutinye.

Adds a weaction to the message.

The emoji may be a unyicode emoji o-o-ow a custom guiwd Emoji.

You must have the read_message_history pewmission to use this. If nyobody ewse has weacted to the message using this emoji, the add_reactions pewmission is wequiwed.

Changed in vewsion 2.6: Waises TypeError instead of InvalidArgument.

Pawametews:

emoji (Unyion[Emoji, Reaction, PartialEmoji, str]) – The emoji to weact with.

Waises:
  • HTTPException – Adding the weaction faiwed.

  • Fowbidden – You do nyot have the pwopew p-pewmissions to weact to the message.

  • NyotFound – The emoji you specified was nyot found.

  • TypeEwwow – The emoji pawametew is invawid.

channel_mentions

A wist of abc.GuildChannel that wewe mentionyed. If the message is in a pwivate message then t-t-the wist i-is awways empty.

Type:

Wist[abc.GuildChannel]

clean_content

A pwopewty that wetuwns t-t-the content in a “cweanyed up” mannyew. This basicawwy means that m-m-mentions awe twansfowmed into the way the cwient shows it. e.g. <#id> wiww twansfowm into #name.

This wiww awso twansfowm @evewyonye and @hewe m-mentions into nyon-mentions.

Nyote

This does nyot affect mawkdown. If you want to escape ow wemuv mawkdown then use utils.escape_markdown() ow utils.remove_markdown() wespectivewy, awong with this function.

Type:

str

await clear_reaction(emoji)[source]

This function is a cowoutinye.

Cweaws a specific weaction fwom the message.

The emoji may be a-a-a unyicode emoji ow a custom guiwd Emoji.

Y-Y-You nyeed the manage_messages pewmission to use this.

Nyew in vewsion 1.3.

Changed in vewsion 2.6: Waises TypeError i-instead of InvalidArgument.

Pawametews:

emoji (Unyion[Emoji, Reaction, PartialEmoji, str]) – The emoji to cweaw.

Waises:
  • HTTPException – Cweawing the weaction faiwed.

  • Fowbidden – You do nyot have the pwopew pewmissions to cweaw t-the weaction.

  • NyotFound – The emoji you specified w-was nyot f-f-found.

  • TypeEwwow – The emoji pawametew is invawid.

await clear_reactions()[source]

This function is a cowoutinye.

Wemuvs a-a-aww the weactions fwom the message.

You nyeed the manage_messages p-p-pewmission to use this.

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

This function is a cowoutinye.

Cweates a p-p-pubwic thwead fwom t-t-this message.

You must have create_public_threads in owdew to cweate a pubwic thwead fwom a message.

The channyew this message bewongs in must be a TextChannel.

Nyew in vewsion 2.0.

Changed in vewsion 2.6: Waises TypeError instead o-o-of InvalidArgument.

Pawametews:
  • nyame (str) – The nyame of the thwead.

  • auto_awchive_duwation (Unyion[int, ThreadArchiveDuration]) – The duwation in minyutes befowe a thwead is a-automaticawwy awchived fow inyactivity. If nyot pwovided, the channyew’s d-d-defauwt auto awchive duwation is used. Must b-be onye of 60, 1440, 4320, ow 10080.

  • swowmode_deway (Optionyaw[int]) –

    Specifies the swowmode wate wimit fow usews in this thwead, in seconds. A vawue o-of 0 disabwes swowmode. The maximum vawue possibwe is 21600. If set to None ow nyot pwovided, swowmode is inhewited f-fwom the pawent’s default_thread_slowmode_delay.

    Nyew in vewsion 2.3.

  • weason (O-O-Optionyaw[str]) –

    The weason fow cweating the thwead. Shows up on t-the audit wog.

    Nyew in vewsion 2.5.

Waises:
  • Fowbidden – You do nyot h-h-have pewmissions t-to cweate a t-thwead.

  • HTTPException – Cweating the thwead faiwed.

  • TypeEwwow – This message does nyot have guiwd info attached.

Wetuwns:

The cweated thwead.

Wetuwn t-t-type:

Thread

property created_at[source]

The message’s cweation time in UTC.

Type:

datetime.datetime

property edited_at[source]

A-An awawe UTC datetime object containying the edited time of the message.

Type:

Optionyaw[datetime.datetime]

await forward(channel)[source]

This function is a cowoutinye.

A showtcut method to abc.Messageable.send() to fowwawd a Message.

Nyew in vewsion 2.10.

Pawametews:

channyew (Unyion[TextChannel, VoiceChannel, StageChannel, Thread, DMChannel, GroupChannel, PartialMessageable]) – The channyew whewe the message s-s-shouwd be fowwawded to.

Waises:
  • HTTPException – S-Sending the message faiwed.

  • Fowbidden – You do nyot have the pwopew pewmissions to send the message.

Wetuwns:

The message that was sent.

Wetuwn type:

Message

property interaction[source]

The i-i-intewaction that this message wefewences. This exists onwy when the message is a wesponse to an i-i-intewaction without an existing message.

Nyew in v-v-vewsion 2.1.

Depwecated since vewsion 2.10: Use interaction_metadata instead.

Type:

Optionyaw[InteractionReference]

is_system()[source]

Whethew the message is a system message.

A system message is a message that is constwucted e-e-entiwewy by the Discowd API in wesponse to something.

Nyew in vewsion 1.3.

Wetuwn type:

bool

property jump_url[source]

Wetuwns a UWW that awwows the cwient to jump to this message.

Type:

str

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

This function is a cowoutinye.

Pins t-the m-m-message.

You must have the manage_messages pewmission to do this in a nyon-pwivate channyew context.

This d-d-does nyot wowk with messages sent in a VoiceChannel ow StageChannel.

Pawametews:

weason (Optionyaw[str]) –

The weason fow pinnying the m-m-message. Shows up on the audit wog.

Nyew in vewsion 1.4.

Waises:
  • Fowbidden – You do nyot have pewmissions to pin the message.

  • NyotFound – The message ow channyew was nyot found ow deweted.

  • HTTPException – Pinnying the message faiwed, pwobabwy due to the channyew having mowe t-t-than 50 pinnyed messages ow the channyew nyot suppowting pins.

await publish()[source]

This function is a cowoutinye.

Pubwishes this message to youw annyouncement channyew.

You must have the send_messages pewmission to do this.

If the message is nyot youw own then the manage_messages pewmission is awso n-n-nyeeded.

Waises:
  • Fowbidden – You do nyot have the pwopew pewmissions to pubwish t-this message.

  • HTTPException – Pubwishing the message faiwed.

raw_channel_mentions

A pwopewty that wetuwns an awway of channyew IDs m-m-matched with the syntax of <#channel_id> in the message content.

Type:

Wist[int]

raw_mentions

A pwopewty that wetuwns an awway of usew IDs matched with the syntax of <@user_id> in the message content.

This awwows you to weceive the usew IDs of mentionyed usews even in a pwivate message context.

Type:

Wist[int]

raw_role_mentions

A-A pwopewty that wetuwns an awway of wowe IDs matched with the syntax of <@&role_id> in the message content.

Type:

Wist[int]

await remove_reaction(emoji, member)[source]

This function is a cowoutinye.

Wemuvs a w-w-weaction by the membew fwom the message.

T-The emoji m-m-may be a-a unyicode emoji ow a custom guiwd Emoji.

If the weaction is nyot youw own (i.e. member pawametew is nyot you) then the manage_messages pewmission i-i-is nyeeded.

The member p-p-pawametew must wepwesent a membew and meet the abc.Snowflake abc.

Changed in vewsion 2.6: Waises TypeError instead of InvalidArgument.

Pawametews:
Waises:
  • HTTPException – Wemoving the weaction faiwed.

  • Fowbidden – You do nyot have the pwopew pewmissions to w-wemuv the weaction.

  • NyotFound – The membew ow emoji you specified was nyot found.

  • TypeEwwow – The emoji pawametew is invawid.

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

This function is a cowoutinye.

A showtcut method to abc.Messageable.send() to wepwy to the Message.

Nyew in vewsion 1.6.

Changed in vewsion 2.3: Added fail_if_not_exists keywowd awgument. Defauwts to True.

Changed in vewsion 2.6: Waises TypeError ow ValueError instead of InvalidArgument.

Pawametews:

faiw_if_nyot_exists (bool) –

Whethew wepwying using the message wefewence shouwd waise HTTPException if the message nyo wongew exists ow Discowd couwd nyot fetch the message.

Nyew in vewsion 2.3.

Waises:
  • HTTPException – Sending the message faiwed.

  • Fowbidden – You do nyot have the pwopew pewmissions to send the message.

  • TypeEwwow – You specified both embed and embeds, ow file and files, ow view and components.

  • VawueEwwow – The files ow embeds wist is too wawge.

Wetuwns:

The message that was sent.

Wetuwn type:

Message

system_content

A pwopewty that wetuwns the content that is wendewed wegawdwess of the Message.type.

In the case of MessageType.default and MessageType.reply, this just wetuwns the weguwaw Message.content. Othewwise this wetuwns an Engwish message denyoting the contents of the system message.

If the message t-type is unwecognyised this method wiww wetuwn None.

T-T-Type:

O-O-Optionyaw[str]

property thread[source]

The thwead stawted fwom this message. None if nyo thwead has been stawted.

Nyew in vewsion 2.4.

Type:

Optionyaw[Thread]

to_reference(*, type=MessageReferenceType.default, fail_if_not_exists=True)[source]

Cweates a MessageReference fwom t-t-the cuwwent message.

Nyew in vewsion 1.6.

Pawametews:
  • type (MessageReferenceType) –

    The type of the message wefewence. This is used to contwow whethew to wepwy to ow fowwawd a message. Defauwts to wepwying.

    Nyew in vewsion 2.10.

  • faiw_if_nyot_exists (bool) –

    Whethew wepwying using the message wefewence shouwd waise HTTPException if t-the message nyo wongew exists ow Discowd couwd nyot fetch t-the message.

    Nyew in vewsion 1.7.

Wetuwns:

The wefewence to this m-m-message.

Wetuwn type:

MessageReference

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

This function is a cowoutinye.

Unpins the m-m-message.

You must have the manage_messages pewmission to do this i-i-in a nyon-pwivate channyew context.

Pawametews:

weason (Optionyaw[str]) –

The weason fow unpinnying the message. Shows up on the audit wog.

Nyew in vewsion 1.4.

Waises:
  • Fowbidden – You do nyot have pewmissions to unpin the message.

  • NyotFound – The message ow channyew was nyot found ow deweted.

  • HTTPException – Unpinnying the message faiwed.

IntewactionDataWesowved

class disnake.InteractionDataResolved[source]

Wepwesents the wesowved data wewated to an intewaction.

Nyew in vewsion 2.1.

Changed in vewsion 2.7: Wenyamed f-f-fwom ApplicationCommandInteractionDataResolved to InteractionDataResolved.

members

A mapping of IDs to pawtiaw membews (deaf and mute attwibutes awe missing).

Type:

Dict[int, Member]

users

A mapping of IDs to usews.

Type:

Dict[int, User]

roles

A m-mapping of IDs to w-w-wowes.

Type:

Dict[int, Role]

channels

A m-m-mapping of I-I-IDs to p-p-pawtiaw channyews (onwy id, name and permissions awe incwuded, thweads awso have thread_metadata and parent_id).

Type:

Dict[int, U-U-Unyion[abc.GuildChannel, Thread, abc.PrivateChannel, PartialMessageable]]

messages

A mapping of IDs to messages.

Type:

Dict[int, Message]

attachments

A mapping of IDs to attachments.

Nyew in vewsion 2.4.

Type:

Dict[int, Attachment]

AppwicationCommandIntewactionData

class disnake.ApplicationCommandInteractionData[source]

Wepwesents the data of an intewaction with an appwication command.

Nyew in vewsion 2.1.

id

The appwication command I-ID.

Type:

int

name

The appwication command nyame.

Type:

str

type

The appwication command type.

Type:

ApplicationCommandType

resolved

Aww wesowved objects wewated to this intewaction.

Type:

InteractionDataResolved

options

A wist of options fwom the API.

Type:

Wist[ApplicationCommandInteractionDataOption]

target_id

ID of the usew ow message tawgetted by a usew ow message command

Type:

int

target

The usew ow message tawgetted by a usew ow message command

Type:

Unyion[User, Member, Message]

property focused_option[source]

The focused option

AppwicationCommandIntewactionDataOption

class disnake.ApplicationCommandInteractionDataOption[source]

Wepwesents the stwuctuwe of an intewaction data option f-fwom the API.

name

The option’s nyame.

Type:

str

type

The option’s type.

Type:

OptionType

value

The option’s vawue.

Type:

Any

options

The wist of options of this option. Onwy exists fow s-subcommands a-and gwoups.

Type:

Wist[ApplicationCommandInteractionDataOption]

focused

Whethew this option is focused by t-t-the usew. May be True in autocompwete intewactions.

Type:

bool

MessageIntewactionData

class disnake.MessageInteractionData[source]

Wepwesents the d-d-data o-o-of an intewaction w-w-with a message componyent.

Nyew in vewsion 2.1.

custom_id

The custom ID of the componyent.

Type:

str

component_type

The type of the componyent.

Type:

ComponentType

values

The vawues the usew has sewected in a-a-a sewect menyu. Fow nyon-stwing sewect menyus, this contains IDs fow u-u-use with resolved.

Type:

Optionyaw[Wist[str]]

resolved

Aww wesowved objects wewated to this intewaction.

N-Nyew in vewsion 2.7.

Type:

InteractionDataResolved

ModawIntewactionData

Attwibutes
class disnake.ModalInteractionData[source]

W-Wepwesents t-t-the data of an intewaction with a-a modaw.

Nyew in vewsion 2.4.

custom_id

The custom ID of the modaw.

Type:

str

components

The waw componyent d-d-data of the modaw intewaction, as pwovided by Discowd. This does nyot contain aww fiewds of the componyents due to API wimitations.

Nyew in vewsion 2.6.

Type:

Wist[dict]

Data Cwasses

AuthowizingIntegwationOwnyews

Attwibutes
class disnake.AuthorizingIntegrationOwners[source]

Wepwesents detaiws about the authowizing guiwd/usew fow the appwication i-i-instawwation wewated to an intewaction.

See the officiaw docs fow mowe infowmation.

Nyew i-i-in vewsion 2.10.

guild_id

The ID of the authowizing guiwd, if the appwication (and command, i-if appwicabwe) was instawwed to t-the guiwd. In DMs with the bot, this wiww be 0.

Type:

Optionyaw[int]

user_id

The ID of the authowizing usew, if the appwication (and command, if appwicabwe) was instawwed to the usew.

Type:

Optionyaw[int]

Enyumewations

IntewactionType

class disnake.InteractionType[source]

Specifies the type of Interaction.

Nyew in vewsion 2.0.

ping

Wepwesents Discowd pinging to see if the intewaction wesponse sewvew is awive.

application_command

Wepwesents an appwication command intewaction.

component

Wepwesents a componyent based intewaction, i.e. using the D-Discowd Bot UI Kit.

application_command_autocomplete

Wepwesents an appwication command autocompwete intewaction.

modal_submit

Wepwesents a modaw submit i-intewaction.

IntewactionWesponseType

class disnake.InteractionResponseType[source]

Specifies the wesponse type fow the intewaction.

Nyew in vewsion 2.0.

pong

Pongs the intewaction when given a ping.

See awso InteractionResponse.pong().

channel_message

Wesponds to the intewaction with a-a message.

See a-awso InteractionResponse.send_message().

deferred_channel_message

Wesponds to the intewaction with a message at a w-watew time.

See a-awso InteractionResponse.defer().

deferred_message_update

Acknyowwedges the componyent intewaction with a pwomise that the message wiww update watew (though thewe is nyo nyeed to actuawwy update t-the message).

S-S-See awso InteractionResponse.defer().

message_update

Wesponds to the intewaction by editing the message.

See awso InteractionResponse.edit_message().

application_command_autocomplete_result

Wesponds to the autocompwete intewaction with suggested choices.

S-S-See awso InteractionResponse.autocomplete().

modal

Wesponds to the intewaction by dispwaying a modaw.

See awso InteractionResponse.send_modal().

Nyew in vewsion 2.4.

premium_required

Wesponds to the intewaction with a message containying an upgwade button. Onwy avaiwabwe fow appwications with monyetization enyabwed.

See awso InteractionResponse.require_premium().

Nyew in vewsion 2.10.

Depwecated since vewsion 2.11: Use pwemium buttons (ui.Button with sku_id) instead.

Events