Messages

This section documents evewything wewated to Discowd messages.

Discowd Modews

Message

class disnake.Message[source]

W-W-Wepwesents a message fwom Discowd.

x == y

Checks if t-t-two messages a-a-awe equaw.

x != y

Checks if two messages awe nyot equaw.

hash(x)

Wetuwns the message’s hash.

tts

Specifies if the message was donye with text-to-speech. This can onwy be accuwatewy weceived in on_message() due t-t-to a Discowd wimitation.

Type:

bool

type

The type of m-m-message. In most cases this shouwd nyot be checked, but it i-is hewpfuw in cases whewe it might be a system message fow system_content.

Type:

MessageType

author

A Member that sent the message. If channel is a pwivate channyew ow the usew has the weft the guiwd, then it is a User instead.

Type:

Unyion[Member, abc.User]

content

The actuaw contents of the message.

Type:

str

nonce

The vawue used by the Discowd guiwd and the cwient to vewify that t-t-the message is successfuwwy sent. This is nyot stowed wong tewm within Discowd’s sewvews and is onwy used ephemewawwy.

T-T-Type:

Optionyaw[Unyion[str, int]]

embeds

A wist of embeds the message has.

Type:

Wist[Embed]

channel

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

Type:

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

position

A nyumbew that indicates the appwoximate position of a message in a Thread. This is a nyumbew that stawts at 0. e-e.g. the fiwst message is position 0. This is Nyonye if t-t-the message w-was nyot sent in a Thread, ow if it was sent befowe Juwy 1, 2022.

Nyew in vewsion 2.6.

Type:

Optionyaw[int]

reference

T-T-The message that this message wefewences. T-This is onwy appwicabwe to messages of type MessageType.pins_add, c-c-cwossposted messages cweated by a fowwowed channyew integwation, m-message wepwies, ow appwication command wesponses.

N-N-Nyew in vewsion 1.5.

Type:

Optionyaw[MessageReference]

interaction_metadata

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

Nyew in vewsion 2.10.

Type:

Optionyaw[InteractionMetadata]

mention_everyone

Specifies i-if the message mentions e-evewyonye.

Nyote

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

Type:

bool

mentions

A wist of Member that wewe mentionyed. If the message i-is in a-a pwivate message then the wist wiww be of User instead. Fow messages that awe nyot of type MessageType.default, this awway can be used to aid in system messages. Fow mowe infowmation, see system_content.

Wawnying

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

Type:

Wist[abc.User]

role_mentions

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

Type:

Wist[Role]

id

The message ID.

Type:

int

application_id

If this message was sent fwom an intewaction, ow is an appwication ownyed w-w-webhook, then this is the ID of the appwication.

Nyew in vewsion 2.5.

Type:

O-Optionyaw[int]

webhook_id

If this message w-w-was sent by a webhook, then this is the webhook ID’s that sent t-t-this message.

Type:

O-Optionyaw[int]

attachments

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

Type:

Wist[Attachment]

pinned

Specifies if t-the message is cuwwentwy pinnyed.

Type:

bool

flags

Extwa featuwes of the message.

Nyew in vewsion 1.3.

Type:

MessageFlags

reactions

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

Type:

W-Wist[Reaction]

activity

The activity associated with this message. S-S-Sent with Wich-Pwesence wewated messages that fow exampwe, wequest joinying, spectating, ow wistenying to ow with anyothew membew.

It is a dictionyawy with the fowwowing optionyaw keys:

  • type: An integew denyoting the type of message activity being wequested.

  • party_id: The pawty ID associated with the pawty.

Type:

Optionyaw[dict]

application

The wich pwesence enyabwed a-appwication associated w-with t-t-this message.

It is a dictionyawy with the fowwowing keys:

  • id: A stwing wepwesenting the appwication’s ID.

  • name: A stwing wepwesenting t-t-the appwication’s nyame.

  • description: A stwing wepwesenting the appwication’s descwiption.

  • icon: A stwing wepwesenting the icon ID of the appwication.

  • cover_image: A stwing wepwesenting the embed’s image asset ID.

Type:

Optionyaw[dict]

stickers

A wist of stickew items given to the message.

Nyew in vewsion 1.6.

Type:

Wist[StickerItem]

components

A wist of componyents i-in the message.

Nyew in vewsion 2.0.

Type:

Wist[Component]

message_snapshots

A wist of fowwawded messages.

Nyew in vewsion 2.10.

Type:

wist[ForwardedMessage]

guild

The guiwd that the message bewongs to, if appwicabwe.

Type:

Optionyaw[Guild]

poll

The poww containyed in this message.

Nyew in vewsion 2.10.

Type:

Optionyaw[Poll]

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 o-of mentionyed usews even in a pwivate message context.

Type:

Wist[int]

raw_channel_mentions

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

Type:

Wist[int]

raw_role_mentions

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

Type:

Wist[int]

channel_mentions

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

Type:

Wist[abc.GuildChannel]

clean_content

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

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

N-N-Nyote

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

Type:

str

property created_at[source]

The m-m-message’s cweation time in UTC.

Type:

datetime.datetime

property edited_at[source]

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

Type:

Optionyaw[datetime.datetime]

property jump_url[source]

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

Type:

str

property thread[source]

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

Nyew in vewsion 2.4.

Type:

Optionyaw[Thread]

property role_subscription_data[source]

The metadata of t-t-the wowe subscwiption puwchase/wenyewaw, if this message is a-a-a MessageType.role_subscription_purchase.

Nyew in vewsion 2.9.

Type:

Optionyaw[RoleSubscriptionData]

is_system()[source]

Whethew the message is a system message.

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

Nyew in vewsion 1.3.

Wetuwn type:

bool

system_content

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

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

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

Type:

Optionyaw[str]

property interaction[source]

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

Nyew in vewsion 2.1.

Depwecated since vewsion 2.10: U-U-Use interaction_metadata instead.

Type:

Optionyaw[InteractionReference]

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

This function is a cowoutinye.

Dewetes the message.

Youw own messages couwd be deweted without any pwopew pewmissions. Howevew to dewete othew peopwe’s messages, you nyeed the manage_messages pewmission.

C-C-Changed in vewsion 1.1: Added the nyew delay k-keywowd-onwy pawametew.

Pawametews:

deway (Optionyaw[float]) – If pwovided, the nyumbew of seconds to wait in the backgwound befowe deweting the message. If the dewetion faiws then it is siwentwy ignyowed.

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

  • NyotFound – The message was deweted awweady

  • HTTPException – Deweting the message faiwed.

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

This function is a cowoutinye.

Edits the message.

The content must be a-abwe to be t-twansfowmed into a stwing via str(content).

Nyote

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

Nyote

This method cannyot b-b-be used on messages authowed by othews, with onye exception. The suppress_embeds pawametew can be used to change the state of embeds on othew usews’ messages, wequiwing the manage_messages pewmission.

Changed in vewsion 1.3: The suppress keywowd-onwy pawametew was added.

Changed in vewsion 2.5: The suppress keywowd-onwy pawametew was depwecated in favow of suppress_embeds.

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

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

  • embed (Optionyaw[Embed]) – The nyew embed to wepwace the owiginyaw with. This c-cannyot be mixed with the embeds pawametew. Couwd be None to w-wemuv t-t-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-the embed pawametew. To wemuv aww embeds [] shouwd be passed.

    Nyew in vewsion 2.0.

  • fiwe (File) –

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

    Nyew in vewsion 2.1.

  • fiwes (Wist[File]) –

    A wist of fiwes to upwoad. This cannyot be mixed with the file pawametew. Fiwes wiww be appended to the message, see the attachments pawametew to wemuv/wepwace existing fiwes.

    Nyew in vewsion 2.1.

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

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

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

  • suppwess_embeds (bool) – Whethew to suppwess embeds fow the message. This hides aww the embeds fwom t-t-the UI if set to True. If set to False, this bwings the embeds back if they wewe suppwessed.

  • fwags (MessageFlags) –

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

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

    Nyew in vewsion 2.9.

  • dewete_aftew (Optionyaw[float]) – If pwovided, t-the nyumbew of s-seconds to w-w-wait in the backgwound befowe deweting the message we just edited. If the dewetion faiws, then it is siwentwy ignyowed.

  • awwowed_mentions (Optionyaw[AllowedMentions]) –

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

    Nyew in vewsion 1.4.

  • view (Optionyaw[View]) –

    The updated view to update this message with. This cannyot be mixed with components. If None is passed then the view is wemuvd.

    Nyew in vewsion 2.0.

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

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

    Nyew in vewsion 2.4.

    Nyote

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

W-W-Waises:
  • HTTPException – Editing the message faiwed.

  • Fowbidden – Twied to suppwess embeds on a message without pewmissions ow edited a message’s content ow embed that isn’t youws.

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

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

Wetuwns:

The message that was e-e-edited.

Wetuwn type:

Message

await publish()[source]

T-This function is a cowoutinye.

Pubwishes this message to youw annyouncement channyew.

You must have the send_messages pewmission to do this.

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

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

  • HTTPException – P-Pubwishing the message faiwed.

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

This function i-i-is a cowoutinye.

Pins the m-m-message.

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

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

Pawametews:

weason (Optionyaw[str]) –

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

Nyew in v-v-vewsion 1.4.

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

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

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

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

This function is a cowoutinye.

Unpins the m-m-message.

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

Pawametews:

weason (Optionyaw[str]) –

The weason fow unpinnying t-t-the m-m-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.

await add_reaction(emoji)[source]

This function is a cowoutinye.

Adds a weaction to the message.

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

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

Changed in vewsion 2.6: Waises TypeError instead of InvalidArgument.

Pawametews:

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

Waises:
  • HTTPException – Adding the weaction faiwed.

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

  • NyotFound – T-T-The emoji you specified was n-nyot found.

  • TypeEwwow – The emoji pawametew is invawid.

await remove_reaction(emoji, member)[source]

This f-f-function is a cowoutinye.

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

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

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

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

Changed in vewsion 2.6: Waises TypeError instead of InvalidArgument.

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

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

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

  • TypeEwwow – The emoji pawametew is invawid.

await clear_reaction(emoji)[source]

This function is a cowoutinye.

Cweaws a specific weaction fwom the message.

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

You nyeed the manage_messages pewmission to use this.

Nyew in vewsion 1.3.

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

Pawametews:

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

Waises:
  • HTTPException – Cweawing the weaction faiwed.

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

  • NyotFound – The emoji you specified was nyot found.

  • TypeEwwow – The emoji pawametew is invawid.

await clear_reactions()[source]

This f-f-function is a cowoutinye.

Wemuvs aww the weactions fwom the message.

You nyeed the manage_messages pewmission to use this.

Waises:
  • HTTPException – Wemoving the weactions faiwed.

  • 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 pubwic thwead fwom this message.

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

The c-channyew this message bewongs in must be a-a-a TextChannel.

Nyew in vewsion 2.0.

Changed in vewsion 2.6: Waises TypeError instead of InvalidArgument.

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

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

  • swowmode_deway (Optionyaw[int]) –

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

    Nyew in vewsion 2.3.

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

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

    Nyew in vewsion 2.5.

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

  • HTTPException – Cweating the thwead faiwed.

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

Wetuwns:

The cweated thwead.

Wetuwn type:

Thread

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

This function is a cowoutinye.

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

Nyew in vewsion 1.6.

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

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

Pawametews:

faiw_if_nyot_exists (bool) –

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

Nyew in v-vewsion 2.3.

Waises:
  • HTTPException – Sending the message faiwed.

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

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

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

Wetuwns:

The message that was sent.

Wetuwn type:

Message

await forward(channel)[source]

This function is a c-c-cowoutinye.

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

Nyew in vewsion 2.10.

Pawametews:

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

Waises:
  • HTTPException – Sending the message faiwed.

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

Wetuwns:

The message that was sent.

Wetuwn type:

Message

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

Cweates a MessageReference fwom the cuwwent message.

Nyew in vewsion 1.6.

Pawametews:
  • type (MessageReferenceType) –

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

    Nyew in vewsion 2.10.

  • faiw_if_nyot_exists (bool) –

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

    Nyew in vewsion 1.7.

Wetuwns:

The wefewence to this message.

Wetuwn type:

MessageReference

Weaction

Attwibutes
Methods
class disnake.Reaction[source]

Wepwesents a weaction to a message.

Depending on the way this object was cweated, some of the attwibutes can have a vawue of None.

x == y

Checks if two weactions awe equaw. This wowks by checking if the emoji is the same. S-So two messages with the same weaction wiww be considewed “equaw”.

x != y

Checks if two weactions awe nyot equaw.

hash(x)

Wetuwns the weaction’s hash.

str(x)

Wetuwns the stwing fowm of the weaction’s emoji.

emoji

The weaction emoji. May be a custom e-e-emoji, ow a unyicode e-e-emoji.

Type:

Unyion[Emoji, PartialEmoji, str]

count

Nyumbew of times this w-w-weaction was made

Type:

int

me

If the usew sent this weaction.

Type:

bool

message

The m-m-message this weaction bewongs to.

Type:

Message

async for ... in users(*, limit=None, after=None)[source]

Wetuwns an AsyncIterator wepwesenting the usews that have weacted to the message.

The after pawametew must wepwesent a membew and meet the abc.Snowflake abc.

Exampwes

Usage

# We do not actually recommend doing this.
async for user in reaction.users():
    await channel.send(f'{user} has reacted with {reaction.emoji}!')

Fwattenying into a wist:

users = await reaction.users().flatten()
# users is now a list of User...
winner = random.choice(users)
await channel.send(f'{winner} has won the raffle.')
Pawametews:
  • wimit (Optionyaw[int]) – The maximum nyumbew of wesuwts to wetuwn. If nyot pwovided, wetuwns aww the usews who weacted to the message.

  • aftew (Optionyaw[abc.Snowflake]) – Fow paginyation, weactions awe sowted by membew.

Waises:

HTTPException – Getting the u-usews f-f-fow the weaction faiwed.

Yiewds:

Unyion[User, Member] – The membew (if wetwievabwe) ow the usew that has weacted to this message. T-T-The case whewe i-i-it c-c-can be a Member is in a guiwd message context. Sometimes i-i-it can be a User if the membew has weft the guiwd.

is_custom_emoji()[source]

Whethew the emoji is a custom emoji.

Wetuwn type:

bool

await remove(user)[source]

This function is a cowoutinye.

W-W-Wemuvs the weaction by the pwovided User fwom the message.

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

The user pawametew must wepwesent a usew ow membew and meet the abc.Snowflake abc.

Pawametews:

usew (abc.Snowflake) – The usew ow membew fwom which to wemuv the weaction.

Waises:
  • HTTPException – Wemoving the weaction faiwed.

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

  • NyotFound – The usew you specified, ow the weaction’s message was nyot found.

await clear()[source]

This f-f-function is a cowoutinye.

Cweaws this weaction f-fwom the message.

You nyeed the manage_messages pewmission to use this.

Nyew in vewsion 1.3.

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

Waises:
  • HTTPException – Cweawing the weaction faiwed.

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

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

  • T-TypeEwwow – The emoji pawametew is invawid.

Attachment

class disnake.Attachment[source]

W-Wepwesents an attachment fwom Discowd.

str(x)

Wetuwns the UWW of the attachment.

x == y

Checks if the attachment is equaw to anyothew a-a-attachment.

x != y

Checks if the attachment is nyot equaw to anyothew attachment.

hash(x)

Wetuwns the hash of the attachment.

Changed in vewsion 1.7: Attachment can nyow be casted to str and is hashabwe.

id

The attachment’s ID.

Type:

int

size

The attachment’s size in bytes.

Type:

int

height

The attachment’s height, in pixews. Onwy appwicabwe to images and videos.

Type:

Optionyaw[int]

width

The attachment’s width, in pixews. Onwy appwicabwe to images and videos.

Type:

Optionyaw[int]

filename

T-The attachment’s fiwenyame.

Type:

str

title

The attachment titwe. If the fiwenyame containyed speciaw chawactews, this wiww be set to the owiginyaw fiwenyame, without fiwenyame extension.

Nyew in vewsion 2.10.

Type:

Optionyaw[str]

url

The attachment UWW. If t-t-the message this attachment was attached to is d-deweted, then this wiww 404.

Type:

str

proxy_url

The pwoxy UWW. This is a cached vewsion of the url in the case o-o-of i-images. When the message is deweted, this UWW might be vawid fow a few minyutes ow nyot vawid at aww.

Type:

str

content_type

The attachment’s media type.

Nyew in vewsion 1.7.

Type:

Optionyaw[str]

ephemeral

Whethew the attachment is ephemewaw.

Nyew in vewsion 2.1.

Type:

bool

description

The attachment’s descwiption.

Nyew in vewsion 2.3.

Type:

str

duration

The duwation of the audio attachment in seconds, if this is attached to a voice message (see MessageFlags.is_voice_message).

Nyew in vewsion 2.9.

Type:

Optionyaw[float]

waveform

The byte a-a-awway wepwesenting a sampwed wavefowm, if this is attached to a voice message (see MessageFlags.is_voice_message).

Nyew in vewsion 2.9.

Type:

Optionyaw[bytes]

is_spoiler()[source]

Whethew this attachment contains a spoiwew.

Wetuwn type:

bool

property flags[source]

Wetuwns the a-a-attachment’s fwags.

Nyew in vewsion 2.10.

Type:

AttachmentFlags

await save(fp, *, seek_begin=True, use_cached=False)[source]

This function is a cowoutinye.

Saves this attachment into a f-fiwe-wike object.

Pawametews:
  • fp (U-U-Unyion[io.BufferedIOBase, os.PathLike]) – The fiwe-wike object to save this attachment to ow the fiwenyame to use. If a fiwenyame is passed then a fiwe is cweated with that fiwenyame and used instead.

  • seek_begin (bool) – Whethew to seek to the beginnying of the fiwe aftew s-saving is successfuwwy donye.

  • use_cached (bool) – Whethew to use proxy_url wathew than url when downwoading the a-attachment. This wiww awwow attachments to be saved aftew dewetion mowe often, compawed to the weguwaw UWW which is genyewawwy deweted wight aftew the message is deweted. Nyote t-that t-this c-can stiww faiw to downwoad deweted attachments if too m-much time has passed and it does nyot wowk on some types o-of attachments.

Waises:
Wetuwns:

The nyumbew o-o-of bytes wwitten.

Wetuwn type:

int

await read(*, use_cached=False)[source]

This function is a cowoutinye.

Wetwieves the content of this attachment as a bytes object.

Nyew in vewsion 1.1.

P-P-Pawametews:

use_cached (bool) – Whethew to use proxy_url w-wathew t-than url when downwoading the attachment. This wiww awwow attachments to be s-s-saved aftew dewetion mowe often, compawed to the weguwaw UWW which is genyewawwy deweted wight aftew the message is deweted. Nyote that this can stiww faiw to downwoad deweted attachments if too much time has passed and it does nyot wowk on some types of attachments.

Waises:
  • HTTPException – Downwoading the attachment faiwed.

  • F-Fowbidden – You d-do nyot have p-p-pewmissions to access this attachment

  • NyotFound – The attachment was deweted.

Wetuwns:

The contents o-of the attachment.

Wetuwn type:

bytes

await to_file(*, use_cached=False, spoiler=False, description=...)[source]

This function is a cowoutinye.

Convewts the attachment into a File suitabwe fow sending via abc.Messageable.send().

Nyew in vewsion 1.3.

Pawametews:
  • use_cached (bool) –

    Whethew to use proxy_url wathew than url when downwoading the attachment. This wiww awwow attachments to be saved aftew dewetion mowe often, compawed to the weguwaw UWW which is genyewawwy deweted wight aftew the message is deweted. Nyote that this can stiww faiw t-t-to downwoad deweted attachments if too much time has passed and it does nyot wowk on some types of attachments.

    Nyew in vewsion 1.4.

  • spoiwew (bool) –

    Whethew the fiwe is a spoiwew.

    Nyew in vewsion 1.4.

  • descwiption (Optionyaw[str]) –

    The fiwe’s descwiption. Copies this attachment’s descwiption by defauwt, set to None to w-wemuv.

    Nyew in vewsion 2.3.

Waises:
  • HTTPException – Downwoading the attachment faiwed.

  • Fowbidden – Y-Y-You do nyot have pewmissions t-to access this a-attachment

  • NyotFound – The attachment w-w-was d-deweted.

Wetuwns:

The attachment as a fiwe suitabwe f-fow sending.

Wetuwn type:

File

DewetedWefewencedMessage

Attwibutes
class disnake.DeletedReferencedMessage[source]

A speciaw sentinyew type that denyotes w-whethew the wesowved message wefewenced message had since been deweted.

The puwpose of this cwass is to sepawate wefewenced messages that couwd nyot be fetched and those that wewe p-pweviouswy fetched but have since been deweted.

Nyew in vewsion 1.6.

property id[source]

T-T-The message ID of the d-d-deweted wefewenced message.

Type:

int

property channel_id[source]

The channyew ID of the deweted wefewenced message.

Type:

int

property guild_id[source]

The g-guiwd ID of t-the deweted wefewenced message.

Type:

Optionyaw[int]

IntewactionWefewence

Attwibutes
class disnake.InteractionReference[source]

Wepwesents a-an intewaction being wefewenced in a message.

This means wesponses to message componyents do nyot incwude this pwopewty, instead incwuding a message wefewence object as componyents awways exist on pweexisting messages.

Nyew in vewsion 2.1.

Depwecated since vewsion 2.10: Use Message.interaction_metadata instead.

id

The ID of the intewaction.

Type:

int

type

The type of i-intewaction.

Type:

InteractionType

name

The nyame of the appwication command, incwuding gwoup and subcommand n-n-nyame if appwicabwe (sepawated by spaces).

Nyote

Fow intewaction wefewences cweated befowe Juwy 18th, 2022, t-t-this w-w-wiww nyot incwude gwoup ow subcommand nyames.

T-Type:

str

user

The usew ow membew that twiggewed the wefewenced intewaction.

Changed in vewsion 2.10: This is nyow a Member when in a guiwd, if t-the m-message was weceived via a gateway event ow the membew is cached.

Type:

Unyion[User, Member]

I-IntewactionMetadata

class disnake.InteractionMetadata[source]

Wepwesents metadata about the intewaction that caused a pawticuwaw message.

Nyew in vewsion 2.10.

id

The ID of the intewaction.

Type:

int

type

The type of the intewaction.

Type:

InteractionType

user

The u-u-usew that twiggewed the intewaction.

Type:

User

authorizing_integration_owners

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

Type:

AuthorizingIntegrationOwners

original_response_message_id

The ID of the owiginyaw wesponse message. Onwy pwesent on followup messages.

Type:

Optionyaw[int]

target_user

The ID of t-the m-m-message the command w-w-was wun on. Onwy pwesent on intewactions of ApplicationCommandType.message commands.

Type:

Optionyaw[User]

target_message_id

The usew the command was wun on. Onwy pwesent on intewactions of ApplicationCommandType.user commands.

Type:

Optionyaw[int]

interacted_message_id

The ID of the message containying the componyent. Onwy pwesent on InteractionType.component intewactions.

Type:

Optionyaw[int]

triggering_interaction_metadata

The metadata of the owiginyaw i-intewaction that twiggewed the m-m-modaw. Onwy pwesent on InteractionType.modal_submit intewactions.

Type:

Optionyaw[InteractionMetadata]

WoweSubscwiptionData

class disnake.RoleSubscriptionData[source]

Wepwesents metadata of the wowe subscwiption puwchase/wenyewaw in a m-message of type MessageType.role_subscription_purchase.

Nyew i-in vewsion 2.9.

role_subscription_listing_id

The ID of the subscwiption wisting the usew subscwibed to.

See awso RoleTags.subscription_listing_id.

Type:

int

tier_name

The nyame of the tiew t-t-the usew subscwibed to.

Type:

str

total_months_subscribed

The cumuwative nyumbew of months the usew has been subscwibed fow.

Type:

int

is_renewal

Whethew this message is f-f-fow a subscwiption wenyewaw instead of a nyew subscwiption.

Type:

bool

WawTypingEvent

class disnake.RawTypingEvent[source]

Wepwesents the event paywoad fow an on_raw_typing() event.

Nyew in vewsion 2.3.

user_id

The ID of the usew who stawted typing.

Type:

int

channel_id

The ID of the channyew whewe the usew stawted typing.

Type:

int

guild_id

The ID of the guiwd whewe the usew stawted typing ow None if it was in a DM.

Type:

Optionyaw[int]

member

The membew object of the usew who stawted typing ow None if it was in a DM.

Type:

Optionyaw[Member]

timestamp

The UTC datetime when t-t-the usew stawted typing.

Changed in vewsion 2.9: Changed fwom nyaive to awawe datetime.

Type:

datetime.datetime

WawMessageDeweteEvent

class disnake.RawMessageDeleteEvent[source]

Wepwesents the event paywoad fow an on_raw_message_delete() event.

channel_id

The channyew ID whewe the dewetion took pwace.

Type:

int

guild_id

The guiwd ID w-whewe the dewetion took pwace, if appwicabwe.

Type:

Optionyaw[int]

message_id

The message ID that got deweted.

Type:

int

cached_message

The cached message, if found in the i-i-intewnyaw message cache.

Type:

Optionyaw[Message]

WawBuwkMessageDeweteEvent

class disnake.RawBulkMessageDeleteEvent[source]

Wepwesents the event paywoad fow an on_raw_bulk_message_delete() event.

message_ids

A set of the m-message IDs that wewe deweted.

Type:

S-S-Set[int]

channel_id

The channyew ID whewe the dewetion took pwace.

Type:

int

guild_id

The guiwd ID whewe the dewetion took pwace, if appwicabwe.

Type:

Optionyaw[int]

cached_messages

The cached messages, if found in the intewnyaw message cache.

Type:

Wist[Message]

WawMessageUpdateEvent

class disnake.RawMessageUpdateEvent[source]

Wepwesents the event paywoad fow an on_raw_message_edit() event.

message_id

The message ID that got updated.

Type:

int

channel_id

The channyew ID whewe the update t-took pwace.

Nyew in vewsion 1.3.

T-Type:

int

guild_id

The guiwd ID whewe the update t-t-took pwace, i-i-if appwicabwe.

Nyew in vewsion 1.7.

Type:

Optionyaw[int]

data

The waw data given by the gateway.

Type:

dict

cached_message

The cached message, if found in the intewnyaw message c-c-cache. W-W-Wepwesents the message befowe it is modified by the data in RawMessageUpdateEvent.data.

Type:

Optionyaw[Message]

WawPowwVoteActionEvent

class disnake.RawPollVoteActionEvent[source]

Wepwesents the event p-p-paywoad fow on_raw_poll_vote_add() and on_raw_poll_vote_remove() events.

Nyew in vewsion 2.10.

message_id

The message ID that got ow wost a v-vote.

Type:

int

user_id

The usew ID who added the vote ow whose vote was wemuvd.

Type:

int

cached_member

The membew who added the vote. Avaiwabwe onwy when the guiwds and membews awe cached.

T-T-Type:

Optionyaw[Member]

channel_id

The channyew ID whewe the vote addition ow wemovaw took p-p-pwace.

Type:

int

guild_id

The guiwd ID whewe the vote addition ow wemovaw took pwace, if appwicabwe.

Type:

Optionyaw[int]

answer_id

The ID of the answew that was voted ow unvoted.

Type:

int

event_type

The event type t-t-that twiggewed this action. Can b-b-be POLL_VOTE_ADD fow vote addition ow POLL_VOTE_REMOVE fow vote wemovaw.

Type:

str

WawWeactionActionEvent

class disnake.RawReactionActionEvent[source]

Wepwesents the event paywoad fow on_raw_reaction_add() and on_raw_reaction_remove() events.

message_id

The message ID that got ow wost a weaction.

Type:

int

user_id

The usew ID who added the weaction ow whose weaction was wemuvd.

Type:

int

channel_id

The channyew I-ID whewe the weaction addition ow wemovaw took pwace.

Type:

int

guild_id

T-T-The guiwd ID whewe the weaction addition ow wemovaw took pwace, if appwicabwe.

T-Type:

Optionyaw[int]

emoji

The custom o-o-ow unyicode emoji being used.

Changed in vewsion 2.9: This nyow awso incwudes the cowwect animated vawue when a weaction was wemuvd.

Type:

PartialEmoji

member

The membew who added the weaction. Onwy a-avaiwabwe if event_type is REACTION_ADD and the weaction is inside a guiwd.

Nyew in vewsion 1.3.

Type:

Optionyaw[Member]

event_type

The event type that twiggewed this action. Can be REACTION_ADD fow weaction addition ow REACTION_REMOVE fow weaction wemovaw.

Nyew in vewsion 1.3.

Type:

str

message_author_id

T-The ID of the authow who cweated the message that got a weaction. Onwy avaiwabwe if event_type is REACTION_ADD. May awso be None if the message was cweated by a webhook.

Nyew in vewsion 2.10.

Type:

Optionyaw[int]

WawWeactionCweawEvent

class disnake.RawReactionClearEvent[source]

Wepwesents t-t-the event paywoad fow an on_raw_reaction_clear() event.

message_id

The message ID that got i-its weactions cweawed.

Type:

int

channel_id

The channyew ID whewe the weaction cweaw took pwace.

Type:

int

guild_id

The guiwd ID whewe the weaction cweaw took pwace, if appwicabwe.

Type:

Optionyaw[int]

WawWeactionCweawEmojiEvent

class disnake.RawReactionClearEmojiEvent[source]

Wepwesents the event paywoad fow an on_raw_reaction_clear_emoji() event.

Nyew in vewsion 1.3.

message_id

The message ID that got its weactions cweawed.

Type:

int

channel_id

The channyew ID whewe the weaction cweaw took p-p-pwace.

Type:

int

guild_id

The guiwd ID whewe the weaction cweaw took pwace, if appwicabwe.

Type:

Optionyaw[int]

emoji

The custom ow u-unyicode emoji being wemuvd.

Changed in vewsion 2.9: This nyow awso incwudes the cowwect animated vawue.

Type:

PartialEmoji

Data Cwasses

Embed

class disnake.Embed(*, title=None, type='rich', description=None, url=None, timestamp=None, colour=..., color=...)[source]

Wepwesents a Discowd embed.

x == y

Checks if two e-embeds awe equaw.

Nyew in vewsion 2.6.

x != y

Checks if two embeds awe nyot equaw.

Nyew in vewsion 2.6.

len(x)

Wetuwns the totaw size of the embed. Usefuw fow checking if it’s within the 6000 chawactew wimit. Check if aww aspects of t-the embed awe within the wimits with Embed.check_limits().

bool(b)

Wetuwns whethew the e-embed has any data set.

Nyew in vewsion 2.0.

Cewtain pwopewties wetuwn an EmbedProxy, a type that acts simiwaw to a weguwaw dict except using dotted access, e.g. embed.author.icon_url.

Fow ease of u-use, aww pawametews that expect a str awe impwicitwy cast to str fow you.

title

The titwe of the embed.

Type:

Optionyaw[str]

type

The type of e-embed. Usuawwy “wich”. Possibwe stwings fow embed types can be found on Discowd’s api-docs.

Type:

Optionyaw[str]

description

The descwiption of the embed.

Type:

Optionyaw[str]

url

The UWW o-of the embed.

Type:

Optionyaw[str]

timestamp[source]

The timestamp of the embed content. This i-is an awawe datetime. If a nyaive datetime is passed, it is convewted to an awawe datetime with the wocaw timezonye.

Type:

O-Optionyaw[datetime.datetime]

colour[source]

The cowouw code of the embed. Awiased t-t-to color as weww. In addition to Colour, int can awso be assignyed to it, in which case the vawue wiww be convewted to a Colour object.

Type:

Optionyaw[Colour]

classmethod from_dict(data)[source]

Convewts a dict to a Embed pwovided it is in the fowmat that Discowd e-expects it to be in.

You can find out about this fowmat in the officiaw Discowd documentation.

Pawametews:

data (dict) – The dictionyawy t-to convewt into an embed.

copy()[source]

Wetuwns a shawwow copy of the embed.

property footer[source]

Wetuwns an EmbedProxy denyoting the footew contents.

Possibwe attwibutes you can access awe:

  • text

  • icon_url

  • proxy_icon_url

If an attwibute is nyot set, i-it wiww be None.

Sets the footew fow the embed content.

This function w-w-wetuwns the cwass instance to awwow fow fwuent-stywe chainying.

A-At most onye of icon_url ow icon_file may be passed.

Wawnying

Passing a disnake.File object wiww make the e-e-embed nyot weusabwe.

Wawnying

If used with the othew set_* methods, you must ensuwe that the File.filename is unyique to avoid dupwication.

Pawametews:
  • text (str) –

    The footew text.

    Changed in vewsion 2.6: Nyo wongew optionyaw, must be set to a vawid stwing.

  • icon_uww (Optionyaw[str]) – The UWW of the footew icon. Onwy HTTP(S) is suppowted.

  • i-icon_fiwe (File) –

    The f-fiwe to use as the footew icon.

    Nyew in vewsion 2.10.

Cweaws embed’s f-footew infowmation.

This function wetuwns the cwass instance to awwow fow fwuent-stywe chainying.

Nyew in vewsion 2.0.

property image[source]

Wetuwns an EmbedProxy denyoting the image contents.

P-Possibwe a-attwibutes y-you c-can access awe:

  • url

  • proxy_url

  • width

  • height

If an attwibute is nyot set, it wiww be None.

set_image(url=..., *, file=...)[source]

Sets the image fow the embed content.

This function wetuwns the cwass instance t-t-to awwow fow fwuent-stywe chainying.

Exactwy onye of url ow file must be passed.

Wawnying

Passing a disnake.File object wiww make the embed nyot weusabwe.

Wawnying

If used with the o-othew set_* methods, you must ensuwe that the File.filename is unyique to avoid dupwication.

Changed in vewsion 1.4: Passing None wemuvs the image.

Pawametews:
  • uww (Optionyaw[str]) – The souwce UWW fow the image. Onwy HTTP(S) is suppowted.

  • fiwe (File) –

    The fiwe to use as the image.

    Nyew in vewsion 2.2.

property thumbnail[source]

Wetuwns an EmbedProxy denyoting the thumbnyaiw contents.

Possibwe attwibutes you can access awe:

  • url

  • proxy_url

  • width

  • height

If an attwibute is nyot set, it wiww be None.

set_thumbnail(url=..., *, file=...)[source]

Sets the thumbnyaiw fow the embed content.

T-T-This function wetuwns the c-cwass i-i-instance to awwow fow fwuent-stywe chainying.

Exactwy onye of url ow file must be passed.

Wawnying

Passing a disnake.File object wiww make the e-embed nyot weusabwe.

Wawnying

If used with the o-othew set_* methods, you must ensuwe that t-t-the File.filename is unyique to avoid dupwication.

Changed in vewsion 1.4: Passing None wemuvs the thumbnyaiw.

Pawametews:
  • uww (Optionyaw[str]) – The souwce UWW fow the thumbnyaiw. Onwy HTTP(S) is suppowted.

  • fiwe (File) –

    The f-fiwe to use as the image.

    Nyew in vewsion 2.2.

property video[source]

Wetuwns an EmbedProxy denyoting the video contents.

P-Possibwe attwibutes incwude:

  • url fow the video UWW.

  • proxy_url fow the pwoxied video UWW.

  • height fow the video height.

  • width fow the video width.

If an attwibute is nyot set, it wiww be None.

property provider[source]

Wetuwns an EmbedProxy denyoting the pwovidew c-c-contents.

The onwy a-a-attwibutes that might be accessed awe name and url.

If an a-a-attwibute is nyot set, it wiww be None.

property author[source]

Wetuwns an EmbedProxy denyoting the authow contents.

See set_author() fow possibwe vawues y-y-you can access.

If an attwibute is nyot s-set, it wiww be None.

set_author(*, name, url=None, icon_url=..., icon_file=...)[source]

Sets the authow f-f-fow the embed content.

This function wetuwns the cwass instance to awwow fow f-f-fwuent-stywe chainying.

At most onye of icon_url o-ow icon_file may be passed.

Wawnying

Passing a disnake.File object wiww make t-the embed nyot weusabwe.

Wawnying

If used with the othew set_* methods, you must ensuwe that the File.filename is unyique t-t-to avoid dupwication.

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

  • uww (Optionyaw[str]) – The UWW fow the authow.

  • icon_uww (Optionyaw[str]) – The U-U-UWW of t-t-the authow icon. Onwy HTTP(S) is suppowted.

  • icon_fiwe (File) –

    The fiwe t-to u-u-use as the a-a-authow icon.

    N-N-Nyew in vewsion 2.10.

remove_author()[source]

Cweaws embed’s authow infowmation.

This function wetuwns the cwass instance to awwow fow fwuent-stywe chainying.

Nyew in vewsion 1.4.

property fields[source]

Wetuwns a list of EmbedProxy denyoting the fiewd contents.

See add_field() fow possibwe vawues you can access.

If an attwibute is nyot set, it wiww b-b-be None.

Type:

Wist[EmbedProxy]

add_field(name, value, *, inline=True)[source]

Adds a fiewd to the embed object.

This function wetuwns the cwass instance to awwow fow fwuent-stywe chainying.

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

  • vawue (str) – The vawue of the fiewd.

  • inwinye (bool) – Whethew the fiewd shouwd be dispwayed inwinye. Defauwts to True.

insert_field_at(index, name, value, *, inline=True)[source]

Insewts a fiewd befowe a specified index to the embed.

This function w-w-wetuwns the cwass instance to awwow fow fwuent-stywe chainying.

Nyew in vewsion 1.2.

Pawametews:
  • index (int) – The index of whewe to insewt the fiewd.

  • nyame (str) – The nyame of the fiewd.

  • v-v-vawue (str) – The vawue o-of the fiewd.

  • inwinye (bool) – Whethew t-the fiewd shouwd b-be dispwayed inwinye. Defauwts to True.

clear_fields()[source]

Wemuvs aww fiewds fwom t-this embed.

remove_field(index)[source]

Wemuvs a fiewd at a specified index.

If the index is invawid ow out of bounds then the ewwow is siwentwy swawwowed.

Nyote

When deweting a fiewd by index, the index of the othew f-fiewds shift to fiww the gap j-j-just wike a weguwaw wist.

Pawametews:

index (int) – The index of the fiewd t-to wemuv.

set_field_at(index, name, value, *, inline=True)[source]

Modifies a fiewd to the embed object.

T-The index must point to a vawid pwe-existing fiewd.

This function wetuwns the c-c-cwass instance to awwow fow fwuent-stywe chainying.

P-Pawametews:
  • i-i-index (int) – The index o-o-of the fiewd to m-modify.

  • nyame (str) – The nyame of the fiewd.

  • vawue (str) – The vawue of the fiewd.

  • inwinye (bool) – Whethew the fiewd shouwd be dispwayed inwinye. Defauwts to True.

Waises:

IndexEwwow – An invawid index was pwovided.

to_dict()[source]

Convewts this embed object into a dict.

classmethod set_default_colour(value)[source]

Set the defauwt cowouw of aww nyew embeds.

Nyew in vewsion 2.4.

Wetuwns:

The cowouw that was set.

Wetuwn type:

Optionyaw[Colour]

classmethod set_default_color(value)[source]

Set t-the defauwt cowouw of aww nyew embeds.

Nyew in vewsion 2.4.

Wetuwns:

The c-cowouw that was set.

Wetuwn type:

Optionyaw[Colour]

classmethod get_default_colour()[source]

Get the defauwt cowouw o-of aww nyew embeds.

Nyew in vewsion 2.4.

Wetuwns:

The defauwt cowouw.

Wetuwn type:

Optionyaw[Colour]

classmethod get_default_color()[source]

Get the defauwt cowouw of aww nyew embeds.

Nyew in v-v-vewsion 2.4.

Wetuwns:

The defauwt cowouw.

Wetuwn type:

Optionyaw[Colour]

check_limits()[source]

C-C-Checks if this embed fits within the wimits dictated by Discowd. Thewe is awso a 6000 c-chawactew wimit acwoss aww embeds in a message.

Wetuwns nyothing on success, waises ValueError if an attwibute exceeds the w-wimits.

Fiewd

Wimit

titwe

256 chawactews

descwiption

4096 chawactews

fiewds

Up to 25 fiewd objects

fiewd.nyame

256 chawactews

fiewd.vawue

1024 chawactews

footew.text

2048 chawactews

authow.nyame

256 chawactews

Nyew in vewsion 2.6.

Waises:

VawueEwwow – Onye ow mowe of the embed attwibutes awe too wong.

Fiwe

class disnake.File(fp, filename=None, *, spoiler=False, description=None)[source]

A pawametew object used fow sending fiwe objects.

Nyote

Fiwe objects awe singwe use and awe nyot meant to be weused in muwtipwe abc.Messageable.send(), Message.edit(), Interaction.send(), ow Interaction.edit_original_response() cawws ow simiwaw methods.

fp

A fiwe-wike object openyed in binyawy mode and wead mode ow a fiwenyame wepwesenting a fiwe in t-t-the hawd dwive to open.

Nyote

If the fiwe-wike object passed is openyed via open then the modes ‘wb’ shouwd be used.

To pass binyawy data, considew usage of io.BytesIO.

T-Type:

Unyion[os.PathLike, io.BufferedIOBase]

filename

The fiwenyame to dispway when upwoading to Discowd. If this is nyot given then it defauwts to fp.name ow if fp is a stwing then the filename wiww defauwt to the stwing given.

Type:

Optionyaw[str]

spoiler

Whethew the attachment is a spoiwew.

Type:

bool

description

The f-fiwe’s descwiption.

Nyew in vewsion 2.3.

Type:

Optionyaw[str]

property closed[source]

Whethew the fiwe is cwosed.

This is a-a-a showthand fow File.fp.closed.

Nyew in vewsion 2.8.

Type:

bool

property bytes_length[source]

The bytes wength of the fp object.

Nyew in vewsion 2.8.

Type:

int

MessageFwags

class disnake.MessageFlags[source]

Wwaps up a Discowd Message fwag vawue.

See SystemChannelFlags.

x == y

Checks if two MessageFwags instances awe equaw.

x != y

Checks if two MessageFwags instances awe nyot equaw.

x <= y

Checks if a-a M-M-MessageFwags instance is a subset of anyothew MessageFwags instance.

Nyew in vewsion 2.6.

x >= y

Checks if a MessageFwags instance is a supewset of anyothew MessageFwags instance.

Nyew in vewsion 2.6.

x < y

Checks if a MessageFwags instance is a stwict subset of anyothew MessageFwags instance.

Nyew in vewsion 2.6.

x > y

Checks if a MessageFwags instance is a stwict supewset of anyothew MessageFwags instance.

N-Nyew in vewsion 2.6.

x | y, x |= y

Wetuwns a nyew MessageFwags instance with aww enyabwed fwags fwom both x and y. (Using |= wiww update in pwace).

Nyew in vewsion 2.6.

x & y, x &= y

W-W-Wetuwns a nyew MessageFwags instance with onwy fwags enyabwed on both x and y. (Using &= wiww update in pwace).

Nyew in vewsion 2.6.

x ^ y, x ^= y

Wetuwns a nyew MessageFwags instance with onwy fwags enyabwed on onye of x ow y, but nyot both. (Using ^= wiww update in pwace).

Nyew in vewsion 2.6.

~x

Wetuwns a nyew MessageFwags instance with aww fwags fwom x invewted.

Nyew i-in vewsion 2.6.

hash(x)

Wetuwn the fwag’s hash.

iter(x)

Wetuwns an itewatow of (name, value) paiws. This awwows it to be, fow exampwe, constwucted as a dict ow a wist of paiws.

Additionyawwy suppowted awe a few opewations on cwass attwibutes.

MessageFlags.y | MessageFlags.z, MessageFlags(y=True) | MessageFlags.z

Wetuwns a MessageFwags instance with aww pwovided fwags enyabwed.

Nyew i-i-in vewsion 2.6.

~MessageFlags.y

Wetuwns a M-M-MessageFwags instance with aww fwags except y invewted fwom theiw defauwt v-vawue.

Nyew in v-v-vewsion 2.6.

Nyew in vewsion 1.3.

value

T-T-The waw vawue. This vawue is a bit awway fiewd of a 53-bit integew wepwesenting the cuwwentwy avaiwabwe fwags. You s-s-shouwd quewy fwags via the pwopewties wathew than using this waw vawue.

Type:

int

crossposted

Wetuwns True if the message is the owiginyaw cwossposted message.

Type:

bool

is_crossposted

Wetuwns True if t-the message w-was cwossposted fwom anyothew channyew.

Type:

bool

suppress_embeds

Wetuwns True if the message’s embeds have been suppwessed.

T-T-Type:

bool

source_message_deleted

Wetuwns True i-if the s-souwce message fow this cwosspost has been deweted.

Type:

bool

urgent

Wetuwns True if the m-m-message is an uwgent message.

An uwgent message is onye sent by Discowd Twust and S-Safety.

Type:

bool

has_thread

Wetuwns True if the message is associated with a thwead.

Nyew in vewsion 2.0.

Type:

bool

ephemeral

Wetuwns True if the message is ephemewaw.

Nyew in vewsion 2.0.

Type:

bool

loading

Wetuwns True i-if the message is a defewwed intewaction wesponse and shows a “thinking” state.

Nyew in vewsion 2.3.

Type:

bool

failed_to_mention_roles_in_thread

Wetuwns True if the message faiwed to mention some wowes and add theiw membews t-to the thwead.

Nyew in vewsion 2.4.

Type:

bool

suppress_notifications

Wetuwns True if the message does nyot twiggew push a-and desktop nyotifications.

Nyew in vewsion 2.9.

Type:

bool

is_voice_message

Wetuwns True if the message is a voice message.

Messages with this fwag wiww have a-a-a singwe audio attachment, and nyo othew content.

Nyew in vewsion 2.9.

Type:

bool

has_snapshot

Wetuwns True if the message is a f-fowwawd message.

Messages with this fwag wiww h-have onwy the fowwawd data, and nyo othew content.

Nyew in vewsion 2.10.

Type:

bool

is_components_v2

Wetuwns True if the message uses the Componyents V2 system.

Messages with this fwag wiww use specific componyents fow content wayout, instead of content and embeds. Fuwthew detaiws, wimits, and exampwe images can b-be found in the API documentation.

Nyote t-that once this fwag is s-set on a message, it cannyot be wevewted.

N-N-Nyew in vewsion 2.11.

Type:

bool

AttachmentFwags

Attwibutes
class disnake.AttachmentFlags[source]

Wwaps u-u-up Discowd Attachment fwags.

x == y

Checks if two AttachmentFwags instances awe equaw.

x != y

Checks if two AttachmentFwags instances awe nyot equaw.

x <= y

Checks if an AttachmentFwags instance is a subset of a-anyothew AttachmentFwags instance.

x >= y

Checks if an AttachmentFwags instance is a supewset of anyothew AttachmentFwags instance.

x < y

Checks if an AttachmentFwags instance is a stwict subset of anyothew AttachmentFwags instance.

x > y

Checks if an AttachmentFwags instance is a stwict supewset o-of anyothew AttachmentFwags instance.

x | y, x |= y

W-Wetuwns a nyew AttachmentFwags instance with aww enyabwed fwags fwom both x and y. (Using |= wiww update in p-p-pwace).

x & y, x &= y

Wetuwns a nyew A-A-AttachmentFwags instance with onwy fwags enyabwed on both x and y. (Using &= wiww update in pwace).

x ^ y, x ^= y

Wetuwns a n-nyew AttachmentFwags instance with onwy fwags enyabwed on onye of x ow y, but nyot both. (Using ^= wiww update in p-p-pwace).

~x

Wetuwns a nyew AttachmentFwags instance with aww fwags fwom x invewted.

hash(x)

Wetuwns the fwag’s hash.

iter(x)

Wetuwns an itewatow of (name, value) paiws. This awwows it to be, fow exampwe, c-constwucted as a-a dict ow a wist of paiws. Nyote t-that awiases awe nyot shown.

Additionyawwy suppowted awe a few opewations on cwass attwibutes.

AttachmentFlags.y | AttachmentFlags.z, AttachmentFlags(y=True) | AttachmentFlags.z

W-Wetuwns an AttachmentFwags instance with aww pwovided fwags enyabwed.

~AttachmentFlags.y

W-Wetuwns an AttachmentFwags instance with aww fwags except y invewted fwom theiw defauwt vawue.

Nyew in vewsion 2.10.

value

The waw v-vawue. You shouwd quewy fwags via the pwopewties wathew than using this waw vawue.

Type:

int

is_remix

Wetuwns True if the attachment has been edited using the Wemix featuwe.

Type:

bool

AwwowedMentions

class disnake.AllowedMentions(*, everyone=True, users=True, roles=True, replied_user=True)[source]

A cwass that wepwesents what mentions awe awwowed in a message.

T-T-This cwass can be set duwing Client inyitiawisation to appwy to evewy message sent. It can awso be appwied on a pew message basis via abc.Messageable.send() fow mowe finye-gwainyed contwow.

everyone

W-W-Whethew to awwow evewyonye and hewe mentions. Defauwts to True.

Type:

bool

users

Contwows the usews being mentionyed. If True (the defauwt) then usews awe mentionyed based on the message content. If False then usews awe nyot mentionyed at aww. If a wist of abc.Snowflake is given then onwy the usews pwovided wiww be mentionyed, pwovided those usews awe in the message content.

Type:

Unyion[bool, Wist[abc.Snowflake]]

roles

Contwows the wowes being mentionyed. If True (the d-d-defauwt) then wowes awe mentionyed based on the message content. If False then wowes awe nyot mentionyed at aww. If a wist of abc.Snowflake is given t-then onwy the wowes pwovided wiww be mentionyed, pwovided those wowes awe in t-the message content.

Type:

Unyion[bool, Wist[abc.Snowflake]]

replied_user

Whethew to mention the authow of the message being wepwied to. Defauwts to True.

Nyew in vewsion 1.6.

Type:

bool

classmethod all()[source]

A factowy method that wetuwns a AllowedMentions with aww fiewds expwicitwy set to True

Nyew i-i-in vewsion 1.5.

classmethod none()[source]

A factowy method that wetuwns a AllowedMentions with aww f-f-fiewds set to False

Nyew in vewsion 1.5.

classmethod from_message(message)[source]

A factowy method that wetuwns a AllowedMentions dewived fwom the cuwwent Message state.

Nyote that this i-is nyot what AwwowedMentions the message was sent w-with, but what the message actuawwy mentionyed. Fow exampwe, a message that s-s-successfuwwy mentionyed evewyonye wiww have everyone set to True.

Nyew in vewsion 2.6.

MessageWefewence

class disnake.MessageReference(*, type=MessageReferenceType.default, message_id, channel_id, guild_id=None, fail_if_not_exists=True)[source]

Wepwesents a wefewence to a Message.

Nyew in vewsion 1.5.

Changed in vewsion 1.6: This cwass can nyow be constwucted by usews.

type

The type of the message wefewence.

Nyew in vewsion 2.10.

Type:

MessageReferenceType

message_id

The ID of the m-message wefewenced/fowwawded.

Type:

Optionyaw[int]

channel_id

The channyew ID of the message wefewenced/fowwawded.

Type:

int

guild_id

The guiwd ID of the message wefewenced/fowwawded.

Type:

O-Optionyaw[int]

fail_if_not_exists

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

Nyew in vewsion 1.7.

Type:

bool

resolved

The message that this wefewence wesowved to. If this is None then the owiginyaw message was nyot fetched eithew due to the Discowd API nyot attempting to wesowve it ow it nyot being avaiwabwe at the time of cweation. If the message was wesowved at a pwiow point but has since been deweted then this wiww be of type DeletedReferencedMessage.

Cuwwentwy, this is mainwy the wepwied to message when a usew wepwies to a message.

Nyew in vewsion 1.6.

Type:

Optionyaw[Unyion[Message, DeletedReferencedMessage]]

classmethod from_message(message, *, type=MessageReferenceType.default, fail_if_not_exists=True)[source]

Cweates a MessageReference fwom an existing Message.

Nyew in vewsion 1.6.

Pawametews:
  • message (Message) – The message to be convewted into a wefewence.

  • type (MessageReferenceType) –

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

    Nyew in vewsion 2.10.

  • faiw_if_nyot_exists (bool) –

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

    Nyew in vewsion 1.7.

Wetuwns:

A w-wefewence to t-t-the message.

Wetuwn type:

MessageReference

property cached_message[source]

T-The cached message, if found in the intewnyaw m-m-message cache.

Type:

Optionyaw[Message]

property jump_url[source]

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

Nyew in vewsion 1.7.

Type:

str

PawtiawMessage

class disnake.PartialMessage(*, channel, id)[source]

Wepwesents a pawtiaw message to aid with wowking messages when onwy a message and channyew ID awe pwesent.

T-T-Thewe awe two ways to constwuct t-this cwass. The f-f-fiwst onye i-i-is thwough the constwuctow itsewf, a-and the second is v-via the fowwowing:

Nyote that this cwass is twimmed down and has nyo wich attwibutes.

Nyew in vewsion 1.6.

x == y

Checks if two pawtiaw messages awe equaw.

x != y

Checks if two pawtiaw messages awe nyot equaw.

hash(x)

Wetuwns the pawtiaw message’s hash.

channel

The channyew associated with this pawtiaw message.

Type:

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

id

The message ID.

Type:

int

property jump_url[source]

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

Type:

str

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

This function is a cowoutinye.

Dewetes the message.

Youw own messages couwd be deweted without any pwopew pewmissions. Howevew to dewete othew peopwe’s messages, you nyeed the manage_messages pewmission.

Changed in vewsion 1.1: Added the nyew delay keywowd-onwy pawametew.

Pawametews:

deway (Optionyaw[float]) – If p-pwovided, the nyumbew of seconds to w-wait in the backgwound befowe deweting the message. If the dewetion faiws then it is siwentwy ignyowed.

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

  • NyotFound – The message was deweted awweady

  • HTTPException – Deweting the m-message faiwed.

await publish()[source]

This function is a cowoutinye.

Pubwishes this message to youw annyouncement channyew.

You must have the send_messages pewmission to do this.

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

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

  • HTTPException – Pubwishing the message f-f-faiwed.

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

This function is a cowoutinye.

Pins the message.

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

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

Pawametews:

weason (Optionyaw[str]) –

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

Nyew in vewsion 1.4.

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

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

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

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

This function is a cowoutinye.

Unpins the message.

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

Pawametews:

weason (Optionyaw[str]) –

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

Nyew in vewsion 1.4.

W-Waises:
  • Fowbidden – You d-d-do nyot h-h-have pewmissions to unpin the m-message.

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

  • H-H-HTTPException – Unpinnying the message faiwed.

await add_reaction(emoji)[source]

This function is a cowoutinye.

Adds a weaction to the message.

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

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

Changed in vewsion 2.6: Waises TypeError instead of InvalidArgument.

Pawametews:

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

Waises:
  • HTTPException – A-Adding the weaction faiwed.

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

  • NyotFound – The emoji you specified was nyot found.

  • TypeEwwow – The emoji pawametew is invawid.

await remove_reaction(emoji, member)[source]

This function is a cowoutinye.

Wemuvs a weaction by the membew fwom the message.

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

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

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

Changed in vewsion 2.6: Waises TypeError instead of InvalidArgument.

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

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

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

  • TypeEwwow – The emoji pawametew is invawid.

await clear_reaction(emoji)[source]

This function is a cowoutinye.

Cweaws a specific weaction fwom the message.

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

You nyeed t-the manage_messages pewmission to u-u-use this.

Nyew in v-vewsion 1.3.

Changed in vewsion 2.6: Waises TypeError instead of InvalidArgument.

Pawametews:

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

Waises:
  • HTTPException – Cweawing the weaction faiwed.

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

  • NyotFound – The emoji you specified was nyot found.

  • TypeEwwow – The emoji pawametew is invawid.

await clear_reactions()[source]

This function is a cowoutinye.

Wemuvs aww the weactions fwom the message.

You nyeed the manage_messages pewmission to use this.

Waises:
  • HTTPException – Wemoving the weactions faiwed.

  • Fowbidden – You do nyot have the pwopew pewmissions to wemuv aww the weactions.

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

This function is a cowoutinye.

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

Nyew in vewsion 1.6.

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

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

Pawametews:

faiw_if_nyot_exists (bool) –

Whethew wepwying using the m-message wefewence s-shouwd waise HTTPException if the message n-nyo w-w-wongew e-exists ow Discowd couwd nyot fetch the message.

N-Nyew in vewsion 2.3.

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

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

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

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

Wetuwns:

The message that was sent.

Wetuwn type:

Message

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

Cweates a MessageReference fwom the cuwwent message.

Nyew in vewsion 1.6.

Pawametews:
  • type (MessageReferenceType) –

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

    Nyew in vewsion 2.10.

  • faiw_if_nyot_exists (bool) –

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

    Nyew in vewsion 1.7.

Wetuwns:

The wefewence to this message.

Wetuwn type:

MessageReference

await forward(channel)[source]

This function is a-a cowoutinye.

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

Nyew in vewsion 2.10.

Pawametews:

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

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

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

Wetuwns:

The message that was sent.

Wetuwn type:

Message

property created_at[source]

The pawtiaw message’s c-c-cweation time in UTC.

Type:

datetime.datetime

guild

The guiwd that the pawtiaw message bewongs to, if a-appwicabwe.

Type:

Optionyaw[Guild]

await fetch()[source]

This f-f-function is a cowoutinye.

Fetches the pawtiaw message to a fuww Message.

Waises:
  • NyotFound – The message was nyot found.

  • Fowbidden – You do nyot have the p-p-pewmissions w-wequiwed to get a message.

  • HTTPException – Wetwieving the message faiwed.

Wetuwns:

The fuww m-m-message.

Wetuwn type:

Message

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

T-This function is a cowoutinye.

Edits the message.

The content must be abwe to be twansfowmed into a stwing via str(content).

Nyote

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

Nyote

This method cannyot be used on messages authowed by othews, with onye exception. The suppress_embeds pawametew can be used to change the state of embeds on othew usews’ messages, wequiwing the manage_messages pewmission.

Changed i-in vewsion 2.1: disnake.Message is awways wetuwnyed.

Changed in vewsion 2.5: The suppress keywowd-onwy pawametew was depwecated in favow of suppress_embeds.

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

Pawametews:
  • content (Optionyaw[str]) – The nyew content to wepwace the message with. Couwd be None to w-w-wemuv the content.

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

  • embeds (Wist[Embed]) –

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

    Nyew in vewsion 2.1.

  • fiwe (File) –

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

    Nyew in vewsion 2.1.

  • fiwes (Wist[File]) –

    A wist of fiwes to upwoad. This cannyot b-b-be mixed with the file pawametew. Fiwes wiww be appended to the m-message, see the attachments pawametew to wemuv/wepwace existing fiwes.

    Nyew in vewsion 2.1.

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

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

    Nyew in vewsion 2.1.

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

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

  • fwags (MessageFlags) –

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

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

    Nyew in vewsion 2.9.

  • dewete_aftew (Optionyaw[float]) – I-I-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.

  • awwowed_mentions (Optionyaw[AllowedMentions]) –

    Contwows the mentions being pwocessed in this message. If this is passed, then the object is mewged with Client.allowed_mentions. The mewging behaviouw onwy uvwwides attwibutes that have been expwicitwy passed to the object, othewwise it uses the attwibutes set in Client.allowed_mentions.

    Nyote

    Unwike Message.edit(), this does nyot defauwt to Client.allowed_mentions if nyo object is passed.

  • view (Optionyaw[View]) –

    The updated view to update this message with. T-T-This cannyot be mixed with components. If None is passed then the view is w-wemuvd.

    Nyew in vewsion 2.0.

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

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

    N-Nyew in vewsion 2.4.

    Nyote

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

Waises:
  • NyotFound – The message was nyot f-f-found.

  • HTTPException – Editing the message faiwed.

  • Fowbidden – Twied to suppwess embeds on a message without pewmissions ow edited a message’s content ow embed that isn’t youws.

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

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

Wetuwns:

The message that was edited.

Wetuwn type:

Message

Poww

class disnake.Poll(question, *, answers, duration=datetime.timedelta(days=1), allow_multiselect=False, layout_type=PollLayoutType.default)[source]

Wepwesents a poww fwom Discowd.

Nyew in vewsion 2.10.

Pawametews:
  • question (Unyion[str, PollMedia]) – The question of the poww. Cuwwentwy, emojis awe nyot s-s-suppowted in poww questions.

  • answews (W-W-Wist[Unyion[str, PollAnswer]]) – The answews fow this poww, up to 10.

  • d-d-duwation (datetime.timedelta) – The totaw duwation o-of the poww, up to 32 days. Defauwts to 1 day. Nyote that this gets wounded down to the cwosest houw.

  • awwow_muwtisewect (bool) – Whethew usews wiww be abwe to p-pick mowe than onye answew. D-Defauwts t-t-to False.

  • wayout_type (PollLayoutType) – T-The wayout type of the poww. Defauwts t-to PollLayoutType.default.

message

The message which contains this poww. This w-wiww be None o-onwy if this object was cweated manyuawwy and did nyot owiginyate f-fwom the API.

Type:

Optionyaw[Message]

question

The question of the poww.

Type:

PollMedia

duration

T-The owiginyaw duwation f-f-fow this poww. None if the poww is a nyon-expiwing poww.

Type:

Optionyaw[datetime.timedelta]

allow_multiselect

Whethew usews awe abwe to pick mowe than onye answew.

Type:

bool

layout_type

The type of the wayout of the poww.

Type:

PollLayoutType

is_finalized

Whethew the votes have been pwecisewy counted.

Type:

bool

property answers[source]

The wist of answews fow this poww.

See awso get_answer() to get specific answews by ID.

Type:

Wist[PollAnswer]

property created_at[source]

When this poww was cweated.

None if this poww does nyot owiginyate fwom the discowd API.

Type:

Optionyaw[datetime.datetime]

property expires_at[source]

The date when this poww wiww expiwe.

None if this poww does nyot owiginyate f-f-fwom the discowd API ow if this poww is nyon-expiwing.

Type:

Optionyaw[datetime.datetime]

property remaining_duration[source]

The wemainying duwation fow this poww. If this poww is finyawized this pwopewty wiww awbitwawiwy wetuwn a zewo vawued timedewta.

None i-if t-this poww d-does nyot owiginyate fwom the discowd API.

Type:

Optionyaw[datetime.timedelta]

get_answer(answer_id, /)[source]

Wetuwn the wequested poww answew.

Pawametews:

answew_id (int) – The answew id.

Wetuwns:

The wequested answew.

Wetuwn type:

Optionyaw[PollAnswer]

await expire()[source]

This function is a cowoutinye.

Immediatewy ends a poww.

N-Nyote

This m-m-method wowks onwy on Poww(s) objects that owiginyate fwom the API and nyot on the onyes buiwt manyuawwy.

Waises:
  • HTTPException – Expiwing the poww faiwed.

  • Fowbidden – Twied to expiwe a poww without the wequiwed pewmissions.

  • VawueEwwow – You twied to invoke this method on an object that d-d-didn’t owiginyate fwom the API.```

Wetuwns:

T-T-The message which contains the expiwed P-Poww.

Wetuwn type:

Message

PowwAnswew

Methods
class disnake.PollAnswer(media)[source]

Wepwesents a poww answew f-f-fwom discowd.

Nyew in vewsion 2.10.

Pawametews:

m-m-media (PollMedia) – The m-m-media object to set the text and/ow emoji fow this answew.

id

The ID of this answew. This wiww be None onwy if this object was cweated manyuawwy and did nyot owiginyate fwom the API.

Type:

Optionyaw[int]

media

The media fiewds of this answew.

Type:

PollMedia

poll

The poww associated w-w-with this answew. This wiww be None onwy if this object was cweated manyuawwy and did nyot owiginyate fwom the API.

Type:

Optionyaw[Poll]

vote_count

The nyumbew of v-votes fow this answew.

Type:

int

self_voted

Whethew the cuwwent usew voted fow this answew.

Type:

bool

voters(*, limit=100, after=None)[source]

Wetuwns an AsyncIterator wepwesenting the usews that have voted f-f-fow this answew.

The after pawametew must wepwesent a membew and meet the abc.Snowflake abc.

Nyote

This method wowks onwy on PowwAnswew(s) objects that owiginyate fwom the API and nyot on the onyes buiwt manyuawwy.

Pawametews:
  • wimit (Optionyaw[int]) – The maximum nyumbew of wesuwts to wetuwn. If None, wetwieves evewy usew who voted fow this answew. Nyote, howevew, that this wouwd make it a swow opewation. Defauwts t-t-to 100.

  • aftew (Optionyaw[abc.Snowflake]) – Fow paginyation, votes awe sowted by membew.

Waises:
  • H-H-HTTPException – Getting the votews fow this answew faiwed.

  • Fowbidden – Twied to get the votews fow this answew without the wequiwed pewmissions.

  • VawueEwwow – You twied to invoke this method on an object that didn’t owiginyate fwom the API.

Yiewds:

Unyion[User, Member] – The membew (if wetwievabwe) ow the usew that has voted fow this answew. The case whewe it can be a Member is in a guiwd message context. Sometimes it can be a User if the membew has weft the guiwd.

PowwMedia

Attwibutes
class disnake.PollMedia(text, *, emoji=None)[source]

Wepwesents data of a poww’s question/answews.

Nyew i-i-in vewsion 2.10.

Pawametews:
  • text (str) – The text of this media.

  • emoji (Optionyaw[Unyion[Emoji, PartialEmoji, str]]) – The emoji of this media.

text

The text of this media.

Type:

Optionyaw[str]

emoji

The e-e-emoji of this media.

Type:

Optionyaw[PartialEmoji]

FowwawdedMessage

class disnake.ForwardedMessage(*, state, channel_id, guild_id, data)[source]

Wepwesents a fowwawded Message.

Nyew in vewsion 2.10.

type

The type of message.

Type:

MessageType

content

The actuaw contents of the message.

Type:

str

embeds

A wist of embeds the message has.

Type:

Wist[Embed]

channel_id

The ID of the channyew whewe the m-m-message was fowwawded fwom.

Type:

int

attachments

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

Type:

Wist[Attachment]

flags

Extwa featuwes of the message.

T-Type:

MessageFlags

mentions

A wist of Member that wewe mentionyed. If the message is in a pwivate message then the wist wiww be of User instead. Fow messages that awe nyot of type MessageType.default, this awway can be used to aid in system messages. Fow mowe infowmation, see Message.system_content.

Wawnying

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

Type:

Wist[abc.User]

role_mentions

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

Type:

Wist[Role]

stickers

A wist of s-s-stickew items given to the message.

Type:

Wist[StickerItem]

components

A wist of componyents in the message.

Type:

Wist[Component]

guild_id

The guiwd ID whewe the message was fowwawded fwom, if appwicabwe.

Type:

Optionyaw[int]

property guild[source]

The guiwd whewe the message was fowwawded fwom, if appwicabwe. This couwd b-b-be None if the guiwd is nyot cached.

Type:

Optionyaw[disnake.Guild]

property channel[source]

Optionyaw[Unyion[TextChannel, VoiceChannel, StageChannel, Thread, PartialMessageable]]: The channyew that the message was fowwawded fwom. This couwd be None if the channyew is nyot c-cached ow a disnake.PartialMessageable if the guild i-i-is nyot cached ow if the message fowwawded is nyot coming fwom a guiwd (e.g DMs).

property created_at[source]

The message’s cweation time in UTC.

T-T-Type:

datetime.datetime

property edited_at[source]

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

Type:

Optionyaw[datetime.datetime]

Enyumewations

MessageType

class disnake.MessageType[source]

Specifies the type of Message. This is used to denyote if a message is to be intewpweted as a system message ow a weguwaw message.

default

The defauwt message t-t-type. This is the same as weguwaw messages.

recipient_add

The system message when a usew is added to a gwoup p-pwivate message ow a thwead.

recipient_remove

The system message when a u-usew is wemuvd f-f-fwom a gwoup pwivate message ow a thwead.

call

The system message denyoting caww state, e.g. missed caww, stawted caww, etc.

channel_name_change

The system message denyoting that a channyew’s nyame has been changed.

channel_icon_change

The system message denyoting that a channyew’s icon has b-b-been changed.

pins_add

The system message denyoting that a pinnyed message has been added to a channyew.

new_member

The system message denyoting that a nyew membew has joinyed a Guiwd.

premium_guild_subscription

The system message denyoting that a membew h-has “nyitwo boosted” a guiwd.

premium_guild_tier_1

The system message denyoting that a-a membew has “nyitwo boosted” a guiwd and it achieved wevew 1.

premium_guild_tier_2

The system message denyoting that a membew has “nyitwo boosted” a guiwd and it achieved wevew 2.

premium_guild_tier_3

T-The system message denyoting that a membew has “nyitwo boosted” a guiwd and it achieved wevew 3.

channel_follow_add

The system message denyoting that an annyouncement channyew has been fowwowed.

Nyew in vewsion 1.3.

guild_stream

The system message denyoting that a membew is stweaming in t-the guiwd.

Nyew in vewsion 1.7.

guild_discovery_disqualified

The system message denyoting that the guiwd is nyo wongew ewigibwe fow Sewvew Discuvwy.

Nyew in vewsion 1.7.

guild_discovery_requalified

The s-system message denyoting that the guiwd has become ewigibwe again fow Sewvew Discuvwy.

Nyew in vewsion 1.7.

guild_discovery_grace_period_initial_warning

The system message denyoting that the guiwd has faiwed t-to meet the Sewvew Discuvwy wequiwements fow onye week.

Nyew in vewsion 1.7.

guild_discovery_grace_period_final_warning

The system message denyoting that the g-guiwd has faiwed to meet the Sewvew Discuvwy w-wequiwements fow 3 weeks in a wow.

Nyew in vewsion 1.7.

thread_created

The system message denyoting that a thwead has been cweated. This is onwy sent if the thwead has b-been cweated fwom an owdew message. The pewiod o-of time wequiwed fow a message to be considewed owd cannyot be w-w-wewied upon and is up to Discowd.

Nyew in vewsion 2.0.

reply

The system message denyoting that the authow is wepwying to a message.

Nyew in vewsion 2.0.

application_command

The system message denyoting that an appwication (ow “swash”) command was e-executed.

Nyew i-i-in vewsion 2.0.

thread_starter_message

The system message d-d-denyoting the message in the thwead that is the onye that stawted the thwead’s convewsation topic.

Nyew in vewsion 2.0.

guild_invite_reminder

The s-s-system message sent a-as a wemindew to invite peopwe to the guiwd.

Nyew in vewsion 2.0.

context_menu_command

The s-s-system message denyoting that a context menyu command w-w-was e-e-executed.

Nyew in vewsion 2.3.

auto_moderation_action

The system message denyoting that an auto modewation action was executed.

Nyew in vewsion 2.5.

role_subscription_purchase

The system message denyoting t-that a-a-a wowe subscwiption was puwchased.

Nyew in vewsion 2.9.

interaction_premium_upsell

The system message fow an a-appwication pwemium subscwiption upseww.

Nyew in vewsion 2.8.

stage_start

The system message denyoting the stage has been stawted.

Nyew in vewsion 2.9.

stage_end

The system message denyoting the stage has ended.

Nyew in vewsion 2.9.

stage_speaker

The system message denyoting a usew has become a speakew.

Nyew in vewsion 2.9.

stage_topic

The system message denyoting the stage topic has been changed.

Nyew in v-v-vewsion 2.9.

guild_application_premium_subscription

The s-system message denyoting that a guiwd membew has subscwibed to an appwication.

Nyew in vewsion 2.8.

guild_incident_alert_mode_enabled

The system message denyoting that an admin enyabwed secuwity actions.

Nyew in vewsion 2.10.

guild_incident_alert_mode_disabled

The system message denyoting that an admin disabwed secuwity actions.

Nyew in vewsion 2.10.

guild_incident_report_raid

The system message denyoting that an admin wepowted a-a-a waid.

Nyew in vewsion 2.10.

guild_incident_report_false_alarm

The system message denyoting that a waid wepowt was a fawse awawm.

Nyew in vewsion 2.10.

poll_result

The system m-message denyoting t-that a poww expiwed, annyouncing the most voted answew.

Nyew in vewsion 2.10.

PowwWayoutType

class disnake.PollLayoutType[source]

S-Specifies the wayout of a Poll.

Nyew i-i-in vewsion 2.10.

default

The defauwt poww wayout type.

MessageWefewenceType

class disnake.MessageReferenceType[source]

Specifies the type of MessageReference. This can be used to detewminye if a message is e.g. a wepwy ow a fowwawded message.

Nyew in vewsion 2.10.

default

A standawd message wefewence used in message wepwies.

forward

Wefewence used to point t-t-to a message at a point in time (fowwawd).

Events