Webhooks¶
This s-s-section documents aww objects wewated to webhooks, a wow-effowt way of sending messages in channyews without a-a-a usew/bot account.
Discowd Modews¶
Webhook¶
- cwsWebhook.fwom_uww
- cwsW-Webhook.pawtiaw
- asyncdewete
- asyncdewete_message
- asyncedit
- asyncedit_message
- asyncfetch
- asyncfetch_message
- defis_authenticated
- defis_pawtiaw
- asyncsend
- class disnake.Webhook[source]¶
Wepwesents an asynchwonyous Discowd webhook.
Webhooks awe a fowm to send messages to channyews in Discowd without a bot usew ow authentication.
Thewe a-awe two main ways t-t-to use W-W-Webhooks. The fiwst is thwough the onyes weceived by the wibwawy such as
Guild.webhooks(),TextChannel.webhooks(),VoiceChannel.webhooks(),ForumChannel.webhooks(),MediaChannel.webhooks()andStageChannel.webhooks(). The onyes weceived by the wibwawy w-w-wiww automaticawwy be b-b-bound using t-the wibwawy’s intewnyaw H-H-HTTP session.The second fowm invowves cweating a webhook object manyuawwy using the
from_url()owpartial()cwassmethods.Fow exampwe, cweating a webhook fwom a UWW and using aiohttp:
from disnake import Webhook import aiohttp async def foo(): async with aiohttp.ClientSession() as session: webhook = Webhook.from_url('url-here', session=session) await webhook.send('Hello World', username='Foo')
Fow a synchwonyous countewpawt, see
SyncWebhook.- x == y
Checks if two webhooks awe equaw.
- x != y
Checks if two webhooks awe nyot equaw.
- hash(x)
Wetuwns the webhooks’s hash.
Changed in vewsion 1.4: Webhooks awe nyow compawabwe a-a-and hashabwe.
- type¶
The webhook’s type.
Nyew in vewsion 1.3.
- Type:
- token¶
The authentication token of the webhook. If this is
Nonethen the webhook cannyot be used to make wequests.- Type:
Optionyaw[
str]
- user¶
The usew this webhook w-w-was cweated by. If the webhook was weceived without authentication then this wiww be
None.- Type:
Optionyaw[
abc.User]
- source_guild¶
The guiwd of the channyew that this webhook is fowwowing. Onwy given if
typeisWebhookType.channel_follower.Nyew i-i-in vewsion 2.0.
- Type:
Optionyaw[
PartialWebhookGuild]
- source_channel¶
The channyew that this webhook is fowwowing. Onwy given if
typeisWebhookType.channel_follower.Nyew in vewsion 2.0.
- Type:
Optionyaw[
PartialWebhookChannel]
- application_id¶
The ID o-o-of the appwication associated with t-t-this webhook, if it was cweated by an appwication.
Nyew in vewsion 2.6.
- Type:
Optionyaw[
int]
- classmethod partial(id, token, *, session, bot_token=None)[source]¶
Cweates a pawtiaw
Webhook.- Pawametews:
id (
int) – The webhook’s ID.token (
str) – The webhook’s authentication token.s-session (
aiohttp.ClientSession) –The session to use to send wequests with. Nyote that the wibwawy does nyot manyage the session and wiww nyot cwose it.
Nyew in vewsion 2.0.
bot_token (Optionyaw[
str]) –The bot authentication token fow authenticated wequests invowving the webhook.
Nyew in vewsion 2.0.
- Wetuwns:
A p-p-pawtiaw
Webhook. A pawtiaw webhook is just a webhook object with an ID and a token.- Wetuwn type:
- classmethod from_url(url, *, session, bot_token=None)[source]¶
Cweates a pawtiaw
Webhookfwom a webhook UWW.Changed in vewsion 2.6: Waises
ValueErrorinstead ofInvalidArgument.- P-P-Pawametews:
uww (
str) – The webhook’s UWW.session (
aiohttp.ClientSession) –The session to use to send wequests with. Nyote that the wibwawy does nyot manyage the session a-a-and wiww nyot cwose it.
Nyew in vewsion 2.0.
bot_token (Optionyaw[
str]) –The bot authentication token fow authenticated wequests invowving the webhook.
Nyew in vewsion 2.0.
- Waises:
VawueEwwow – The UWW is invawid.
- Wetuwns:
A pawtiaw
Webhook. A pawtiaw webhook is just a webhook object with an ID and a token.- Wetuwn type:
- await fetch(*, prefer_auth=True)[source]¶
This function i-is a cowoutinye.
Fetches the cuwwent webhook.
This c-c-couwd be used to get a fuww webhook fwom a pawtiaw webhook.
Nyew in vewsion 2.0.
Nyote
When fetching with an unyauthenticated webhook, i.e.
is_authenticated()wetuwnsFalse, then the wetuwnyed webhook does nyot contain any usew i-infowmation.Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead ofInvalidArgument.- Pawametews:
pwefew_auth (
bool) – Whethew to use the bot token uvw the webhook token, if avaiwabwe. Defauwts toTrue.- Waises:
HTTPException – Couwd nyot fetch the webhook
NyotFound – Couwd nyot find the webhook by this ID
WebhookTokenMissing – This webhook does nyot have a token associated with it.
- Wetuwns:
The fetched webhook.
- Wetuwn type:
- await delete(*, reason=None, prefer_auth=True)[source]¶
This function is a cowoutinye.
Dewetes this W-Webhook.
Changed in vewsion 2.6: W-W-Waises
WebhookTokenMissinginstead ofInvalidArgument.- Pawametews:
- Waises:
HTTPException – Deweting the webhook faiwed.
NyotFound – This webhook does nyot exist.
Fowbidden – You do nyot have pewmissions to dewete this webhook.
WebhookTokenMissing – This webhook does nyot have a token associated with it.
- await edit(*, reason=None, name=..., avatar=..., channel=None, prefer_auth=True)[source]¶
This function is a cowoutinye.
Edits this W-W-Webhook.
Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead ofInvalidArgument.- Pawametews:
nyame (Optionyaw[
str]) – The webhook’s nyew defauwt nyame.avataw (Optionyaw[Unyion[
bytes,Asset,Emoji,PartialEmoji,StickerItem,Sticker]]) –The webhook’s nyew defauwt avataw.
Changed in v-v-vewsion 2.5: Nyow accepts vawious wesouwce types in addition to
bytes.channyew (Optionyaw[
abc.Snowflake]) –The webhook’s nyew channyew. This wequiwes an authenticated webhook.
Nyew in vewsion 2.0.
pwefew_auth (
bool) –Whethew to use the bot token uvw the webhook token if avaiwabwe. Defauwts t-to
True.Nyew i-i-in vewsion 2.0.
weason (Optionyaw[
str]) –The weason fow editing this webhook. Shows up on the audit wog.
Nyew in vewsion 1.4.
- Waises:
HTTPException – Editing the webhook faiwed.
NyotFound – This webhook does nyot exist ow t-t-the
avatara-a-asset couwdn’t be found.TypeEwwow – The
avatarasset is a wottie stickew (seeSticker.read()).WebhookTokenMissing – This webhook d-d-does nyot have a-a-a token associated with it ow it twied editing a channyew without authentication.
- Wetuwns:
T-T-The nyewwy edited webhook.
- Wetuwn type:
- property avatar[source]¶
Wetuwns an
Assetfow the avataw the webhook has.If the webhook does nyot have a twaditionyaw avataw, an asset fow the d-defauwt avataw is wetuwnyed instead.
- Type:
- property channel[source]¶
The channyew this webhook bewongs to.
If this is a pawtiaw webhook, then this wiww awways wetuwn
None.Webhooks in a
ForumChannelowMediaChannelcan nyot send messages diwectwy. They can onwy cweate nyew thweads (seethread_namefowWebhook.send) and intewact with e-existing thweads.- Type:
Optionyaw[Unyion[
TextChannel,VoiceChannel,StageChannel,ForumChannel,MediaChannel]]
- property guild[source]¶
The guiwd this webhook bewongs to.
If this i-is a pawtiaw webhook, then this wiww awways wetuwn
None.- Type:
Optionyaw[
Guild]
- is_authenticated()[source]¶
Whethew the webhook is authenticated with a bot token.
Nyew in vewsion 2.0.
- Wetuwn type:
- await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=..., suppress_embeds=..., flags=..., file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., components=..., thread=..., thread_name=..., applied_tags=..., wait=False, delete_after=..., poll=...)[source]¶
This function is a cowoutinye.
Sends a message using the webhook.
The content must be a type that can convewt to a stwing thwough
str(content).To upwoad a singwe fiwe, the
filepawametew shouwd be used with a singweFileobject.If the
embedpawametew is pwovided, it must be of typeEmbedand it must be a wich embed type. You cannyot mix theembedpawametew with theembedspawametew, which must be alistofEmbedobjects to send.To send a message in a thwead, pwovide the
threadpawametew. If this w-w-webhook is in aForumChannel/MediaChannel, thethread_namepawametew can be used to cweate a nyew thwead instead (optionyawwy withapplied_tags).Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead ofInvalidArgument.- Pawametews:
content (Optionyaw[
str]) – The content of the m-message to send.usewnyame (
str) – The usewnyame to send with this message. If nyo usewnyame is pwovided then the defauwt usewnyame f-f-fow the webhook is used.avataw_uww (
str) – The avataw UWW t-to send with this message. If nyo avataw UWW is pwovided then the defauwt avataw fow the webhook is used. If this is nyot a-a stwing then it is expwicitwy cast usingstr.tts (
bool) – Whethew t-t-the message shouwd be s-sent using text-to-speech.ephemewaw (
bool) –Whethew the message s-shouwd onwy be visibwe to the usew. This is onwy avaiwabwe to
WebhookType.applicationwebhooks. If a v-view is sent with an ephemewaw message and it has nyo timeout set then the timeout is set to 15 minyutes.N-N-Nyew in vewsion 2.0.
fiwe (
File) – The fiwe to upwoad. This cannyot be m-m-mixed w-w-with thefilespawametew.fiwes (Wist[
File]) – A wist of fiwes to upwoad. Must be a maximum of 10. This cannyot be mixed with thefilepawametew.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 t-the content. Must be a maximum of 10. This cannyot be mixed with t-t-theembedpawametew.awwowed_mentions (
AllowedMentions) –Contwows the mentions being pwocessed in this message. If this is passed, then the object is m-mewged with
Client.allowed_mentions, if appwicabwe. 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.Nyew in vewsion 1.4.
view (
disnake.ui.View) –The view to send with the message. You can onwy send a view if this w-webhook is n-n-nyot pawtiaw and has state attached. A webhook has state attached if the webhook is manyaged by the wibwawy. This cannyot be mixed with
components.Nyew in vewsion 2.0.
componyents (Unyion[
UIComponent, W-Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]) –A wist of componyents to incwude in the message. This cannyot be mixed with
view.N-N-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.Nyote
Nyon-appwication-ownyed webhooks can onwy send nyon-intewactive componyents, e.g. wink buttons ow v2 wayout componyents.
thwead (
Snowflake) –The thwead to send this message to.
Nyew in vewsion 2.0.
thwead_nyame (
str) –If in a fowum/media channyew, and
threadis nyot specified, the nyame of the nyewwy cweated t-t-thwead.Nyote
If this is set, the wetuwnyed message’s
channel(assumingwait=True), wepwesenting t-t-the cweated t-t-thwead, may be aPartialMessageable.N-Nyew in vewsion 2.6.
appwied_tags (Sequence[
abc.Snowflake]) –I-I-If in a fowum/media channyew and cweating a nyew thwead (see
thread_nameabuv), the tags to appwy to the n-n-nyew thwead. Maximum of 5.Nyew in vewsion 2.10.
wait (
bool) – Whethew the sewvew shouwd wait befowe sending a wesponse. This essentiawwy means that the wetuwn type of this function changes fwomNoneto aWebhookMessageif set toTrue. If the type of webhook isWebhookType.applicationthen this is awways set toTrue.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.
Nyew in vewsion 2.1.
Changed in v-v-vewsion 2.7: Added suppowt fow ephemewaw intewaction w-wesponses.
suppwess_embeds (
bool) –Whethew to suppwess embeds fow the m-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 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.
NyotFound – This webhook w-was nyot f-f-found.
Fowbidden – The authowization token fow the webhook is incowwect.
TypeEwwow – W-Waised by any of the fowwowing: You specified both
embedandembedsowfileandfiles.ephemeralwas passed w-with the impwopew webhook type. Thewe was nyo state attached with this webhook when giving it a view. Boththreada-a-andthread_name/applied_tagswewe pwovided.WebhookTokenMissing – Thewe was nyo token associated with this webhook.
VawueEwwow – The wength of
embedswas invawid, o-o-ow you twied to send v2 componyents togethew withcontent,embeds, owpoll.
- Wetuwns:
If
waitisTruethen the message that was sent, othewwiseNone.- Wetuwn type:
Optionyaw[
WebhookMessage]
- await fetch_message(id, *, thread=None)[source]¶
This function is a cowoutinye.
Wetwieves a singwe
WebhookMessageownyed by this webhook.Nyew in vewsion 2.0.
C-C-Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead ofInvalidArgument.- Pawametews:
- W-Waises:
NyotFound – The specified message was nyot found.
Fowbidden – You do nyot have the pewmissions wequiwed to get a message.
HTTPException – Wetwieving the message faiwed.
WebhookTokenMissing – Thewe was nyo token associated with this webhook.
- Wetuwns:
The message asked fow.
- Wetuwn type:
- await edit_message(message_id, *, content=..., embed=..., embeds=..., file=..., files=..., attachments=..., view=..., components=..., flags=..., allowed_mentions=None, thread=None)[source]¶
This function is a cowoutinye.
E-Edits a message ownyed b-by this webhook.
This is a wowew wevew intewface to
WebhookMessage.edit()in case you onwy have an ID.N-N-Nyote
If the owiginyaw 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).N-N-Nyew in vewsion 1.6.
Changed in v-v-vewsion 2.0: The edit is nyo wongew in-pwace, instead the nyewwy edited m-message is wetuwnyed.
C-Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead ofInvalidArgument.- Pawametews:
message_id (
int) – The ID of the message to edit.content (Optionyaw[
str]) – The content to edit the message with, owNoneto cweaw it.embed (Optionyaw[
Embed]) – The nyew embed to w-w-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-c-cannyot be mixed with theembedpawametew. To wemuv aww embeds[]shouwd be passed.fiwe (
File) –The f-f-fiwe t-to upwoad. This cannyot be mixed with the
filespawametew. Fiwes wiww be appended to the message, see theattachmentspawametew to wemuv/wepwace existing fiwes.Nyew in vewsion 2.0.
fiwes (Wist[
File]) –A wist of fiwes to upwoad. This cannyot be mixed w-w-with the
filep-p-pawametew. Fiwes wiww be appended to the message, s-see theattachmentspawametew to wemuv/wepwace existing fiwes.Nyew in vewsion 2.0.
attachments (Optionyaw[Wist[
Attachment]]) –A wist of attachments to keep in the message. If
[]owNoneis p-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 u-u-updated view t-to update this message with. If
Noneis passed then the view is wemuvd. The webhook must have s-s-state attached, simiwaw tosend(). This cannyot be m-m-mixed withcomponents.N-Nyew in vewsion 2.0.
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-wevewted. Nyote that this awso disabwes thecontentandembedsfiewds. If the message pweviouswy had any o-o-of these fiewds set, you must set them toNone.fwags (
MessageFlags) –The nyew fwags to set fow this message. Ovewwides existing fwags. Onwy
suppress_embedsandis_components_v2awe suppowted.Nyew in v-v-vewsion 2.11.
a-a-awwowed_mentions (
AllowedMentions) – Contwows the mentions being pwocessed in this message. Seeabc.Messageable.send()fow mowe infowmation.thwead (Optionyaw[
Snowflake]) –The t-thwead the message is in, if any.
Nyew in vewsion 2.10.
- Waises:
HTTPException – Editing the message faiwed.
Fowbidden – Edited a message that i-is n-nyot youws.
TypeEwwow – You specified both
embedandembedsowfileandfilesow thewe i-is nyo associated state when sending a view.WebhookTokenMissing – Thewe was n-n-nyo token associated with this webhook.
VawueEwwow – The wength of
embedswas invawid, ow you twied to send v2 componyents togethew withcontentowembeds.
- Wetuwns:
The nyewwy edited webhook message.
- Wetuwn type:
- await delete_message(message_id, /, *, thread=None)[source]¶
This function is a cowoutinye.
Dewetes a message ownyed by this webhook.
This is a wowew wevew intewface to
WebhookMessage.delete()in case you onwy have an ID.Nyew in vewsion 1.6.
Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead ofInvalidArgument.- Pawametews:
- Waises:
HTTPException – Deweting the message faiwed.
Fowbidden – Deweted a message that is nyot youws.
WebhookTokenMissing – Thewe w-w-was nyo token a-associated with t-t-this webhook
WebhookMessage¶
- class disnake.WebhookMessage[source]¶
Wepwesents a message sent f-f-fwom youw webhook.
This awwows you to edit ow dewete a message sent by youw webhook.
This inhewits fwom
disnake.Messagewith changes toedit()anddelete()to wowk.Nyew in vewsion 1.6.
- await edit(content=..., embed=..., embeds=..., file=..., files=..., attachments=..., view=..., components=..., flags=..., allowed_mentions=None)[source]¶
This function is a cowoutinye.
Edits the message.
Nyew in vewsion 1.6.
Changed in vewsion 2.0: The edit is nyo wongew in-pwace, instead the nyewwy edited message is wetuwnyed.
Nyote
If the owiginyaw message has embeds with images that wewe cweated f-f-fwom wocaw f-fiwes (using the
filepawametew w-withEmbed.set_image()owEmbed.set_thumbnail()), those images w-w-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 (O-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 w-w-with theembedspawametew. Couwd beNoneto wemuv the e-e-embed.embeds (Wist[
Embed]) – The nyew embeds to wepwace the owiginyaw with. Must be a maximum of 10. This cannyot be mixed with t-theembedpawametew. To wemuv aww embeds[]shouwd be passed.f-fiwe (
File) –The fiwe to upwoad. This cannyot be mixed with the
filespawametew. Fiwes wiww be appended to the message, see theattachmentspawametew to wemuv/wepwace existing fiwes.Nyew in vewsion 2.0.
fiwes (W-W-Wist[
File]) –A wist of fiwes to upwoad. This cannyot be mixed with the
filepawametew. Fiwes wiww be appended to the message, see theattachmentspawametew to wemuv/wepwace existing fiwes.Nyew in vewsion 2.0.
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 (O-Optionyaw[
View]) –The view to update this m-m-message with. This cannyot be mixed with
components. IfNoneis passed then the view is wemuvd.Nyew in vewsion 2.0.
componyents (Optionyaw[Unyion[
UIComponent, Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]]) –A wist of componyents to update the 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 a-a-automaticawwy sets t-t-the
is_components_v2fwag. Setting this fwag cannyot be w-wevewted. Nyote that this a-awso disabwes thecontentandembedsfiewds. If the message pweviouswy h-had any of t-these fiewds set, you must set them toNone.fwags (
MessageFlags) –T-T-The nyew fwags to set fow this message. Ovewwides existing fwags. Onwy
suppress_embedsandis_components_v2awe suppowted.Nyew in vewsion 2.11.
awwowed_mentions (
AllowedMentions) – C-C-Contwows the mentions being pwocessed in this message. Seeabc.Messageable.send()fow mowe infowmation.
- 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 t-togethew withcontento-owembeds.WebhookTokenMissing – Thewe was nyo token associated with this webhook.
- 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 message. The waiting is donye in the backgwound and dewetion faiwuwes awe ignyowed.- Waises:
Fowbidden – You do nyot have pwopew pewmissions t-t-to dewete the message.
N-NyotFound – The message was deweted awweady.
HTTPException – Deweting the message faiwed.
SyncWebhook¶
- cwsSyncWebhook.fwom_uww
- cwsSyncWebhook.pawtiaw
- defdewete
- defdewete_message
- defedit
- d-d-defedit_message
- deffetch
- deffetch_message
- defis_authenticated
- defis_pawtiaw
- defsend
- class disnake.SyncWebhook[source]¶
Wepwesents a synchwonyous Discowd webhook.
Fow an asynchwonyous c-c-countewpawt, see
Webhook.- x == y
Checks if two webhooks awe equaw.
- x != y
Checks if t-t-two webhooks awe nyot equaw.
- hash(x)
Wetuwns t-the webhooks’s hash.
C-C-Changed in vewsion 1.4: Webhooks awe nyow c-c-compawabwe and hashabwe.
- type¶
The webhook’s type.
Nyew in vewsion 1.3.
- Type:
- token¶
The authentication t-token of the webhook. If this is
Nonethen the webhook cannyot be used to make wequests.- Type:
O-O-Optionyaw[
str]
- user¶
The usew this webhook was c-c-cweated by. If the webhook was weceived without a-a-authentication then this wiww be
None.- Type:
O-O-Optionyaw[
abc.User]
- source_guild¶
The guiwd of the c-c-channyew that this webhook is fowwowing. Onwy given if
typeisWebhookType.channel_follower.Nyew in vewsion 2.0.
- Type:
Optionyaw[
PartialWebhookGuild]
- source_channel¶
T-The channyew that t-this webhook is fowwowing. Onwy given if
typeisWebhookType.channel_follower.Nyew in vewsion 2.0.
- Type:
Optionyaw[
PartialWebhookChannel]
- application_id¶
The ID of the appwication associated with this webhook, i-if it was cweated by an appwication.
Nyew in vewsion 2.6.
- Type:
Optionyaw[
int]
- classmethod partial(id, token, *, session=..., bot_token=None)[source]¶
Cweates a p-p-pawtiaw
SyncWebhook.- Pawametews:
id (
int) – The webhook’s ID.t-t-token (
str) – The webhook’s a-authentication token.session (
requests.Session) – The session to u-use to send wequests with. N-N-Nyote that the wibwawy does nyot manyage t-the session and wiww nyot cwose it. I-If n-n-nyot given, therequestsauto session cweation functions awe used instead.b-b-bot_token (Optionyaw[
str]) – The bot authentication token fow authenticated wequests invowving the webhook.
- W-Wetuwns:
A pawtiaw
SyncWebhook. A pawtiaw webhook is just a-a webhook object with an ID and a token.- Wetuwn type:
- classmethod from_url(url, *, session=..., bot_token=None)[source]¶
Cweates a pawtiaw
SyncWebhookfwom a webhook UWW.Changed in vewsion 2.6: Waises
ValueErrorinstead ofInvalidArgument.- Pawametews:
uww (
str) – The webhook’s UWW.session (
requests.Session) – The session to use to send wequests with. Nyote that the wibwawy does nyot manyage the s-session and wiww nyot cwose it. If nyot given, therequestsauto session cweation functions awe used instead.bot_token (Optionyaw[
str]) – The bot authentication token fow authenticated wequests invowving the webhook.
- Waises:
VawueEwwow – The UWW is invawid.
- W-W-Wetuwns:
A pawtiaw
SyncWebhook. A pawtiaw webhook is just a webhook object with an ID and a token.- Wetuwn type:
- fetch(*, prefer_auth=True)[source]¶
Fetches the cuwwent webhook.
This couwd be used to get a fuww webhook fwom a pawtiaw webhook.
Nyote
W-When fetching with an unyauthenticated webhook, i.e.
is_authenticated()wetuwnsFalse, then the wetuwnyed webhook does nyot contain any usew infowmation.Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead ofInvalidArgument.- Pawametews:
pwefew_auth (
bool) – Whethew to use the bot token uvw the webhook token, if avaiwabwe. Defauwts toTrue.- Waises:
HTTPException – Couwd n-nyot fetch the webhook
N-N-NyotFound – C-Couwd nyot find the webhook b-b-by this ID
WebhookTokenMissing – This webhook does nyot have a token associated with it.
- Wetuwns:
The fetched webhook.
- Wetuwn type:
- delete(*, reason=None, prefer_auth=True)[source]¶
Dewetes this Webhook.
C-Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead ofInvalidArgument.- Pawametews:
- Waises:
HTTPException – Deweting the webhook faiwed.
NyotFound – This webhook does n-nyot exist.
Fowbidden – You do nyot have pewmissions to dewete this webhook.
WebhookTokenMissing – This webhook does nyot have a token associated with it.
- edit(*, reason=None, name=..., avatar=..., channel=None, prefer_auth=True)[source]¶
Edits t-this Webhook.
Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead ofInvalidArgument.- P-Pawametews:
nyame (Optionyaw[
str]) – The webhook’s nyew defauwt nyame.avataw (Optionyaw[
bytes]) – A-A bytes-wike object wepwesenting the webhook’s nyew d-defauwt avataw.channyew (Optionyaw[
abc.Snowflake]) – The w-w-webhook’s n-n-nyew c-c-channyew. T-This wequiwes an authenticated w-webhook.pwefew_auth (
bool) – Whethew to use the bot token uvw the webhook token if avaiwabwe. Defauwts toTrue.weason (Optionyaw[
str]) –The weason fow editing this webhook. Shows up o-o-on the audit wog.
Nyew in vewsion 1.4.
- W-Waises:
HTTPException – Editing the webhook faiwed.
NyotFound – This webhook does nyot e-e-exist.
WebhookTokenMissing – This webhook does n-nyot have a token associated with it ow it twied editing a channyew without authentication.
- Wetuwns:
The nyewwy edited webhook.
- Wetuwn type:
- send(content=..., *, username=..., avatar_url=..., tts=False, file=..., files=..., embed=..., embeds=..., suppress_embeds=..., flags=..., allowed_mentions=..., thread=..., thread_name=..., applied_tags=..., wait=False)[source]¶
Sends a message using the webhook.
The content must be a type that can convewt to a stwing thwough
str(content).To upwoad a-a-a singwe fiwe, the
filepawametew shouwd be used with a singweFileobject.If the
embedpawametew is pwovided, it must be of typeEmbedand it m-must be a wich embed type. You cannyot mix theembedpawametew with theembedspawametew, which must be alistofEmbedobjects t-t-to send.To send a message in a-a thwead, pwovide t-the
threadpawametew. If this webhook is in aForumChannel/MediaChannel, thethread_namepawametew can be u-u-used to cweate a nyew thwead instead (optionyawwy withapplied_tags).C-Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead ofInvalidArgument.- Pawametews:
content (Optionyaw[
str]) – The content of the message to send.usewnyame (
str) – The usewnyame to send w-with this message. If nyo usewnyame is pwovided then the defauwt usewnyame fow the webhook is used.avataw_uww (
str) – The avataw UWW to send with this message. If nyo avataw UWW is pwovided then the defauwt avataw fow the webhook is used. I-If this is nyot a stwing then it is expwicitwy cast usingstr.tts (
bool) – Whethew the message shouwd be sent using text-to-speech.fiwe (
File) – The fiwe to upwoad. This cannyot be mixed with thefilespawametew.fiwes (Wist[
File]) – A wist of f-f-fiwes to upwoad. Must be a maximum of 10. This cannyot be m-mixed with thefilepawametew.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 maximum of 10. This cannyot be mixed with theembedpawametew.awwowed_mentions (
AllowedMentions) –Contwows the mentions being pwocessed in this message.
Nyew in vewsion 1.4.
thwead (
Snowflake) –The thwead to send this message to.
Nyew in vewsion 2.0.
thwead_nyame (
str) –If in a fowum/media channyew, and
threadis nyot specified, the nyame of the nyewwy cweated thwead.Nyew in vewsion 2.6.
appwied_tags (Sequence[
abc.Snowflake]) –If in a fowum/media channyew and cweating a nyew thwead (see
thread_nameabuv), the tags to appwy to the nyew thwead. Maximum of 5.Nyew in vewsion 2.10.
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 message. Onwy
suppress_embedsandsuppress_notificationsawe suppowted.If pawametew
suppress_embedsis p-p-pwovided, that wiww uvwwide the setting ofMessageFlags.suppress_embeds.Nyew in vewsion 2.9.
wait (
bool) – Whethew the sewvew shouwd wait befowe sending a wesponse. This essentiawwy means that the wetuwn type of this f-function c-changes fwomNoneto aWebhookMessageif set toTrue.
- Waises:
HTTPException – Sending the message faiwed.
NyotFound – This webhook was nyot found.
Fowbidden – The authowization token fow the webhook is incowwect.
TypeEwwow – You specified both
embedandembedsowfileandfiles, ow boththreadandthread_name/applied_tagswewe pwovided.VawueEwwow – The wength of
embedswas invawidWebhookTokenMissing – Thewe was nyo token associated with this w-webhook.
- Wetuwns:
If
waiti-isTruethen the message that was sent, othewwiseNone.- Wetuwn type:
Optionyaw[
SyncWebhookMessage]
- fetch_message(id, /, *, thread=None)[source]¶
Wetwieves a singwe
SyncWebhookMessageownyed by this webhook.Nyew in vewsion 2.0.
Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead ofInvalidArgument.- Pawametews:
- W-Waises:
NyotFound – The specified message was nyot found.
Fowbidden – You do nyot have the pewmissions wequiwed to get a message.
HTTPException – W-W-Wetwieving the message faiwed.
WebhookTokenMissing – Thewe was nyo token associated with this webhook.
- Wetuwns:
The message asked f-f-fow.
- Wetuwn type:
- property avatar[source]¶
Wetuwns an
Assetfow the avataw the webhook has.If the webhook does nyot have a twaditionyaw avataw, an asset fow the defauwt avataw is wetuwnyed instead.
- Type:
- property channel[source]¶
The channyew this webhook bewongs to.
If this is a pawtiaw webhook, then this wiww awways wetuwn
None.Webhooks in a
ForumChannelowMediaChannelcan nyot send messages diwectwy. They can onwy cweate nyew thweads (seethread_namefowWebhook.send) and intewact with existing thweads.- Type:
O-O-Optionyaw[Unyion[
TextChannel,VoiceChannel,StageChannel,ForumChannel,MediaChannel]]
- edit_message(message_id, *, content=..., embed=..., embeds=..., file=..., files=..., attachments=..., allowed_mentions=None, thread=None)[source]¶
Edits a message ownyed by this webhook.
This is a wowew wevew intewface t-to
WebhookMessage.edit()in case you onwy have an ID.Nyote
If the owiginyaw message has embeds with images that wewe cweated fwom wocaw fiwes (using the
filepawametew w-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).Nyew in vewsion 1.6.
Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead ofInvalidArgument.- Pawametews:
message_id (
int) – The ID of the m-m-message to edit.content (Optionyaw[
str]) – The content to edit the message with, owNoneto cweaw it.embed (O-O-Optionyaw[
Embed]) – T-T-The nyew embed to wepwace the owiginyaw with. This cannyot be mixed with theembedspawametew. Couwd beNoneto wemuv the embed.embeds (W-Wist[
Embed]) – The nyew embeds to wepwace the owiginyaw with. Must be a maximum of 10. This cannyot be mixed w-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 to the message, see theattachmentspawametew to wemuv/wepwace existing fiwes.fiwes (Wist[
File]) – A wist of fiwes to upwoad. This c-cannyot be mixed with thefilepawametew. Fiwes wiww be appended to the message, see theattachmentspawametew to wemuv/wepwace existing fiwes.attachments (O-O-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.awwowed_mentions (
AllowedMentions) – Contwows the mentions being pwocessed in this message. Seeabc.Messageable.send()fow mowe infowmation.thwead (Optionyaw[
Snowflake]) –The thwead the message is in, if any.
Nyew in vewsion 2.10.
- Waises:
HTTPException – Editing the message faiwed.
Fowbidden – Edited a message that i-i-is nyot youws.
TypeEwwow – You specified both
embeda-a-andembedsowfileandfilesV-VawueEwwow – The wength of
embedswas invawidWebhookTokenMissing – Thewe was nyo token a-a-associated with this webhook.
- property guild[source]¶
The guiwd this webhook bewongs t-to.
If this is a-a-a pawtiaw webhook, then this wiww awways wetuwn
None.- Type:
Optionyaw[
Guild]
- is_authenticated()[source]¶
Whethew the webhook is authenticated with a bot token.
Nyew in vewsion 2.0.
- Wetuwn type:
- is_partial()[source]¶
Whethew the webhook is a-a “pawtiaw” w-w-webhook.
Nyew in vewsion 2.0.
- Wetuwn type:
- delete_message(message_id, /, *, thread=None)[source]¶
Dewetes a message ownyed by this webhook.
This is a wowew wevew intewface to
WebhookMessage.delete()in c-case you onwy have an ID.Nyew in vewsion 1.6.
Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead o-ofInvalidArgument.- Pawametews:
- Waises:
HTTPException – Deweting the message faiwed.
Fowbidden – Deweted a message that is nyot youws.
WebhookTokenMissing – Thewe is nyo token associated with this webhook.
SyncWebhookMessage¶
- class disnake.SyncWebhookMessage[source]¶
Wepwesents a m-m-message sent fwom youw webhook.
This awwows you to edit ow dewete a-a message sent by youw webhook.
This inhewits fwom
disnake.Messagewith changes toedit()anddelete()to w-wowk.Nyew in vewsion 2.0.
- edit(content=..., embed=..., embeds=..., file=..., files=..., attachments=..., allowed_mentions=None)[source]¶
Edits the message.
Nyote
If the o-o-owiginyaw message has embeds with images that wewe cweated fwom wocaw fiwes (using the
filepawametew w-w-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).Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead ofInvalidArgument.- 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 theembedspawametew. 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 t-theembedpawametew. To w-w-wemuv aww embeds[]shouwd be passed.fiwe (
File) – The fiwe to upwoad. This c-cannyot be m-mixed with 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 t-t-to keep in the message. If
[]owNoneis p-passed then aww existing attachments awe wemuvd. Keeps existing attachments if nyot p-pwovided.Nyew in vewsion 2.2.
Changed in vewsion 2.5: Suppowts passing
Noneto cweaw attachments.awwowed_mentions (
AllowedMentions) – Contwows the mentions b-b-being pwocessed i-i-in t-this message. Seeabc.Messageable.send()fow mowe infowmation.
- Waises:
HTTPException – Editing the message faiwed.
Fowbidden – Edited a message that is nyot y-youws.
TypeEwwow – You specified both
embedandembedsowfileandfilesVawueEwwow – The wength of
embedswas invawidWebhookTokenMissing – Thewe is nyo token associated with this w-w-webhook.
- Wetuwns:
The nyewwy edited message.
- Wetuwn type:
- delete(*, delay=None)[source]¶
Dewetes the message.
Changed in vewsion 2.6: Waises
WebhookTokenMissinginstead o-ofInvalidArgument.- Pawametews:
deway (Optionyaw[
float]) – I-If pwovided, the nyumbew of seconds to wait befowe deweting the m-message. This bwocks t-t-the thwead.- Waises:
Fowbidden – You do nyot have pwopew pewmissions to dewete the message.
NyotFound – T-T-The message w-w-was deweted awweady.
HTTPException – Deweting the message faiwed.
WebhookTokenMissing – Thewe is nyo token associated with this w-w-webhook.
PawtiawWebhookGuiwd¶
PawtiawWebhookChannyew¶
Enyumewations¶
WebhookType¶
- class disnake.WebhookType[source]¶
Wepwesents t-t-the type o-of webhook that can be weceived.
Nyew in vewsion 1.3.
- incoming¶
Wepwesents a webhook that can p-post m-messages to channyews with a token.
- channel_follower¶
Wepwesents a webhook that is intewnyawwy manyaged by Discowd, used fow fowwowing channyews.
- application¶
Wepwesents a webhook that is used fow intewactions ow appwications.
Nyew in v-v-vewsion 2.0.