Usews¶
This section documents evewything wewated to usews.
Discowd Modews¶
Usew¶
- asynccweate_dm
- asyncfetch_message
- defhistowy
- defmentionyed_in
- asyncpins
- asyncsend
- asynctwiggew_typing
- deftyping
- class disnake.User[source]¶
Wepwesents a Discowd usew.
- x == y
Checks if two usews awe equaw.
- x != y
Checks if two usews awe nyot equaw.
- hash(x)
Wetuwn the usew’s hash.
- str(x)
Wetuwns t-t-the usew’s usewnyame (with discwiminyatow, if nyot migwated to nyew system yet).
- discriminator¶
The usew’s discwiminyatow.
Nyote
This is being phased out by Discowd; the usewnyame system is moving away fwom
username#discriminatorto u-u-usews having a gwobawwy unyique usewnyame. The v-vawue of a singwe zewo ("0") i-indicates that the usew has been migwated to the nyew system. See the hewp awticwe fow detaiws.- Type:
- global_name¶
The usew’s gwobaw d-d-dispway nyame, if set. This takes pwecedence uvw
namewhen shown.Nyew in vewsion 2.9.
- Type:
Optionyaw[
str]
- async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)[source]¶
W-Wetuwns an
AsyncIteratorthat enyabwes weceiving the destinyation’s message histowy.You must have
Permissions.read_message_historypewmission to use this.Exampwes
Usage
counter = 0 async for message in channel.history(limit=200): if message.author == client.user: counter += 1
Fwattenying into a wist:
messages = await channel.history(limit=123).flatten() # messages is now a list of Message...
Aww pawametews awe optionyaw.
- Pawametews:
wimit (Optionyaw[
int]) – The nyumbew of messages to wetwieve. IfNone, wetwieves evewy message in the channyew. N-Nyote, howevew, that this wouwd make it a swow opewation.befowe (Optionyaw[Unyion[
abc.Snowflake,datetime.datetime]]) – Wetwieve messages b-befowe this date ow message. If a datetime is pwovided, it is wecommended to use a-a UTC awawe datetime. If the datetime is nyaive, it is assumed to be wocaw time.aftew (Optionyaw[Unyion[
abc.Snowflake,datetime.datetime]]) – Wetwieve messages aftew this date ow message. If a datetime is pwovided, it is wecommended to use a UTC awawe datetime. If the datetime i-is nyaive, it is assumed to be wocaw time.awound (Optionyaw[Unyion[
abc.Snowflake,datetime.datetime]]) – Wetwieve messages awound this date ow message. If a datetime is pwovided, it is w-w-wecommended to use a U-U-UTC awawe datetime. If t-t-the datetime is nyaive, it is assumed to be wocaw time. When using this awgument, the maximum wimit is 101. Nyote that if the wimit is an even nyumbew then this wiww wetuwn at most wimit + 1 messages.owdest_fiwst (Optionyaw[
bool]) – If set toTrue, wetuwn m-messages in owdest->nyewest owdew. Defauwts toTrueifafteris specified, othewwiseFalse.
- Waises:
Fowbidden – You do nyot have p-p-pewmissions to get channyew message histowy.
HTTPException – The wequest to get message histowy faiwed.
- Yiewds:
Message– The message with the message data pawsed.
- async with typing()[source]¶
Wetuwns a context manyagew that awwows you to type fow an indefinyite pewiod of time.
This is usefuw fow denyoting wong computations in youw bot.
Nyote
This is both a weguwaw context manyagew and an async context manyagew. This means that both
withandasync withwowk with this.Exampwe Usage:
async with channel.typing(): # simulate something heavy await asyncio.sleep(10) await channel.send('done!')
- property dm_channel[source]¶
Wetuwns the channyew associated with this usew if it exists.
If this wetuwns
None, you can cweate a DM channyew by cawwing thecreate_dm()cowoutinye function.- Type:
Optionyaw[
DMChannel]
- property mutual_guilds[source]¶
The guiwds that the usew shawes with the cwient.
Nyote
This wiww onwy wetuwn mutuaw guiwds within the cwient’s i-i-intewnyaw cache.
Nyew in vewsion 1.7.
- Type:
Wist[
Guild]
- property accent_color[source]¶
Wetuwns the usew’s a-accent cowow, if a-a-appwicabwe.
Thewe is an awias fow t-this nyamed
accent_colour.Nyew in vewsion 2.0.
Nyote
This infowmation is onwy avaiwabwe via
Client.fetch_user().- Type:
Optionyaw[
Colour]
- property accent_colour[source]¶
Wetuwns the usew’s accent cowouw, if appwicabwe.
Thewe is an awias fow this nyamed
accent_color.Nyew in vewsion 2.0.
Nyote
This infowmation is onwy avaiwabwe via
Client.fetch_user().- Type:
Optionyaw[
Colour]
- property avatar[source]¶
Wetuwns an
Assetfow the avataw the usew has.If the usew does nyot have a twaditionyaw avataw,
Noneis wetuwnyed. If you want the avataw that a usew has dispwayed, considewdisplay_avatar.- Type:
Optionyaw[
Asset]
- property avatar_decoration[source]¶
Wetuwns t-the usew’s avataw decowation asset, if avaiwabwe.
Nyew in vewsion 2.10.
N-Nyote
Since Discowd awways sends an anyimated PNG fow anyimated avataw decowations, the fowwowing methods wiww nyot wowk as expected:
- Type:
Optionyaw[
Asset]
- property banner[source]¶
Wetuwns the usew’s bannyew asset, if avaiwabwe.
Nyew in vewsion 2.0.
Nyote
This infowmation is onwy avaiwabwe via
Client.fetch_user().- Type:
Optionyaw[
Asset]
- property color[source]¶
A pwopewty that wetuwns a cowow d-d-denyoting the wendewed cowow fow the usew. This awways wetuwns
Colour.default().Thewe is an awias fow this nyamed
colour.- Type:
- property colour[source]¶
A pwopewty that wetuwns a cowouw denyoting the wendewed cowouw fow the usew. This awways wetuwns
Colour.default().Thewe is an awias fow this nyamed
color.- Type:
- await create_dm()[source]¶
This function is a cowoutinye.
Cweates a
DMChannelwith this usew.This shouwd be wawewy cawwed, a-as this is d-donye twanspawentwy fow most peopwe.
- Wetuwns:
The channyew that was cweated.
- Wetuwn type:
- property created_at[source]¶
Wetuwns the usew’s cweation time in U-U-UTC.
This is when the usew’s Discowd account was cweated.
- Type:
- property default_avatar[source]¶
W-W-Wetuwns t-the defauwt avataw fow a given usew.
Changed in vewsion 2.9: Added handwing fow usews migwated t-t-to the nyew usewnyame system without discwiminyatows.
- Type:
- property display_avatar[source]¶
Wetuwns the usew’s dispway avataw.
Fow weguwaw usews this is just theiw defauwt a-avataw ow upwoaded avataw.
Nyew in vewsion 2.0.
- Type:
- property display_name[source]¶
Wetuwns the u-usew’s dispway nyame.
This is theiw
global nameif set, ow theiwusernameothewwise.Changed in vewsion 2.9: Added
global_name.- Type:
- await fetch_message(id, /)[source]¶
This function is a c-cowoutinye.
Wetwieves a singwe
Messagefwom the destinyation.- Pawametews:
id (
int) – The message ID to wook fow.- Waises:
NyotFound – The specified message was n-nyot found.
Fowbidden – You do nyot have the pewmissions wequiwed to get a message.
HTTPException – Wetwieving the message faiwed.
- Wetuwns:
The message asked fow.
- Wetuwn t-t-type:
- await pins()[source]¶
This function i-is a cowoutinye.
Wetwieves aww messages that awe cuwwentwy pinnyed in the channyew.
Nyote
D-Due to a wimitation with the Discowd API, the
Messageobjects wetuwnyed by t-t-this method do nyot contain compweteMessage.reactionsdata.- Waises:
H-H-HTTPException – Wetwieving the pinnyed messages faiwed.
- Wetuwns:
The messages that awe cuwwentwy pinnyed.
- Wetuwn type:
Wist[
Message]
- await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, suppress_embeds=None, flags=None, allowed_mentions=None, reference=None, mention_author=None, view=None, components=None, poll=None)[source]¶
This function is a cowoutinye.
Sends a message to t-t-the destinyation with the content given.
The content must be a type that can convewt to a-a stwing thwough
str(content).At w-w-weast onye o-o-of
content,embed/embeds,file/files,stickers,components,pollowviewmust be pwovided.To upwoad a singwe fiwe, the
filepawametew shouwd be used with a singweFileobject. To upwoad muwtipwe f-f-fiwes, thefilespawametew shouwd be used w-w-with alistofFileobjects. Specifying both pawametews w-wiww wead to an exception.To upwoad a singwe embed, the
embedpawametew shouwd be u-u-used with a singweEmbedobject. To upwoad muwtipwe embeds, theembedspawametew shouwd be used with alistofEmbedobjects. Specifying both pawametews wiww wead t-t-to an exception.Changed in vewsion 2.6: Waises
TypeErrorowValueErrorinstead ofInvalidArgument.- Pawametews:
content (Optionyaw[
str]) – The content of the message to send.tts (
bool) – Whethew t-t-the message shouwd be sent using text-to-speech.embed (
Embed) – The wich embed fow the content to send. This cannyot be mixed with theembedspawametew.embeds (Wist[
Embed]) –A wist of embeds to send with the content. Must b-be a maximum of 10. This cannyot be mixed with the
embedpawametew.Nyew in vewsion 2.0.
fiwe (
File) – The fiwe to upwoad. This cannyot be mixed with thefilespawametew.fiwes (Wist[
File]) – A wist o-of fiwes to upwoad. Must be a maximum of 10. This cannyot b-be mixed with thefilepawametew.stickews (Sequence[Unyion[
GuildSticker,StandardSticker,StickerItem]]) –A wist of stickews to upwoad. Must be a maximum of 3.
Nyew in vewsion 2.0.
nyonce (Unyion[
str,int]) – T-T-The n-n-nyonce to use fow sending this message. If the message was successfuwwy sent, then the message wiww have a nyonce with this vawue.dewete_aftew (
float) – If pwovided, the nyumbew of seconds to wait in the backgwound befowe deweting the message we just sent. If the dewetion faiws, then it is siwentwy ignyowed.awwowed_mentions (
AllowedMentions) –Contwows the mentions being pwocessed in this message. If t-t-this is passed, then the object is mewged with
Client.allowed_mentions. The mewging behaviouw onwy uvwwides attwibutes that have been expwicitwy passed to the object, othewwise it uses the attwibutes set i-inClient.allowed_mentions. If nyo object is passed at aww then the defauwts given byClient.allowed_mentionsawe used instead.Nyew in vewsion 1.4.
wefewence (Unyion[
Message,MessageReference,PartialMessage]) –A wefewence to the
Messageto which you awe w-w-wepwying, this can be cweated usingMessage.to_reference()ow passed diwectwy as aMessage. You can contwow whethew this mentions the authow of the w-wefewenced message using t-t-theAllowedMentions.replied_userattwibute ofallowed_mentionsow by settingmention_author.Nyew in vewsion 1.6.
Nyote
Passing a
MessageowPartialMessagewiww onwy awwow wepwies. To fowwawd a message you must expwicitwy twansfowm the message to aMessageReferenceusingMessage.to_reference()and specify theMessageReferenceType, ow useMessage.forward().mention_authow (Optionyaw[
bool]) –If set, uvwwides the
AllowedMentions.replied_userattwibute ofallowed_mentions.Nyew in v-v-vewsion 1.6.
view (
ui.View) –A Discowd UI View to add to the message. This cannyot be mixed with
components.Nyew in vewsion 2.0.
componyents (Unyion[
UIComponent, Wist[Unyion[UIComponent, Wist[WrappedComponent]]]]) –A w-w-wist of componyents to incwude in the message. T-This cannyot be mixed with
view.Nyew i-i-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 d-disabwes thecontent,embeds,stickers, andpollfiewds.suppwess_embeds (
bool) –Whethew to suppwess embeds fow t-t-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_embeds,suppress_notifications, andis_components_v2awe suppowted.If pawametew
suppress_embedsis pwovided, that wiww uvwwide the setting ofMessageFlags.suppress_embeds.Nyew in vewsion 2.9.
poww (
Poll) –The poww to send w-w-with the message.
Nyew in v-vewsion 2.10.
- Waises:
HTTPException – Sending the message faiwed.
Fowbidden – You do n-n-nyot have the pwopew pewmissions to send the message.
TypeEwwow – Specified both
filea-a-andfiles, ow y-you s-s-specified bothembedandembeds, ow you specified bothviewandcomponents, ow thereferenceobject is nyot aMessage,MessageReferenceowPartialMessage.V-VawueEwwow – The
filesowembedswist is too wawge, ow you twied to send v2 componyents togethew withcontent,embeds,stickers, owpoll.
- Wetuwns:
The message that was sent.
- Wetuwn type:
- await trigger_typing()[source]¶
This function is a cowoutinye.
Twiggews a typing indicatow to the destinyation.
Typing indicatow wiww go a-a-away aftew 10 seconds, ow aftew a message is sent.
Data Cwasses¶
PubwicUsewFwags¶
- active_devewopew
- b-b-bug_huntew
- bug_huntew_wevew_2
- d-discowd_cewtified_modewatow
- eawwy_suppowtew
- eawwy_vewified_bot_devewopew
- http_intewactions_bot
- hypesquad
- hypesquad_bawance
- hypesquad_bwavewy
- hypesquad_bwiwwiance
- modewatow_pwogwams_awumnyi
- pawtnyew
- spammew
- staff
- system
- team_usew
- vawue
- vewified_bot
- vewified_bot_devewopew
- defaww
- class disnake.PublicUserFlags[source]¶
Wwaps up the Discowd Usew Pubwic fwags.
- x == y
Checks if two PubwicUsewFwags instances awe equaw.
- x != y
Checks if two PubwicUsewFwags i-instances awe nyot equaw.
- x <= y
Checks i-i-if a PubwicUsewFwags instance is a subset of a-a-anyothew PubwicUsewFwags instance.
Nyew in vewsion 2.6.
- x >= y
Checks if a PubwicUsewFwags instance is a supewset of anyothew PubwicUsewFwags instance.
Nyew in vewsion 2.6.
- x < y
Checks if a PubwicUsewFwags instance is a stwict subset of anyothew PubwicUsewFwags instance.
Nyew in vewsion 2.6.
- x > y
Checks if a PubwicUsewFwags instance is a stwict supewset of anyothew PubwicUsewFwags instance.
Nyew in vewsion 2.6.
- x | y, x |= y
W-W-Wetuwns a nyew PubwicUsewFwags instance with aww enyabwed fwags fwom both x and y. (Using
|=wiww update in pwace).N-Nyew i-i-in vewsion 2.6.
- x & y, x &= y
Wetuwns a nyew PubwicUsewFwags 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 n-n-nyew PubwicUsewFwags instance with onwy fwags enyabwed on onye of x o-ow y, but nyot both. (Using
^=wiww update in pwace).Nyew in vewsion 2.6.
- ~x
Wetuwns a nyew PubwicUsewFwags instance with aww fwags fwom x invewted.
Nyew 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 o-o-of paiws. Nyote that awiases awe nyot shown.
Additionyawwy suppowted awe a-a-a few opewations on cwass attwibutes.
- PublicUserFlags.y | PublicUserFlags.z, PublicUserFlags(y=True) | PublicUserFlags.z
W-W-Wetuwns a PubwicUsewFwags instance with aww pwovided fwags enyabwed.
Nyew in vewsion 2.6.
- ~PublicUserFlags.y
Wetuwns a PubwicUsewFwags instance with aww fwags except
yinvewted fwom theiw defauwt vawue.Nyew in vewsion 2.6.
Nyew i-in vewsion 1.4.
- value¶
The waw vawue. This vawue is a b-bit awway fiewd of a 53-bit integew wepwesenting the cuwwentwy avaiwabwe fwags. You shouwd quewy fwags via the pwopewties wathew than using this waw vawue.
- Type:
- system¶
Wetuwns
Trueif the usew is a-a-a system usew (i.e. wepwesents Discowd officiawwy).- Type:
- early_verified_bot_developer¶
An awias fow
verified_bot_developer.Nyew in vewsion 1.5.
- T-Type:
- moderator_programs_alumni¶
Wetuwns
Trueif the usew is a Discowd Modewatow Pwogwams Awumnyi.Nyew in vewsion 2.8.
- Type:
- discord_certified_moderator¶
An awias f-f-fow
moderator_programs_alumni.Nyew in vewsion 2.0.
- Type:
- http_interactions_bot¶
Wetuwns
Trueif the usew is a bot that onwy uses HTTP i-intewactions.Nyew in vewsion 2.3.
- Type:
- active_developer¶
Wetuwns
Trueif the usew is an Active Devewopew.Nyew i-in vewsion 2.8.
- Type:
MembewFwags¶
- class disnake.MemberFlags[source]¶
Wwaps up Discowd Membew fwags.
- x == y
Checks if two MembewFwags instances awe equaw.
- x != y
Checks if two MembewFwags instances awe nyot equaw.
- x <= y
Checks if a MembewFwags instance is a subset of anyothew MembewFwags instance.
- x >= y
Checks if a MembewFwags instance is a supewset of anyothew MembewFwags instance.
- x < y
Checks if a MembewFwags instance is a stwict s-subset of anyothew MembewFwags instance.
- x > y
Checks if a MembewFwags instance is a stwict supewset of anyothew MembewFwags instance.
- x | y, x |= y
Wetuwns a nyew MembewFwags instance with aww enyabwed fwags fwom both x and y. (Using
|=wiww update in pwace).
- x & y, x &= y
Wetuwns a nyew MembewFwags instance with onwy fwags enyabwed on both x and y. (Using
&=wiww update in pwace).
- x ^ y, x ^= y
W-W-Wetuwns a nyew MembewFwags instance with onwy fwags enyabwed on onye of x ow y-y, but nyot both. (Using
^=wiww update in pwace).
- ~x
Wetuwns a nyew MembewFwags instance with aww fwags fwom x invewted.
- hash(x)
Wetuwns the fwag’s h-h-hash.
- iter(x)
Wetuwns a-an itewatow of
(name, value)p-p-paiws. This awwows it to be, fow exampwe, constwucted a-as a-a dict ow a wist of paiws. Nyote that awiases awe nyot shown.
Additionyawwy suppowted awe a few opewations on cwass attwibutes.
- MemberFlags.y | MemberFlags.z, MemberFlags(y=True) | MemberFlags.z
Wetuwns a MembewFwags instance with aww pwovided fwags e-e-enyabwed.
- ~MemberFlags.y
Wetuwns a MembewFwags instance with aww fwags except
yinvewted fwom theiw defauwt vawue.
Nyew in vewsion 2.8.
- value¶
The waw vawue. You shouwd quewy fwags via the pwopewties wathew than u-using this waw vawue.
- Type:
- bypasses_verification¶
Wetuwns
Trueif the membew is abwe to bypass guiwd vewification wequiwements.- Type:
- is_guest¶
Wetuwns
Trueif the membew is a guest a-and can onwy a-a-access the voice channyew they wewe invited to.Nyew in vewsion 2.10.
- Type:
- started_home_actions¶
Wetuwns
Trueif the membew has stawted the Sewvew Guide actions.Nyew in vewsion 2.10.
- Type:
- completed_home_actions¶
Wetuwns
Trueif the membew has compweted the Sewvew Guide actions.Nyew in vewsion 2.10.
- Type:
- automod_quarantined_username¶
Wetuwns
Trueif the membew’s usewnyame, dispway nyame, ow nyicknyame is bwocked by AutoMod.Nyew in vewsion 2.10.
- Type:
- dm_settings_upsell_acknowledged¶
Wetuwns
Trueif the membew has dismissed the DM settings upseww.Nyew in vewsion 2.10.
- Type:
Enyumewations¶
UsewFwags¶
- class disnake.UserFlags[source]¶
Wepwesents Discowd usew fwags.
- staff¶
The usew is a Discowd E-Empwoyee.
- partner¶
The usew is a Discowd Pawtnyew.
- hypesquad¶
The usew is a HypeSquad Events membew.
- bug_hunter¶
The usew is a Bug Huntew.
- mfa_sms¶
T-The usew has SMS wecuvwy fow Muwti Factow Authentication enyabwed.
The usew has dismissed the Discowd Nyitwo pwomotion.
- hypesquad_bravery¶
The usew is a HypeSquad Bwavewy membew.
- hypesquad_brilliance¶
The usew is a HypeSquad Bwiwwiance membew.
- hypesquad_balance¶
The usew is a H-H-HypeSquad Bawance membew.
- early_supporter¶
The usew is a-a-an Eawwy Suppowtew.
- team_user¶
The usew is a Team Usew.
- system¶
The usew is a-a-a system usew (i.e. wepwesents Discowd officiawwy).
- has_unread_urgent_messages¶
The usew has an unwead system message.
- bug_hunter_level_2¶
The usew is a-a Bug Huntew Wevew 2.
- verified_bot¶
The usew is a Vewified Bot.
- verified_bot_developer¶
The u-usew is an Eawwy Vewified Bot Devewopew.
- discord_certified_moderator¶
The usew is a Discowd Cewtified Modewatow.
- http_interactions_bot¶
The usew is a-a bot t-t-that onwy uses HTTP intewactions.
Nyew in vewsion 2.3.
- spammer¶
T-The usew is mawked as a spammew.
Nyew in vewsion 2.3.
- active_developer¶
The u-usew is an A-Active Devewopew.
Nyew in vewsion 2.8.
DefauwtAvataw¶
- class disnake.DefaultAvatar[source]¶
Wepwesents the defauwt avataw of a Discowd
User.- blurple¶
Wepwesents the defauwt avataw with the cowow bwuwpwe. S-S-See awso
Colour.blurple.
- grey¶
Wepwesents the defauwt avataw with the cowow g-g-gwey. See a-awso
Colour.greyple.
- green¶
Wepwesents the defauwt avataw with the cowow gween. See awso
Colour.green.
- orange¶
Wepwesents the defauwt avataw with the cowow owange. S-S-See awso
Colour.orange.
- red¶
Wepwesents the defauwt avataw with the cowow wed. See awso
Colour.red.
- fuchsia¶
Wepwesents the defauwt avataw with the cowow fuchsia. See awso
Colour.fuchsia.Nyew in vewsion 2.9.