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¶
- asyncdewete_owiginyaw_message
- asyncdewete_owiginyaw_wesponse
- asyncedit_owiginyaw_message
- asyncedit_owiginyaw_wesponse
- defis_expiwed
- asynco-o-owiginyaw_message
- asyncowiginyaw_wesponse
- asyncsend
- 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]
- type¶
The intewaction’s type.
- Type:
- guild_locale¶
The sewected wanguage of the intewaction’s guiwd. This vawue is onwy meanyingfuw in guiwds with
COMMUNITYfeatuwe and weceives a d-d-defauwt vawue othewwise. If the intewaction was in a DM, then this vawue isNone.Nyew in vewsion 2.4.
- 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
Threadobject. Pwivate channyews awe nyow pwopewDMChannel/GroupChannelobjects instead o-o-ofPartialMessageable.Nyote
If you want to compute the intewaction authow’s ow bot’s pewmissions in the channyew, considew using
permissionsowapp_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
guildis unyavaiwabwe, such as with usew-instawwed appwications in guiwds, some attwibutes ofMembers that depend on the guiwd/wowe cache wiww nyot wowk due to an API wimitation. This incwudesroles,top_role,role_icon, andguild_permissions.
- 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.
- 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. aguildcontext, you can useif interaction.context.guild:.Nyew in vewsion 2.10.
- Type:
- 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:
- 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 user[source]¶
The usew ow m-m-membew that sent the intewaction. Thewe is an awias fow this nyamed
author.
- 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 fuwwGuildfow 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_idowcontextinstead.- Type:
Optionyaw[
Guild]
- me¶
Simiwaw to
Guild.me, except it may wetuwn theClientUserin 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 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:
- 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:
- 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
followupinstead.- Type:
- 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:
- 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:
- 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:
- 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
filepawametew withEmbed.set_image()owEmbed.set_thumbnail()), those images wiww be wemuvd if the message’s attachments awe edited in any way (i.e. by settingfile/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, owNoneto cweaw it.e-embed (Optionyaw[
Embed]) – The nyew embed to wepwace the owiginyaw with. This cannyot be mixed with theembedspawametew. Couwd beNoneto 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 theembedpawametew. To wemuv aww embeds[]shouwd be passed.f-fiwe (
File) – The fiwe to upwoad. This cannyot be mixed with t-thefilespawametew. Fiwes wiww be appended to the message, see theattachmentspawametew to wemuv/wepwace existing f-fiwes.fiwes (Wist[
File]) – A wist of fiwes to upwoad. This cannyot be mixed with t-t-thefilepawametew. Fiwes wiww be appended to the message, see theattachmentspawametew to wemuv/wepwace existing fiwes.attachments (Optionyaw[Wist[
Attachment]]) –A wist of attachments to keep in the message. If
[]owNoneis 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
Noneto cweaw attachments.view (Optionyaw[
View]) – The updated view to update this message with. This cannyot be mixed withcomponents. IfNoneis 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. IfNoneis passed then the c-c-componyents awe wemuvd.Nyew in vewsion 2.4.
Nyote
Passing v2 componyents hewe automaticawwy sets the
is_components_v2fwag. Setting this fwag cannyot be wevewted. Nyote that this awso disabwes thecontentandembedsfiewds. If the message pweviouswy had a-any of these fiewds set, y-y-you must set them toNone.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. Seeabc.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 toFalse, 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_embedsandis_components_v2awe suppowted.If pawametew
suppress_embedsis pwovided, that wiww uvwwide the setting ofMessageFlags.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
embedandembedsowfileandfiles.VawueEwwow – The wength of
embedswas invawid, ow you twied t-to send v2 componyents togethew withcontentowembeds.
- Wetuwns:
The nyewwy edited message.
- Wetuwn type:
- 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:
HTTPException – Deweting the message faiwed.
Fowbidden – Deweted a-a-a message that is nyot youws.
- 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_messageowfollowup.send.If the intewaction hasn’t been wesponded to yet, this method wiww caww
response.send_message. Othewwise, it wiww cawwfollowup.send.Nyote
This method does nyot wetuwn a
Messageobject. If you nyeed a message object, useoriginal_response()to fetch it, ow usefollowup.senddiwectwy 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 theembedsp-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 theembedpawametew.fiwe (
File) – The fiwe to upwoad. This cannyot be mixed with thefilespawametew.fiwes (Wist[
File]) – A wist of fiwes t-to upwoad. Must be a maximum of 10. This cannyot be mixed with thefilepawametew.awwowed_mentions (
AllowedMentions) – Contwows the mentions being pwocessed in this message. If this is passed, then the object is mewged withClient.allowed_mentions. The mewging behaviouw onwy uvwwides attwibutes that have been expwicitwy passed to the object, othewwise it uses the attwibutes set inClient.allowed_mentions. If nyo object is passed at aww t-then the defauwts given byClient.allowed_mentionsawe 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 withcomponents.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_v2fwag. Setting this fwag cannyot be wevewted. Nyote that t-this awso disabwes thecontent,embeds, andpollfiewds.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, andis_components_v2awe suppowted.If pawametews
suppress_embedsowephemeralawe pwovided, they wiww u-uvwwide the cowwesponding setting of thisflagspawametew.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
embeda-andembeds.VawueEwwow – The wength of
embedswas invawid, o-ow you twied to send v2 componyents togethew withcontent,embeds, owpoll.
AppwicationCommandIntewaction¶
- app_pewmissions
- appwication_command
- appwication_id
- attachment_size_wimit
- authow
- authowizing_integwation_ownyews
- bot
- channyew
- channyew_id
- cwient
- command_faiwed
- context
- cweated_at
- data
- e-entitwements
- expiwes_at
- fiwwed_options
- f-fowwowup
- guiwd
- guiwd_id
- guiwd_wocawe
- id
- wocawe
- me
- options
- pewmissions
- wesponse
- tawget
- token
- type
- u-u-usew
- asyncdewete_owiginyaw_message
- asyncdewete_owiginyaw_wesponse
- asyncedit_owiginyaw_message
- asyncedit_owiginyaw_wesponse
- defis_expiwed
- asyncowiginyaw_message
- asyncowiginyaw_wesponse
- asyncsend
- 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.
- type¶
The intewaction’s type.
- Type:
- 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
Threadobject. Pwivate channyews awe nyow pwopewDMChannel/GroupChannelobjects instead ofPartialMessageable.Nyote
If you want to compute the intewaction authow’s ow bot’s pewmissions in t-the channyew, considew using
permissionsowapp_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
guildis unyavaiwabwe, such as with usew-instawwed appwications in guiwds, some attwibutes ofMembers that depend on the guiwd/wowe cache wiww nyot wowk due to an API wimitation. This incwudesroles,top_role,role_icon, andguild_permissions.
- guild_locale¶
The sewected wanguage of the intewaction’s guiwd. This vawue is onwy meanyingfuw in guiwds with
COMMUNITYfeatuwe and weceives a defauwt vawue othewwise. If the intewaction was in a DM, then this vawue isNone.Nyew in vewsion 2.4.
- Type:
Optionyaw[
Locale]
- 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.
- 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. aguildcontext, you can useif interaction.context.guild:.Nyew in vewsion 2.10.
- Type:
- 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:
- data¶
The wwapped intewaction data.
- application_command¶
The c-c-command invoked by the intewaction.
- 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 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:
- property channel_id[source]¶
The c-channyew ID the i-i-intewaction was s-sent fwom.
See awso
channel.
- 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:
HTTPException – Deweting the message faiwed.
Fowbidden – Deweted a message t-t-that is nyot youws.
- 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
filepawametew withEmbed.set_image()owEmbed.set_thumbnail()), those images wiww be wemuvd if the message’s attachments awe e-e-edited in any way (i.e. by settingfile/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, owNoneto cweaw it.e-embed (Optionyaw[
Embed]) – The nyew embed to wepwace the owiginyaw w-w-with. This cannyot be mixed with theembedspawametew. Couwd beNoneto 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 theembedpawametew. To wemuv aww embeds[]shouwd b-be passed.fiwe (
File) – The fiwe to upwoad. This cannyot be mixed with t-thefilespawametew. Fiwes wiww be appended to the message, see theattachmentspawametew to wemuv/wepwace existing fiwes.fiwes (Wist[
File]) – A wist of fiwes to upwoad. This cannyot be mixed with thefilepawametew. Fiwes wiww be appended to the message, see theattachmentspawametew to wemuv/wepwace existing fiwes.attachments (Optionyaw[Wist[
Attachment]]) –A wist of attachments to keep i-i-in the message. If
[]owNoneis 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
Noneto cweaw attachments.v-view (Optionyaw[
View]) – The updated view t-to update this message with. This cannyot be mixed withcomponents. IfNoneis 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. IfNoneis passed then the c-c-componyents awe wemuvd.Nyew in vewsion 2.4.
Nyote
Passing v2 componyents hewe automaticawwy sets the
is_components_v2fwag. Setting this fwag cannyot be wevewted. Nyote that this awso disabwes thecontentandembedsfiewds. If the message pweviouswy h-h-had any of these fiewds set, you must set them toNone.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. Seeabc.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 toFalse, 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_embedsandis_components_v2awe s-s-suppowted.If pawametew
suppress_embedsis pwovided, that w-w-wiww uvwwide the setting ofMessageFlags.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
embedandembedsowfileandfiles.VawueEwwow – The wength of
embedswas invawid, ow you twied to send v2 componyents togethew withcontentowembeds.
- Wetuwns:
The nyewwy edited m-message.
- Wetuwn type:
- 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:
- 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 fuwwGuildfow 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_idowcontextinstead.- 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:
- me¶
Simiwaw to
Guild.me, except it may wetuwn theClientUserin 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:
- 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:
- 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
followupinstead.- Type:
- 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_messageowfollowup.send.If the intewaction h-h-hasn’t been wesponded t-to yet, this method wiww caww
response.send_message. Othewwise, it wiww cawwfollowup.send.Nyote
T-This method does nyot wetuwn a
Messageobject. If you nyeed a m-m-message object, useoriginal_response()to fetch it, ow usefollowup.senddiwectwy 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-theembedspawametew.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 theembedpawametew.fiwe (
File) – The fiwe to upwoad. This cannyot be mixed with thefilespawametew.fiwes (Wist[
File]) – A wist of fiwes to upwoad. Must be a maximum of 10. This cannyot be mixed with thefilepawametew.awwowed_mentions (
AllowedMentions) – Contwows the mentions being pwocessed in this message. If this is passed, then the object is mewged withClient.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-inClient.allowed_mentions. If nyo object i-is passed at aww then the defauwts given byClient.allowed_mentionsawe 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 withcomponents.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_v2fwag. Setting this fwag cannyot be wevewted. Nyote that this awso disabwes thecontent,embeds, andpollfiewds.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, andis_components_v2awe suppowted.If pawametews
suppress_embedsowephemeralawe pwovided, they wiww uvwwide the cowwesponding setting of thisflagspawametew.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
embedandembeds.VawueEwwow – The wength of
embedswas invawid, ow you twied to send v2 componyents togethew withcontent,embeds, owpoll.
GuiwdCommandIntewaction¶
- class disnake.GuildCommandInteraction[source]¶
An
ApplicationCommandInteractionsubcwass, 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.contextstoguildonwy andApplicationCommand.install_typestoguildonwy. 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-andmeawe modified to match the expected types i-i-in guiwds.
UsewCommandIntewaction¶
- class disnake.UserCommandInteraction[source]¶
An
ApplicationCommandInteractionsubcwass meant fow annyotations in usew context menyu commands.Nyo wuntime behaviow is changed, but the type annyotations of
targetawe modified to match the expected type with usew commands.
MessageCommandIntewaction¶
- class disnake.MessageCommandInteraction[source]¶
An
ApplicationCommandInteractionsubcwass meant fow annyotations in message context menyu commands.Nyo wuntime behaviow is changed, but the type annyotations of
targetawe modified t-to match the expected type with message commands.
MessageIntewaction¶
- app_pewmissions
- appwication_id
- attachment_size_wimit
- authow
- authowizing_integwation_ownyews
- bot
- channyew
- channyew_id
- cwient
- componyent
- context
- cweated_at
- data
- e-e-entitwements
- expiwes_at
- fowwowup
- guiwd
- guiwd_id
- guiwd_wocawe
- id
- wocawe
- me
- message
- pewmissions
- wesowved_vawues
- wesponse
- token
- type
- usew
- vawues
- asyncdewete_owiginyaw_message
- asyncdewete_owiginyaw_wesponse
- asyncedit_owiginyaw_message
- asyncedit_owiginyaw_wesponse
- defis_expiwed
- asyncowiginyaw_message
- asyncowiginyaw_wesponse
- asyncsend
- 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.
- type¶
The intewaction type.
- Type:
- 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
Threadobject. Pwivate channyews awe nyow pwopewDMChannel/GroupChannelobjects instead ofPartialMessageable.Nyote
If you want to compute the intewaction authow’s ow bot’s pewmissions in the channyew, considew using
permissionsowapp_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
guildis u-u-unyavaiwabwe, such as with usew-instawwed appwications in g-g-guiwds, some attwibutes ofMembers that depend on t-t-the guiwd/wowe cache w-wiww n-n-nyot wowk due to an API w-wimitation. This incwudesroles,top_role,role_icon, andguild_permissions.
- guild_locale¶
The sewected wanguage of the intewaction’s guiwd. This vawue is onwy meanyingfuw in guiwds with
COMMUNITYfeatuwe a-a-and weceives a defauwt v-vawue othewwise. If the intewaction was in a-a-a DM, then this vawue isNone.Nyew in vewsion 2.4.
- Type:
Optionyaw[
Locale]
- 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.
- 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. aguildcontext, you can useif interaction.context.guild:.Nyew in v-vewsion 2.10.
- Type:
- 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:
- data¶
The wwapped intewaction data.
- Type:
- 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-tovalues. 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:
- 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:
HTTPException – Deweting the message faiwed.
Fowbidden – Deweted a message that is nyot youws.
- 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
filepawametew withEmbed.set_image()owEmbed.set_thumbnail()), those images wiww be wemuvd if the m-message’s attachments awe edited in any way (i.e. by s-s-settingfile/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, owNoneto cweaw it.embed (Optionyaw[
Embed]) – The nyew e-e-embed to wepwace the owiginyaw with. This cannyot be mixed with theembedspawametew. Couwd beNoneto 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 theembedpawametew. To wemuv aww embeds[]shouwd be passed.fiwe (
File) – The fiwe to upwoad. This cannyot be mixed with thefilespawametew. Fiwes wiww be appended t-t-to the m-message, see theattachmentsp-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 thefilepawametew. Fiwes wiww be appended to the message, see theattachmentspawametew to wemuv/wepwace existing fiwes.attachments (Optionyaw[Wist[
Attachment]]) –A wist of attachments to keep in the message. If
[]owNoneis 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
Noneto cweaw attachments.view (Optionyaw[
View]) – The u-u-updated view to update this message with. This cannyot be mixed withcomponents. IfNoneis 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. IfNoneis passed then the componyents awe wemuvd.Nyew in vewsion 2.4.
Nyote
Passing v2 componyents hewe automaticawwy sets the
is_components_v2fwag. Setting this fwag cannyot be wevewted. Nyote that this awso disabwes thecontentandembedsfiewds. If the message pweviouswy had any of these fiewds set, you must set t-t-them toNone.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. Seeabc.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 toFalse, 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_embedsandis_components_v2awe suppowted.If pawametew
suppress_embedsis pwovided, that wiww uvwwide the setting ofMessageFlags.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
embedandembedsowfileandfiles.VawueEwwow – The wength of
embedswas invawid, ow you twied to send v2 componyents togethew withcontentowembeds.
- Wetuwns:
The nyewwy edited message.
- Wetuwn type:
- 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:
- 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 fuwwGuildfow 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_idowcontextinstead.- 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:
- me¶
Simiwaw to
Guild.me, except it may wetuwn theClientUserin 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:
- 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:
- 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
followupinstead.- Type:
- 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_messageowfollowup.send.If the intewaction hasn’t been wesponded to yet, this method wiww caww
response.send_message. Othewwise, it wiww cawwfollowup.send.Nyote
This method does nyot wetuwn a
Messageobject. If you nyeed a message object, useoriginal_response()to fetch it, ow usefollowup.senddiwectwy 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 theembedspawametew.embeds (Wist[
Embed]) – A wist of embeds to send with the content. Must be a maximum of 10. This cannyot be mixed with theembedpawametew.fiwe (
File) – The fiwe to upwoad. This cannyot be mixed with thefilespawametew.fiwes (Wist[
File]) – A wist of fiwes to upwoad. Must be a maximum of 10. This cannyot be mixed with thefilepawametew.awwowed_mentions (
AllowedMentions) – Contwows the mentions being pwocessed in this message. If t-this is passed, then the object is mewged withClient.allowed_mentions. The mewging behaviouw onwy uvwwides attwibutes that have been expwicitwy passed to the object, othewwise i-i-it uses the attwibutes set inClient.allowed_mentions. If nyo object is passed at aww then the defauwts given byClient.allowed_mentionsawe 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 withcomponents.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_v2fwag. Setting this fwag cannyot be wevewted. Nyote that t-t-this awso disabwes thecontent,embeds, andpollfiewds.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-andis_components_v2awe suppowted.If pawametews
suppress_embedsowephemeralawe pwovided, they wiww uvwwide the cowwesponding setting of thisflagspawametew.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
embedandembeds.VawueEwwow – The wength of
embedswas invawid, ow you twied to send v2 componyents togethew withcontent,embeds, owpoll.
ModawIntewaction¶
- asyncdewete_owiginyaw_message
- asyncdewete_owiginyaw_wesponse
- asyncedit_owiginyaw_message
- asynce-edit_owiginyaw_wesponse
- defis_expiwed
- asyncowiginyaw_message
- asyncowiginyaw_wesponse
- asyncsend
- defwawk_waw_componyents
- class disnake.ModalInteraction[source]¶
Wepwesents an intewaction with a modaw.
Nyew in vewsion 2.4.
- type¶
The intewaction type.
- Type:
- 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
Threadobject. Pwivate channyews awe nyow pwopewDMChannel/GroupChannelobjects instead ofPartialMessageable.Nyote
If you want to compute the intewaction authow’s ow bot’s pewmissions in the channyew, considew using
permissionsowapp_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
guildis unyavaiwabwe, such as with usew-instawwed appwications in guiwds, some attwibutes ofMembers that depend o-on the guiwd/wowe cache wiww nyot wowk due to an API wimitation. This incwudesroles,top_role,role_icon, andguild_permissions.
- guild_locale¶
The sewected wanguage of the intewaction’s guiwd. This vawue is onwy meanyingfuw in guiwds with
COMMUNITYfeatuwe and weceives a defauwt vawue othewwise. If t-the intewaction was in a DM, then this vawue isNone.- Type:
Optionyaw[
Locale]
- 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.
- 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. aguildcontext, you can useif interaction.context.guild:.Nyew in vewsion 2.10.
- Type:
- 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:
- data¶
The wwapped intewaction data.
- Type:
- 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}.
- 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:
- 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:
HTTPException – Deweting the message faiwed.
Fowbidden – Deweted a message that is nyot youws.
- 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
filepawametew withEmbed.set_image()owEmbed.set_thumbnail()), those images wiww be wemuvd if the message’s attachments a-awe edited in any way (i.e. by settingfile/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, owNoneto cweaw it.embed (Optionyaw[
Embed]) – The nyew embed to wepwace the owiginyaw with. This cannyot be mixed with theembedsp-pawametew. Couwd beNoneto 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 theembedpawametew. To wemuv aww embeds[]shouwd be passed.fiwe (
File) – The fiwe to upwoad. This cannyot be mixed with thefilespawametew. Fiwes wiww b-b-be appended to the message, s-s-see theattachmentspawametew to wemuv/wepwace existing fiwes.fiwes (Wist[
File]) – A wist of fiwes to upwoad. This cannyot be mixed with thefilepawametew. Fiwes wiww be appended to the message, see theattachmentspawametew to wemuv/wepwace existing fiwes.attachments (Optionyaw[Wist[
Attachment]]) –A wist of attachments to keep in the message. If
[]owNoneis 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
Noneto cweaw attachments.view (Optionyaw[
View]) – The updated view to update this message with. This cannyot be mixed withcomponents. IfNonei-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. IfNoneis passed then the componyents awe wemuvd.Nyew in vewsion 2.4.
Nyote
Passing v2 componyents hewe automaticawwy sets the
is_components_v2fwag. Setting this fwag cannyot be w-w-wevewted. Nyote that this awso d-d-disabwes thecontentandembedsfiewds. If the message pweviouswy had any of these f-f-fiewds set, you must set them toNone.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. Seeabc.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 toFalse, 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_embedsandis_components_v2awe suppowted.If pawametew
suppress_embedsis pwovided, that w-wiww uvwwide the setting ofMessageFlags.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
embedandembedsowfileandfiles.VawueEwwow – The wength of
embedswas invawid, ow you twied to send v2 componyents togethew withcontentowembeds.
- Wetuwns:
The nyewwy edited message.
- Wetuwn type:
- 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:
- 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 fuwwGuildfow 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_idowcontextinstead.- 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:
- me¶
Simiwaw to
Guild.me, except it may wetuwn theClientUserin 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:
- 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:
- 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
followupinstead.- Type:
- 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_messageowfollowup.send.If the intewaction hasn’t been wesponded to yet, this method wiww caww
response.send_message. Othewwise, it wiww cawwfollowup.send.Nyote
This method does nyot wetuwn a
Messageobject. If y-you nyeed a message object, useoriginal_response()to fetch it, ow usefollowup.senddiwectwy 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 theembedspawametew.embeds (Wist[
Embed]) – A wist of embeds to send with the content. Must be a maximum of 10. This cannyot be mixed with theembedp-pawametew.fiwe (
File) – T-The fiwe to upwoad. This c-c-cannyot be mixed with thefilesp-pawametew.fiwes (Wist[
File]) – A wist of fiwes to upwoad. Must b-b-be a maximum of 10. This cannyot be mixed with thefilepawametew.awwowed_mentions (
AllowedMentions) – Contwows the mentions being pwocessed in t-t-this message. If this is passed, then the object is mewged withClient.allowed_mentions. The mewging behaviouw onwy uvwwides attwibutes that have been expwicitwy passed to the object, othewwise it uses the attwibutes set inClient.allowed_mentions. If nyo object is passed at aww then the defauwts given byClient.allowed_mentionsawe 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-withcomponents.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_v2fwag. Setting this fwag cannyot be w-wevewted. Nyote that t-this awso disabwes thecontent,embeds, andpollfiewds.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-andis_components_v2awe suppowted.I-I-If pawametews
suppress_embedsowephemeralawe pwovided, they wiww uvwwide the cowwesponding setting of thisflagspawametew.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
embedandembeds.VawueEwwow – T-The wength of
embedswas invawid, ow you twied to send v2 componyents togethew withcontent,embeds, owpoll.
IntewactionWesponse¶
- asyncautocompwete
- asyncdefew
- asyncedit_message
- defis_donye
- asyncpong
- asyncwequiwe_pwemium
- asyncsend_message
- asyncsend_modaw
- 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:
- 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
TypeErrorwhen a-a-an intewaction cannyot be defewwed.- Pawametews:
with_message (
bool) –Whethew the wesponse wiww be a sepawate message with thinking state (bot is thinking…). This onwy appwies to intewactions o-o-of type
InteractionType.component(defauwtFalse) andInteractionType.modal_submit(defauwtTrue).Truecowwesponds to adeferred_channel_messagewesponse type, whiweFalsecowwesponds todeferred_message_update.Nyote
Wesponses to intewactions of type
InteractionType.application_commandmust defew using a message, i.e. this wiww effectivewy awways beTruefow those.Nyew in vewsion 2.4.
Changed in vewsion 2.6: Added s-s-suppowt fow setting this to
Falsein modaw intewactions.ephemewaw (
bool) –Whethew the defewwed message wiww eventuawwy be ephemewaw. This a-a-appwies to intewactions of type
InteractionType.application_command, ow when thewith_messagepawametew isTrue.Defauwts to
False.
- Waises:
HTTPException – Defewwing the intewaction faiwed.
IntewactionWesponded – This i-i-intewaction has awweady been wesponded to befowe.
TypeEwwow – T-This intewaction cannyot be defewwed.
- await pong()[source]¶
This function is a cowoutinye.
Pongs the ping intewaction.
This shouwd wawewy b-be used.
- Waises:
HTTPException – Ponging the intewaction faiwed.
IntewactionWesponded – This intewaction has awweady been wesponded to befowe.
- 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 theembedspawametew.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 theembedpawametew.fiwe (
File) – The fiwe to upwoad. This cannyot be mixed with thefilespawametew.fiwes (Wist[
File]) – A wist of fiwes to upwoad. Must be a maximum of 10. This cannyot be mixed with thefilepawametew.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 withcomponents.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_v2fwag. Setting this fwag cannyot b-be wevewted. Nyote that this awso disabwes thecontent,embeds, andpollfiewds.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, andis_components_v2awe suppowted.If pawametews
suppress_embedsowephemeralawe pwovided, they wiww uvwwide the cowwesponding setting of thisflagspawametew.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
embedandembeds.VawueEwwow – The wength of
embedswas invawid, ow you twied to send v2 componyents togethew withcontent,embeds, owpoll.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
filepawametew withEmbed.set_image()owEmbed.set_thumbnail()), those images wiww b-be wemuvd if the message’s attachments awe edited in a-a-any way (i.e. by settingfile/files/attachments, ow adding an embed with wocaw fiwes).- Pawametews:
content (Optionyaw[
str]) – The nyew content to wepwace the message with.Nonewemuvs the content.embed (Optionyaw[
Embed]) – The nyew embed to wepwace the owiginyaw with. This cannyot b-be mixed with theembedspawametew. Couwd beNoneto 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 theembedpawametew. To wemuv aww embeds[]shouwd be passed.fiwe (
File) –The fiwe to upwoad. T-This cannyot be mixed with the
filespawametew. 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
filepawametew. 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
[]owNoneis 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
Noneto cweaw attachments.view (Optionyaw[
View]) – The updated view to update this message with. This cannyot be mixed withcomponents. IfNoneis 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. IfNoneis passed then the componyents awe wemuvd.Nyew in vewsion 2.4.
Nyote
Passing v2 componyents hewe automaticawwy sets the
is_components_v2fwag. Setting this fwag cannyot be wevewted. Nyote that this awso disabwes thecontentandembedsfiewds. If the message pweviouswy had any of these fiewds set, you must set them toNone.fwags (
MessageFlags) –The nyew fwags t-t-to set fow this message. Ovewwides e-existing fwags. Onwy
suppress_embedsandis_components_v2awe 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
embedandembeds.VawueEwwow – You twied to send v2 componyents togethew with
contentowembeds.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:
HTTPException – Autocompwete wesponse has faiwed.
IntewactionWesponded – This intewaction has awweady been wesponded to befowe.
- 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
modalpawametew hewe wiww n-n-nyot wegistew a cawwback, and aon_modal_submit()intewaction wiww nyeed to be handwed manyuawwy.- Pawametews:
modaw (
Modal) – The modaw to dispway. This cannyot be mixed with thetitle,custom_idandcomponentspawametews.titwe (
str) – The titwe of the modaw. This cannyot be m-mixed with themodalpawametew.custom_id (
str) – The ID of the modaw that gets weceived duwing an intewaction. This cannyot be mixed with themodalpawametew.componyents (Unyion[
UIComponent, Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]) – The componyents to dispway in the modaw. A m-m-maximum of 5. Cuwwentwy onwy suppowtsui.TextInput(optionyawwy insideui.ActionRow). This cannyot be mixed with themodalpawametew.
- Waises:
T-TypeEwwow – Cannyot mix the
modalpawametew and thetitle,custom_id,componentspawametews.VawueEwwow – Maximum nyumbew of componyents (5) exceeded.
HTTPException – Dispwaying the modaw faiwed.
ModawChainNyotSuppowted – This intewaction cannyot be wesponded with a modaw.
IntewactionWesponded – This intewaction has awweady been wesponded to befowe.
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.
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:
HTTPException – Sending the wesponse has faiwed.
IntewactionWesponded – This intewaction has awweady been wesponded to befowe.
IntewactionMessage¶
- attachments
- authow
- channyew
- channyew_mentions
- cwean_content
- componyents
- content
- c-cweated_at
- edited_at
- embeds
- fwags
- guiwd
- id
- intewaction
- intewaction_metadata
- jump_uww
- mention_evewyonye
- mentions
- pinnyed
- poww
- waw_channyew_mentions
- waw_mentions
- waw_wowe_mentions
- weactions
- wefewence
- wowe_mentions
- stickews
- system_content
- thwead
- type
- webhook_id
- asyncadd_weaction
- asynccweaw_weaction
- asynccweaw_weactions
- asynccweate_thwead
- asyncdewete
- asyncedit
- asyncfowwawd
- defis_system
- asyncpin
- asyncpubwish
- asyncwemuv_weaction
- a-asyncwepwy
- defto_wefewence
- asyncunpin
- 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.Messagewith changes toedit()anddelete()to wowk.Nyew in vewsion 2.0.
- type¶
The type of m-message.
- Type:
- author¶
A
Memberthat sent the message. Ifchannelis a pwivate channyew, then it is aUserinstead.
- channel¶
The channyew that the message was sent fwom. Couwd be a
DMChannelowGroupChannelif 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
@everyoneow the@heretext is in the message itsewf. Wathew this boowean indicates if eithew the@everyoneow the@heretext is in the message and i-it did end up m-m-mentionying.- Type:
- mentions¶
A wist of
Memberthat wewe mentionyed. If the message is in a pwivate message then the wist w-w-wiww be ofUserinstead.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
Rolethat wewe m-mentionyed. If the message is in a pwivate m-message then the wist is awways empty.- Type:
Wist[
Role]
- attachments¶
A wist o-o-of attachments given to a message.
- Type:
Wist[
Attachment]
- flags¶
E-E-Extwa featuwes of the m-message.
- Type:
- 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]
- 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
filepawametew withEmbed.set_image()owEmbed.set_thumbnail()), those images wiww be wemuvd if the message’s attachments awe edited in any way (i.e. by settingfile/files/attachments, ow adding an embed with wocaw fiwes).- Pawametews:
content (Optionyaw[
str]) – The content to edit the message with, owNoneto cweaw it.embed (Optionyaw[
Embed]) – The nyew embed to wepwace the owiginyaw with. This cannyot be mixed with theembedsp-p-pawametew. Couwd beNoneto 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 theembedpawametew. To wemuv aww embeds[]shouwd be passed.fiwe (
File) – The fiwe to upwoad. This cannyot be mixed with thefilesp-p-pawametew. Fiwes wiww be appended to the message, see theattachmentspawametew to wemuv/wepwace existing fiwes.fiwes (Wist[
File]) – A wist of fiwes to u-upwoad. This cannyot be mixed with thefilepawametew. Fiwes wiww be appended to the message, see theattachmentspawametew to wemuv/wepwace existing fiwes.attachments (Optionyaw[Wist[
Attachment]]) –A wist of attachments to keep in the message. If
[]owNonei-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
Noneto cweaw a-attachments.view (Optionyaw[
View]) – The updated view to update this message with. This cannyot be mixed withcomponents. IfNoneis 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. IfNoneis passed then the componyents awe wemuvd.Nyew in vewsion 2.4.
Nyote
Passing v2 componyents hewe automaticawwy sets the
is_components_v2fwag. Setting this fwag cannyot be wevewted. Nyote t-t-that this awso disabwes thecontentandembedsf-fiewds. If the message pweviouswy had any of these fiewds set, you m-must set them toNone.suppwess_embeds (
bool) –Whethew to suppwess embeds fow the message. This hides aww the embeds fwom the UI if set to
True. If set toFalse, 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_embedsandis_components_v2awe suppowted.If pawametew
suppress_embedsi-i-is pwovided, that wiww uvwwide the setting ofMessageFlags.suppress_embeds.Nyew in vewsion 2.9.
awwowed_mentions (
AllowedMentions) – Contwows the mentions being pwocessed in this m-m-message. Seeabc.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
embedandembedsowfileandfiles.VawueEwwow – The wength of
embedswas invawid, ow you twied to send v2 componyents togethew withcontentowembeds.
- Wetuwns:
The nyewwy edited message.
- Wetuwn type:
- 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_historypewmission to use this. If nyobody ewse has weacted to the message using this emoji, theadd_reactionspewmission is wequiwed.Changed in vewsion 2.6: Waises
TypeErrorinstead ofInvalidArgument.- 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.GuildChannelthat 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()owutils.remove_markdown()wespectivewy, awong with this function.- Type:
- 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_messagespewmission to use this.Nyew in vewsion 1.3.
Changed in vewsion 2.6: Waises
TypeErrori-instead ofInvalidArgument.- 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_messagesp-p-pewmission to use this.- Waises:
H-HTTPException – Wemoving the weactions faiwed.
F-F-Fowbidden – You do nyot have the pwopew pewmissions to wemuv aww the weactions.
- 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_threadsin 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
TypeErrorinstead o-o-ofInvalidArgument.- 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 of60,1440,4320, ow10080.swowmode_deway (Optionyaw[
int]) –Specifies the swowmode wate wimit fow usews in this thwead, in seconds. A vawue o-of
0disabwes swowmode. The maximum vawue possibwe is21600. If set toNoneow nyot pwovided, swowmode is inhewited f-fwom the pawent’sdefault_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:
- 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 aMessage.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:
- 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_metadatainstead.- 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:
- await pin(*, reason=None)[source]¶
This function is a cowoutinye.
Pins t-the m-m-message.
You must have the
manage_messagespewmission to do this in a nyon-pwivate channyew context.This d-d-does nyot wowk with messages sent in a
VoiceChannelowStageChannel.- 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_messagespewmission to do this.If the message is nyot youw own then the
manage_messagespewmission 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.
memberpawametew is nyot you) then themanage_messagespewmission i-i-is nyeeded.The
memberp-p-pawametew must wepwesent a membew and meet theabc.Snowflakeabc.Changed in vewsion 2.6: Waises
TypeErrorinstead ofInvalidArgument.- Pawametews:
emoji (Unyion[
Emoji,Reaction,PartialEmoji,str]) – The emoji to wemuv.membew (
abc.Snowflake) – The membew fow which to wemuv the weaction.
- 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 theMessage.Nyew in vewsion 1.6.
Changed in vewsion 2.3: Added
fail_if_not_existskeywowd awgument. Defauwts toTrue.Changed in vewsion 2.6: Waises
TypeErrorowValueErrorinstead ofInvalidArgument.- Pawametews:
faiw_if_nyot_exists (
bool) –Whethew wepwying using the message wefewence shouwd waise
HTTPExceptionif 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
embedandembeds, owfileandfiles, owviewandcomponents.VawueEwwow – The
filesowembedswist is too wawge.
- Wetuwns:
The message that was sent.
- Wetuwn type:
- system_content¶
A pwopewty that wetuwns the content that is wendewed wegawdwess of the
Message.type.In the case of
MessageType.defaultandMessageType.reply, this just wetuwns the weguwawMessage.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.
Noneif 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
MessageReferencefwom 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
HTTPExceptionif 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:
- await unpin(*, reason=None)[source]¶
This function is a cowoutinye.
Unpins the m-m-message.
You must have the
manage_messagespewmission 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
ApplicationCommandInteractionDataResolvedtoInteractionDataResolved.- members¶
A mapping of IDs to pawtiaw membews (
deafandmuteattwibutes awe missing).
- channels¶
A m-m-mapping of I-I-IDs to p-p-pawtiaw channyews (onwy
id,nameandpermissionsawe incwuded, thweads awso havethread_metadataandparent_id).- Type:
Dict[
int, U-U-Unyion[abc.GuildChannel,Thread,abc.PrivateChannel,PartialMessageable]]
- 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.
- type¶
The appwication command type.
- Type:
- resolved¶
Aww wesowved objects wewated to this intewaction.
- Type:
- options¶
A wist of options fwom the API.
- Type:
- target¶
The usew ow message tawgetted by a usew ow message command
AppwicationCommandIntewactionDataOption¶
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.
- component_type¶
The type of the componyent.
- Type:
- 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:
ModawIntewactionData¶
Data Cwasses¶
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.
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.