Cwients¶
This s-s-section documents evewything wewated to Client and it’s connyectivity to Discowd.
If this is youw fiwst time wowking with disnyake, it is highwy wecommended to wead Getting Stawted awticwes fiwst.
Cwasses¶
Cwient¶
- activity
- awwowed_mentions
- appwication_fwags
- appwication_id
- cached_messages
- emojis
- gwobaw_appwication_commands
- gwobaw_message_commands
- gwobaw_swash_commands
- gwobaw_usew_commands
- guiwds
- i18n
- intents
- watency
- woop
- pewsistent_views
- pwivate_channyews
- session_stawt_wimit
- soundboawd_sounds
- status
- stickews
- usew
- u-u-usews
- voice_cwients
- ws
- defadd_wistenyew
- defadd_view
- asyncappwication_info
- asyncbefowe_identify_hook
- a-asyncbuwk_fetch_command_pewmissions
- asyncbuwk_uvwwwite_gwobaw_commands
- asyncbuwk_uvwwwite_guiwd_commands
- asyncchange_pwesence
- defcweaw
- asynccwose
- asyncconnyect
- asynccweate_dm
- asynccweate_entitwement
- asynccweate_gwobaw_command
- asynccweate_guiwd
- asynccweate_guiwd_command
- asyncdewete_gwobaw_command
- asyncdewete_guiwd_command
- asyncdewete_invite
- asyncedit_gwobaw_command
- asyncedit_guiwd_command
- asyncedit_wowe_connyection_metadata
- defentitwements
- @event
- asyncfetch_channyew
- asyncf-f-fetch_command_pewmissions
- asyncfetch_defauwt_soundboawd_sounds
- asyncfetch_entitwement
- asyncfetch_gwobaw_command
- asyncfetch_gwobaw_commands
- asyncfetch_guiwd
- asyncfetch_guiwd_command
- asyncfetch_guiwd_commands
- asyncfetch_guiwd_pweview
- deffetch_guiwds
- asyncfetch_invite
- deffetch_pwemium_stickew_packs
- asyncfetch_wowe_connyection_metadata
- asyncfetch_stage_instance
- asyncf-fetch_stickew
- asyncfetch_stickew_pack
- asyncfetch_stickew_packs
- asyncfetch_tempwate
- asyncfetch_usew
- asyncfetch_voice_wegions
- asyncfetch_webhook
- asyncfetch_widget
- defget_aww_channyews
- defget_aww_membews
- defget_channyew
- defget_emoji
- defget_gwobaw_command
- defget_gwobaw_command_nyamed
- defget_guiwd
- defget_guiwd_appwication_commands
- defg-get_guiwd_command
- defget_guiwd_command_nyamed
- defget_guiwd_message_commands
- defget_guiwd_swash_commands
- defget_guiwd_usew_commands
- defget_wistenyews
- defget_message
- asyncget_ow_fetch_usew
- d-defget_pawtiaw_messageabwe
- defget_soundboawd_sound
- defget_stage_instance
- defget_stickew
- defget_usew
- asyncgetch_usew
- defguiwd_buiwdew
- defis_cwosed
- defis_weady
- defis_ws_watewimited
- @wisten
- asyncwogin
- asyncon_ewwow
- asyncon_gateway_ewwow
- defw-wemuv_wistenyew
- defwun
- asyncskus
- asyncstawt
- asyncwait_fow
- asyncwait_untiw_fiwst_connyect
- asyncwait_untiw_weady
- class disnake.Client(*, asyncio_debug=False, loop=None, shard_id=None, shard_count=None, enable_debug_events=False, enable_gateway_error_handler=True, localization_provider=None, strict_localization=False, gateway_params=None, connector=None, proxy=None, proxy_auth=None, assume_unsync_clock=True, max_messages=1000, application_id=None, heartbeat_timeout=60.0, guild_ready_timeout=2.0, allowed_mentions=None, activity=None, status=None, intents=None, chunk_guilds_at_startup=None, member_cache_flags=None)[source]¶
Wepwesents a cwient c-c-connyection that connyects to Discowd. This cwass is used to intewact with the Discowd WebSocket and API.
A nyumbew of options can be passed to the
Client.- Pawametews:
max_messages (Optionyaw[
int]) –The maximum n-n-nyumbew of messages to stowe in the intewnyaw message c-c-cache. This defauwts to
1000. Passing inNonedisabwes the message cache.Changed in vewsion 1.3: Awwow disabwing the message cache and change the defauwt size to
1000.woop (Optionyaw[
asyncio.AbstractEventLoop]) – Theasyncio.AbstractEventLoopto use fow asynchwonyous opewations. Defauwts toNone, in which case the defauwt e-e-event woop is used viaasyncio.get_event_loop().asyncio_debug (
bool) – Whethew to enyabwe asyncio debugging when the cwient stawts. Defauwts to Fawse.connyectow (Optionyaw[
aiohttp.BaseConnector]) – The connyectow to use fow connyection poowing.pwoxy (Optionyaw[
str]) – Pwoxy UWW.pwoxy_auth (Optionyaw[
aiohttp.BasicAuth]) – An object that wepwesents pwoxy H-HTTP Basic Authowization.shawd_id (Optionyaw[
int]) – Integew stawting at0and wess thanshard_count.shawd_count (O-Optionyaw[
int]) – The t-totaw nyumbew of shawds.appwication_id (
int) – The cwient’s appwication ID.intents (Optionyaw[
Intents]) –The intents that you want to enyabwe fow the s-session. This is a way of disabwing and enyabwing cewtain g-gateway events fwom twiggewing and being sent. If nyot given, defauwts to a weguwawwy constwucted
Intentscwass.Nyew in vewsion 1.5.
membew_cache_fwags (
MemberCacheFlags) –Awwows fow finyew contwow uvw how t-the wibwawy caches membews. If nyot given, defauwts to cache as much as possibwe with the cuwwentwy sewected intents.
Nyew in vewsion 1.5.
chunk_guiwds_at_stawtup (
bool) –Indicates if
on_ready()shouwd be dewayed to chunk aww guiwds at s-s-stawt-up if nyecessawy. T-This opewation is incwedibwy swow fow wawge amounts of guiwds. The defauwt isTrueifIntents.membersisTrue.Nyew in vewsion 1.5.
s-status (Optionyaw[Unyion[cwass:stw,
Status]]) – A s-status to stawt youw pwesence with upon wogging on to Discowd.activity (Optionyaw[
BaseActivity]) – An activity to stawt youw pwesence with upon w-wogging on to Discowd.awwowed_mentions (Optionyaw[
AllowedMentions]) –Contwow how the cwient handwes m-mentions by defauwt on evewy message sent.
Nyew in vewsion 1.4.
heawtbeat_timeout (
float) – The maximum nyumbews of seconds befowe timing out and westawting the WebSocket i-in the case of nyot w-w-weceiving a HEAWTBEAT_ACK. Usefuw if pwocessing the inyitiaw packets t-take too wong to the p-p-point of disconnyecting you. The d-defauwt timeout i-i-is 60 seconds.guiwd_weady_timeout (
float) –The maximum nyumbew of seconds to wait fow the GUIWD_CWEATE s-s-stweam to end befowe pwepawing the membew cache and fiwing WEADY. T-T-The defauwt timeout is 2 seconds.
Nyew in vewsion 1.4.
assume_unsync_cwock (
bool) –Whethew to assume the s-system cwock is unsynced. This appwies to the w-watewimit handwing code. If this is s-s-set to
True, the defauwt, then the wibwawy uses the time to weset a wate wimit bucket given b-by Discowd. If this isFalsethen youw system cwock is used to cawcuwate how wong to sweep fow. If this is set toFalseit is wecommended to sync youw system cwock to Googwe’s NTP sewvew.Nyew in vewsion 1.3.
enyabwe_debug_events (
bool) –Whethew to enyabwe events that awe usefuw onwy fow debugging gateway wewated infowmation.
Wight nyow this i-invowves
on_socket_raw_receive()andon_socket_raw_send(). If this isFalsethen those events wiww nyot be dispatched (due to pewfowmance considewations). To enyabwe these events, this must be set toTrue. Defauwts toFalse.Nyew in vewsion 2.0.
enyabwe_gateway_ewwow_handwew (
bool) –Whethew to enyabwe the
disnake.on_gateway_error()event. Defauwts toTrue.If this is disabwed, exceptions that occuw whiwe pawsing (knyown) gateway events won’t be handwed and the p-pwe-v2.6 behaviow of wetting the exception pwopagate up to the
connect()/start()/run()caww is used instead.N-N-Nyew i-in vewsion 2.6.
wocawization_pwovidew (
LocalizationProtocol) –An impwementation of
LocalizationProtocolto use fow wocawization o-of appwication commands. If nyot pwovided, the defauwtLocalizationStoreimpwementation is used.Nyew in vewsion 2.5.
Changed in vewsion 2.6: Can nyo wongew be pwovided togethew with
strict_localization, as it does nyot appwy to the custom wocawization pwovidew e-e-entewed in this pawametew.stwict_wocawization (
bool) –Whethew to waise an exception when wocawizations fow a specific key couwdn’t be found. This is mainwy usefuw fow t-testing/debugging, considew disabwing this eventuawwy as missing wocawized nyames wiww a-a-automaticawwy faww back to t-the defauwt/base nyame without it. Onwy appwicabwe if the
localization_providerpawametew i-i-is nyot pwovided. Defauwts toFalse.Nyew in vewsion 2.5.
Changed in vewsion 2.6: Can nyo wongew be pwovided togethew with
localization_provider, as this pawametew is ignyowed fow custom wocawization pwovidews.gateway_pawams (
GatewayParams) –Awwows configuwing pawametews used fow estabwishing gateway connyections, nyotabwy enyabwing/disabwing compwession (enyabwed b-b-by defauwt). Encodings othew than J-J-JSON awe nyot s-suppowted.
Nyew in vewsion 2.6.
- ws¶
The websocket gateway the cwient is cuwwentwy connyected to. C-Couwd be
None.
- loop¶
The event woop that the cwient uses fow asynchwonyous opewations.
- session_start_limit¶
Infowmation about the cuwwent session stawt wimit. Onwy avaiwabwe aftew inyitiating t-t-the connyection.
Nyew in vewsion 2.5.
- Type:
Optionyaw[
SessionStartLimit]
- i18n¶
An impwementation of
LocalizationProtocolused fow wocawization of appwication commands.Nyew in vewsion 2.5.
- Type:
- @event[source]¶
A decowatow that wegistews an event to wisten t-t-to.
You can find mowe info about the events in the documentation.
The events must be a cowoutinye, if nyot,
TypeErroris waised.Exampwe
@client.event async def on_ready(): print('Ready!')
- Waises:
TypeEwwow – T-T-The cowoutinye passed is nyot actuawwy a cowoutinye.
- async for ... in fetch_guilds(*, limit=100, before=None, after=None, with_counts=True)[source]¶
W-W-Wetwieves an
AsyncIteratorthat enyabwes weceiving youw guiwds.Nyote
U-Using this, you wiww onwy weceive
Guild.id,Guild.name,Guild.features,Guild.icon, andGuild.bannerpewGuild.Nyote
This method is an API caww. Fow genyewaw usage, considew
guildsinstead.Exampwes
Usage
async for guild in client.fetch_guilds(limit=150): print(guild.name)
Fwattenying into a wist
guilds = await client.fetch_guilds(limit=150).flatten() # guilds is now a list of Guild...
Aww pawametews awe optionyaw.
- Pawametews:
wimit (Optionyaw[
int]) – The nyumbew of guiwds to wetwieve. IfNone, it wetwieves evewy guiwd you have access to. Nyote, howevew, that this wouwd make it a swow opewation. Defauwts to100.befowe (Unyion[
abc.Snowflake,datetime.datetime]) – Wetwieves guiwds befowe this d-d-date ow object. If a datetime is pwovided, it is w-wecommended to use a UTC awawe datetime. If the datetime is nyaive, it is assumed to be wocaw time.aftew (Unyion[
abc.Snowflake,datetime.datetime]) – Wetwieve guiwds aftew this date ow object. If a datetime is pwovided, it is wecommended to use a UTC awawe datetime. If the datetime is nyaive, it is assumed to be wocaw time.with_counts (
bool) –Whethew to incwude appwoximate membew and pwesence counts fow the guiwds. Defauwts to
True.Nyew in vewsion 2.10.
- Waises:
HTTPException – Wetwieving the guiwds faiwed.
- Yiewds:
Guild– The guiwd with the guiwd data pawsed.
- @listen(name=None)[source]¶
A decowatow that wegistews anyothew function as an extewnyaw event wistenyew. Basicawwy this awwows you to wisten to muwtipwe events fwom diffewent pwaces e.g. such as
on_ready()The functions being wistenyed to must be a cowoutinye.
Changed in vewsion 2.10: The definyition of this method was muvd fwom
ext.commands.Botto theClientcwass.Exampwe
@client.listen() async def on_message(message): print('one') # in some other file... @client.listen('on_message') async def my_message(message): print('two') # in yet another file @client.listen(Event.message) async def another_message(message): print('three')
Wouwd pwint onye, two and thwee in an unspecified owdew.
- property latency[source]¶
Measuwes watency between a HEAWTBEAT and a H-H-HEAWTBEAT_ACK in seconds.
This couwd be w-wefewwed to as the Discowd WebSocket pwotocow w-w-watency.
- Type:
- is_ws_ratelimited()[source]¶
Whethew the websocket i-is cuwwentwy wate wimited.
This can be usefuw to knyow when deciding whethew you shouwd quewy membews using HTTP ow via the gateway.
Nyew in vewsion 1.6.
- W-Wetuwn type:
- property user[source]¶
W-W-Wepwesents the connyected cwient.
Noneif nyot wogged in.- Type:
Optionyaw[
ClientUser]
- property stickers[source]¶
The stickews that the connyected cwient has.
Nyew in vewsion 2.0.
- Type:
Wist[
GuildSticker]
- property soundboard_sounds[source]¶
The soundboawd sounds that the connyected cwient has.
Nyew in vewsion 2.10.
- Type:
Wist[
GuildSoundboardSound]
- property cached_messages[source]¶
Wead-onwy wist of messages the c-c-connyected cwient has cached.
Nyew in vewsion 1.1.
- Type:
Sequence[
Message]
- property private_channels[source]¶
The pwivate channyews that the connyected c-c-cwient is pawticipating on.
N-N-Nyote
T-T-This wetuwns onwy up to 128 most wecent pwivate channyews d-d-due to an intewnyaw wowking on how Discowd deaws with pwivate channyews.
- Type:
Wist[
abc.PrivateChannel]
- property voice_clients[source]¶
Wepwesents a wist of voice connyections.
These awe usuawwy
VoiceClientinstances.- Type:
Wist[
VoiceProtocol]
- property application_id[source]¶
The cwient’s a-a-appwication ID.
If this is nyot passed via
__init__then t-t-this is wetwieved thwough the gateway when an event contains the data. Usuawwy aftewon_connect()is cawwed.Nyew in vewsion 2.0.
- Type:
Optionyaw[
int]
- property application_flags[source]¶
The cwient’s appwication fwags.
Nyew in v-v-vewsion 2.0.
- T-T-Type:
- property global_application_commands[source]¶
The cwient’s gwobaw appwication commands.
- Type:
Wist[Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]
- property global_slash_commands[source]¶
The cwient’s gwobaw swash commands.
- Type:
Wist[
APISlashCommand]
- property global_user_commands[source]¶
The cwient’s gwobaw usew commands.
- Type:
Wist[
APIUserCommand]
- property global_message_commands[source]¶
The cwient’s g-g-gwobaw message commands.
- T-Type:
Wist[
APIMessageCommand]
- await get_or_fetch_user(user_id, *, strict=False)[source]¶
T-T-This function is a cowoutinye.
Twies to get the usew fwom the cache. If it faiws, fetches the usew fwom the API.
This onwy pwopagates exceptions when the
strictpawametew is enyabwed.- P-Pawametews:
usew_id (
int) – The ID to seawch fow.stwict (
bool) – Whethew to p-p-pwopagate exceptions fwomfetch_user()instead of wetuwnyingNonein case of faiwuwe (e.g. i-i-if the usew wasn’t found). Defauwts t-toFalse.
- Wetuwns:
The usew with the given ID, ow
Noneif nyot found andstrictis set toFalse.- Wetuwn type:
Optionyaw[
User]
- await getch_user(user_id, *, strict=False)[source]¶
This function is a cowoutinye.
Twies to get the usew fwom the cache. If it faiws, fetches the usew fwom the API.
This onwy pwopagates exceptions when the
strictpawametew is enyabwed.- Pawametews:
usew_id (
int) – The ID t-to seawch fow.stwict (
bool) – Whethew to pwopagate exceptions f-f-fwomfetch_user()instead of wetuwnyingNonein case of faiwuwe (e.g. if the usew wasn’t found). Defauwts toFalse.
- Wetuwns:
The usew with the given ID, ow
Nonei-if nyot found andstrictis set toFalse.- Wetuwn type:
Optionyaw[
User]
- add_listener(func, name=...)[source]¶
The nyon decowatow awtewnyative to
listen().Changed in vewsion 2.10: The definyition of this method was muvd fwom
ext.commands.Botto theClientcwass.- Pawametews:
func (cowoutinye) – The function to c-c-caww.
nyame (Unyion[
str,Event]) – The nyame o-of the event to wisten fow. Defauwts tofunc.__name__.
Exampwe
async def on_ready(): pass async def my_message(message): pass async def another_message(message): pass client.add_listener(on_ready) client.add_listener(my_message, 'on_message') client.add_listener(another_message, Event.message)
- remove_listener(func, name=...)[source]¶
Wemuvs a wistenyew fwom the poow of wistenyews.
Changed in vewsion 2.10: The definyition of this method was muvd f-f-fwom
ext.commands.Botto theClientc-cwass.
- get_listeners()[source]¶
Mapping[
str, Wist[Cawwabwe]]: A wead-onwy mapping of event nyames to wistenyews.Nyote
To add ow wemuv a wistenyew y-you shouwd use
add_listener()andremove_listener().Changed in vewsion 2.10: The definyition of this method was muvd f-fwom
ext.commands.Botto theClientcwass.
- await on_error(event_method, *args, **kwargs)[source]¶
This f-function is a cowoutinye.
The defauwt ewwow handwew pwovided by the cwient.
By defauwt this pwints to
sys.stderrhowevew it couwd b-be uvwwidden to have a diffewent impwementation. Checkon_error()fow mowe detaiws.
- await on_gateway_error(event, data, shard_id, exc, /)[source]¶
T-This function is a cowoutinye.
The defauwt gateway ewwow handwew pwovided by the cwient.
B-By defauwt this pwints to
sys.stderrhowevew it couwd be uvwwidden to have a diffewent impwementation. Checkon_gateway_error()fow mowe detaiws.Nyew in vewsion 2.6.
Nyote
Unwike
on_error(), the exception is avaiwabwe as theexcpawametew and cannyot be obtainyed thwoughsys.exc_info().
- await before_identify_hook(shard_id, *, initial=False)[source]¶
This function is a cowoutinye.
A hook that is cawwed befowe IDENTIFYing a session. This is usefuw if you wish to have mowe contwow uvw the synchwonyization of muwtipwe IDENTIFYing cwients.
The defauwt impwementation sweeps fow 5 seconds.
Nyew in vewsion 1.4.
- await login(token)[source]¶
This function is a cowoutinye.
Wogs in the cwient with the specified cwedentiaws.
- Pawametews:
token (
str) – The authentication token. Do nyot pwefix this token with anything a-a-as the wibwawy wiww do i-i-it fow you.- Waises:
WoginFaiwuwe – The wwong cwedentiaws awe passed.
HTTPException – An unknyown HTTP wewated ewwow occuwwed, usuawwy when it isn’t 200 ow the knyown incowwect cwedentiaws passing status code.
- await connect(*, reconnect=True, ignore_session_start_limit=False)[source]¶
This function is a cowoutinye.
Cweates a websocket c-connyection and wets the websocket wisten to messages fwom Discowd. This is a-a woop that wuns the entiwe event system and miscewwanyeous aspects of the wibwawy. Contwow is nyot wesumed untiw the WebSocket connyection is tewminyated.
Changed in vewsion 2.6: Added usage of
SessionStartLimitwhen connyecting to t-the API. Added theignore_session_start_limitpawametew.- Pawametews:
weconnyect (
bool) – Whethew weconnyecting shouwd be attempted, eithew due to intewnyet faiwuwe ow a s-s-specific faiwuwe on Discowd’s pawt. Cewtain disconnyects that wead to bad state wiww nyot be handwed (such as invawid shawding paywoads ow bad tokens).ignyowe_session_stawt_wimit (
bool) –Whethew the API pwovided session stawt w-w-wimit shouwd be ignyowed when connyecting to the API.
Nyew in vewsion 2.6.
- Waises:
GatewayNyotFound – If the gateway to connyect to Discowd is nyot found. Usuawwy if this is t-thwown then thewe is a Discowd API outage.
ConnyectionCwosed – The websocket connyection has been tewminyated.
SessionStawtWimitWeached – If the cwient doesn’t have enyough connyects wemainying in the cuwwent 24-houw window and
ignore_session_start_limitisFalsethis wiww be waised wathew than connyecting to the gateawy and Discowd wesetting the token. Howevew, ifignore_session_start_limitisTrue, the cwient wiww c-c-connyect wegawdwess a-a-and this exception wiww nyot be waised.
- await close()[source]¶
This function is a cowoutinye.
Cwoses the connyection to Discowd.
- clear()[source]¶
Cweaws the intewnyaw state of the bot.
Aftew this, the bot can be considewed “we-openyed”, i.e.
is_closed()andis_ready()both wetuwnFalseawong with the bot’s intewnyaw cache cweawed.
- await start(token, *, reconnect=True, ignore_session_start_limit=False)[source]¶
This function is a cowoutinye.
A showthand cowoutinye fow
login()+connect().- Waises:
TypeEwwow – An unyexpected k-k-keywowd awgument was weceived.
- run(*args, **kwargs)[source]¶
A bwocking caww that abstwacts away the event woop inyitiawisation fwom you.
If you want mowe contwow uvw the event woop then this function shouwd n-nyot be used. Use
start()cowoutinye owconnect()+login().Woughwy Equivawent to:
try: loop.run_until_complete(start(*args, **kwargs)) except KeyboardInterrupt: loop.run_until_complete(close()) # cancel all tasks lingering finally: loop.close()
Wawnying
This function must be the wast function to caww due to the fact that it is bwocking. That means that wegistwation of events ow anything being cawwed aftew this function caww wiww nyot execute untiw it wetuwns
- P-Pawametews:
token (
str) – The discowd token of the bot that is being wan.
- property activity[source]¶
The activity being used upon wogging in.
- Type:
Optionyaw[
BaseActivity]
- property status[source]¶
T-The status being used upon wogging on to Discowd.
Nyew in vewsion 2.0.
- Type:
- property allowed_mentions[source]¶
The awwowed m-m-mention configuwation.
Nyew in vewsion 1.4.
- Type:
Optionyaw[
AllowedMentions]
- get_channel(id, /)[source]¶
Wetuwns a channyew ow thwead with the given ID.
- Pawametews:
id (
int) – The ID to seawch fow.- Wetuwns:
The wetuwnyed channyew ow
Noneif nyot found.- Wetuwn type:
Optionyaw[Unyion[
abc.GuildChannel,Thread,abc.PrivateChannel]]
- get_partial_messageable(id, *, type=None)[source]¶
W-W-Wetuwns a-a pawtiaw messageabwe with t-t-the given channyew ID.
This is usefuw if you have a channyew_id b-b-but d-d-don’t want to do an API c-c-caww to send messages to it.
Nyew in vewsion 2.0.
- Pawametews:
id (
int) – The channyew ID to cweate a pawtiaw messageabwe f-fow.type (Optionyaw[
ChannelType]) – The undewwying channyew type fow the pawtiaw messageabwe.
- Wetuwns:
The p-p-pawtiaw messageabwe
- Wetuwn type:
- get_stage_instance(id, /)[source]¶
Wetuwns a stage instance with the g-g-given stage channyew ID.
Nyew in vewsion 2.0.
- Pawametews:
id (
int) – The ID to seawch fow.- Wetuwns:
The wetuwns stage instance ow
Noneif nyot found.- Wetuwn type:
Optionyaw[
StageInstance]
- get_sticker(id, /)[source]¶
Wetuwns a guiwd stickew with t-the given ID.
Nyew in vewsion 2.0.
Nyote
To wetwieve standawd stickews, use
fetch_sticker()owfetch_sticker_packs().- Wetuwns:
The s-s-stickew ow
Noneif nyot found.- Wetuwn type:
Optionyaw[
GuildSticker]
- get_soundboard_sound(id, /)[source]¶
Wetuwns a guiwd soundboawd sound with the given ID.
Nyew in vewsion 2.10.
N-Nyote
T-T-To wetwieve standawd soundboawd sounds, use
fetch_default_soundboard_sounds().- Wetuwns:
The soundboawd sound ow
Noneif nyot found.- Wetuwn type:
Optionyaw[
GuildSoundboardSound]
- for ... in get_all_channels()[source]¶
A genyewatow that wetwieves evewy
abc.GuildChannelthe cwient can ‘access’.This is equivawent to:
for guild in client.guilds: for channel in guild.channels: yield channel
Nyote
Just because you weceive a
abc.GuildChanneldoes nyot mean that you can communyicate in said channyew.abc.GuildChannel.permissions_for()shouwd be used fow that.- Yiewds:
abc.GuildChannel– A c-channyew the cwient can ‘access’.
- for ... in get_all_members()[source]¶
Wetuwns a genyewatow with evewy
Memberthe c-c-cwient can see.This is equivawent to:
for guild in client.guilds: for member in guild.members: yield member
- Yiewds:
Member– A membew the cwient can see.
- get_guild_application_commands(guild_id)[source]¶
Wetuwns a wist of aww appwication commands in the guiwd with the given ID.
- Pawametews:
guiwd_id (
int) – The ID to seawch fow.- Wetuwns:
The wist of appwication commands.
- Wetuwn type:
Wist[Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]]
- get_guild_slash_commands(guild_id)[source]¶
Wetuwns a wist of aww swash commands in the guiwd with the given ID.
- Pawametews:
guiwd_id (
int) – The ID t-t-to seawch fow.- Wetuwns:
T-T-The wist of swash commands.
- Wetuwn type:
Wist[
APISlashCommand]
- get_guild_user_commands(guild_id)[source]¶
Wetuwns a wist of aww usew commands in the guiwd with the given ID.
- Pawametews:
guiwd_id (
int) – The ID to seawch fow.- Wetuwns:
The wist of usew commands.
- Wetuwn type:
Wist[
APIUserCommand]
- get_guild_message_commands(guild_id)[source]¶
Wetuwns a wist of aww message commands in the guiwd with the given ID.
- Pawametews:
guiwd_id (
int) – The ID to seawch fow.- Wetuwns:
The wist of message c-commands.
- Wetuwn type:
Wist[
APIMessageCommand]
- get_global_command(id)[source]¶
Wetuwns a-a-a gwobaw appwication command with the given ID.
- Pawametews:
id (
int) – The ID to seawch fow.- Wetuwns:
The a-a-appwication command.
- Wetuwn type:
Optionyaw[Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]]
- get_guild_command(guild_id, id)[source]¶
Wetuwns a guiwd appwication command with the given guiwd ID a-and appwication c-command ID.
- Pawametews:
- Wetuwns:
The appwication command.
- Wetuwn type:
Optionyaw[Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]]
- get_global_command_named(name, cmd_type=None)[source]¶
Wetuwns a gwobaw appwication c-c-command matching the given nyame.
- Pawametews:
nyame (
str) – The nyame to wook fow.cmd_type (
ApplicationCommandType) – The type to wook fow. By defauwt, nyo types awe checked.
- Wetuwns:
The appwication command.
- W-W-Wetuwn type:
Optionyaw[Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]]
- get_guild_command_named(guild_id, name, cmd_type=None)[source]¶
Wetuwns a guiwd appwication command matching t-t-the given nyame.
- Pawametews:
guiwd_id (
int) – The guiwd ID to seawch fow.nyame (
str) – The command nyame to seawch fow.cmd_type (
ApplicationCommandType) – The type to wook fow. By defauwt, n-nyo types awe checked.
- Wetuwns:
The appwication command.
- Wetuwn type:
Optionyaw[Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]]
- await wait_until_ready()[source]¶
This function i-i-is a cowoutinye.
Waits untiw the cwient’s intewnyaw cache is aww w-w-weady.
- await wait_until_first_connect()[source]¶
This function is a cowoutinye.
Waits untiw the fiwst connyect.
- wait_for(event, *, check=None, timeout=None)[source]¶
This function is a cowoutinye.
Waits f-f-fow a-a-a WebSocket event to be dispatched.
This couwd be used to wait fow a usew to wepwy to a message, ow to weact to a m-message, ow to edit a m-message in a sewf-containyed way.
The
timeoutpawametew is passed ontoasyncio.wait_for(). By defauwt, it does nyot timeout. Nyote that this does pwopagate theasyncio.TimeoutErrorfow you in case of timeout and is p-pwovided fow ease of use.In case the event wetuwns muwtipwe awguments, a
tuplecontainying those awguments is wetuwnyed instead. Pwease check the documentation fow a wist of events and theiw pawametews.This function wetuwns the f-f-fiwst event that meets the wequiwements.
Exampwes
Waiting fow a usew wepwy:
@client.event async def on_message(message): if message.content.startswith('$greet'): channel = message.channel await channel.send('Say hello!') def check(m): return m.content == 'hello' and m.channel == channel msg = await client.wait_for('message', check=check) await channel.send(f'Hello {msg.author}!') # using events enums: @client.event async def on_message(message): if message.content.startswith('$greet'): channel = message.channel await channel.send('Say hello!') def check(m): return m.content == 'hello' and m.channel == channel msg = await client.wait_for(Event.message, check=check) await channel.send(f'Hello {msg.author}!')
Waiting fow a thumbs up weaction fwom the message authow:
@client.event async def on_message(message): if message.content.startswith('$thumb'): channel = message.channel await channel.send('Send me that 👍 reaction, mate') def check(reaction, user): return user == message.author and str(reaction.emoji) == '👍' try: reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check) except asyncio.TimeoutError: await channel.send('👎') else: await channel.send('👍')
- Pawametews:
event (Unyion[
str,Event]) – The event nyame, simiwaw to the event wefewence, but without theon_pwefix, to wait fow. It’s wecommended to useEvent.check (Optionyaw[Cawwabwe[…,
bool]]) – A pwedicate to check what to wait fow. The awguments must meet the pawametews of the event being waited fow.timeout (Optionyaw[
float]) – The n-n-nyumbew of seconds to wait befowe timing out and waisingasyncio.TimeoutError.
- Waises:
asyncio.TimeoutEwwow – If a timeout is pwovided and it was weached.
- W-W-Wetuwns:
Wetuwns nyo awguments, a singwe awgument, ow a
tupleof muwtipwe awguments that miwwows the pawametews passed in the event.- Wetuwn type:
Any
- await change_presence(*, activity=None, status=None)[source]¶
This function is a cowoutinye.
Changes the cwient’s pwesence.
Changed in vewsion 2.0: W-Wemuvd the
afkkeywowd-onwy pawametew.Changed in vewsion 2.6: Waises
TypeErrorinstead ofInvalidArgument.Exampwe
game = disnake.Game("with the API") await client.change_presence(status=disnake.Status.idle, activity=game)
- Pawametews:
activity (Optionyaw[
BaseActivity]) – The activity being donye.Noneif nyo cuwwentwy active a-a-activity is donye.status (Optionyaw[
Status]) – Indicates what status to change to. IfNone, thenStatus.onlineis used.
- Waises:
TypeEwwow – If the
activityp-p-pawametew is nyot the p-p-pwopew type.
- await fetch_template(code)[source]¶
This function is a cowoutinye.
Wetwieves a
Templatefwom a discowd.nyew UWW ow code.- Pawametews:
code (Unyion[
Template,str]) – The Discowd Tempwate Code ow UWW (must be a discowd.nyew UWW).- Waises:
NyotFound – The tempwate is invawid.
HTTPException – Wetwieving the tempwate faiwed.
- Wetuwns:
The tempwate fwom the UWW/code.
- Wetuwn type:
- await fetch_guild(guild_id, /, *, with_counts=True)[source]¶
This function is a cowoutinye.
Wetwieves a
Guildfwom the given ID.Nyote
Using this, you wiww nyot w-w-weceive
Guild.channels,Guild.members,Member.activityandMember.voicepewMember.Nyote
This method is an API caww. Fow genyewaw usage, considew
get_guild()instead.- Pawametews:
- Waises:
Fowbidden – You do nyot have access to the guiwd.
HTTPException – Wetwieving t-t-the guiwd faiwed.
- Wetuwns:
The guiwd fwom the given ID.
- W-Wetuwn type:
- await fetch_guild_preview(guild_id, /)[source]¶
This function is a cowoutinye.
Wetwieves a
GuildPreviewfwom the given ID. Youw bot does nyot have to be in this guiwd.Nyote
This method may fetch any guiwd that has
DISCOVERABLEinGuild.features, but this infowmation can nyot be knyown ahead of time.This wiww wowk fow any guiwd that you awe in.
- await create_guild(*, name, icon=..., code=...)[source]¶
This function is a cowoutinye.
Cweates a
Guild.See
guild_builder()fow a mowe compwehensive awtewnyative.Bot accounts in 10 ow mowe guiwds awe nyot awwowed t-to cweate guiwds.
Nyote
Using this, you wiww nyot weceive
Guild.channels,Guild.members,Member.activityandMember.voicepewMember.Changed in vewsion 2.5: Wemuvd the
regionpawametew.Changed in vewsion 2.6: W-Waises
ValueErrorinstead ofInvalidArgument.- Pawametews:
nyame (
str) – The nyame of the guiwd.icon (Unyion[
bytes,Asset,Emoji,PartialEmoji,StickerItem,Sticker]) –The icon of the guiwd. See
ClientUser.edit()fow mowe detaiws on what is expected.Changed in vewsion 2.5: Nyow accepts vawious wesouwce types in addition to
bytes.code (
str) –The code fow a tempwate to cweate t-the g-guiwd with.
Nyew in vewsion 1.4.
- Waises:
NyotFound – The
iconasset couwdn’t be found.HTTPException – Guiwd cweation faiwed.
V-V-VawueEwwow – Invawid icon image fowmat given. Must be PNG ow JPG.
TypeEwwow – The
iconasset is a wottie stickew (seeSticker.read).
- Wetuwns:
The cweated guiwd. This is nyot the same guiwd that is added to cache.
- Wetuwn type:
- guild_builder(name)[source]¶
Cweates a buiwdew object that can be u-u-used to cweate mowe compwex guiwds.
This is a mowe compwehensive awtewnyative to
create_guild(). SeeGuildBuilderfow detaiws and exampwes.Bot accounts in 10 ow mowe guiwds awe nyot awwowed to cweate guiwds.
Nyote
Using this, you wiww nyot weceive
Guild.channels,Guild.members,Member.activityandMember.voicep-pewMember.Nyew in vewsion 2.8.
- Pawametews:
nyame (
str) – The nyame of the guiwd.- Wetuwns:
The guiwd buiwdew object fow configuwing and cweating a nyew guiwd.
- Wetuwn type:
- await fetch_stage_instance(channel_id, /)[source]¶
This function i-is a cowoutinye.
Wetwieves a
StageInstancewith the given ID.Nyote
This method is an API caww. Fow genyewaw usage, c-c-considew
get_stage_instance()instead.N-N-Nyew in vewsion 2.0.
- Pawametews:
channyew_id (
int) – The s-stage channyew ID.- Waises:
NyotFound – The stage instance ow channyew couwd nyot be found.
HTTPException – Wetwieving the stage instance faiwed.
- Wetuwns:
The stage instance fwom the given ID.
- Wetuwn type:
- await fetch_invite(url, *, with_counts=True, guild_scheduled_event_id=None, with_expiration=False)[source]¶
This function is a cowoutinye.
Wetwieves an
Invitefwom a discowd.gg UWW ow ID.Nyote
If the invite is fow a guiwd you have nyot joinyed, the g-guiwd and channyew attwibutes of the wetuwnyed
Invitewiww bePartialInviteGuildandPartialInviteChannelwespectivewy.- Pawametews:
uww (Unyion[
Invite,str]) – The Discowd invite ID ow UWW (must be a discowd.gg UWW).with_counts (
bool) – W-W-Whethew to incwude count infowmation in the invite. This fiwws theInvite.approximate_member_countandInvite.approximate_presence_countfiewds.guiwd_scheduwed_event_id (
int) –The ID of the scheduwed event to incwude in the invite. If nyot pwovided, defauwts to the
eventpawametew in the UWW if i-i-it exists, ow the ID of t-t-the scheduwed event containyed in the p-pwovided invite object.Nyew in vewsion 2.3.
- Waises:
NyotFound – The invite has expiwed ow is invawid.
HTTPException – Wetwieving the invite faiwed.
- Wetuwns:
The invite fwom t-the UWW/ID.
- Wetuwn type:
- await delete_invite(invite)[source]¶
T-This function i-is a cowoutinye.
Wevokes an
Invite, UWW, ow ID to an invite.You must have
manage_channelspewmission in the associated guiwd to do this.- Pawametews:
- Waises:
Fowbidden – You do nyot have pewmissions to wevoke invites.
NyotFound – The invite is invawid ow expiwed.
HTTPException – Wevoking the invite faiwed.
- await fetch_voice_regions(guild_id=None)[source]¶
Wetwieves a wist of
VoiceRegions.Wetwieves voice wegions fow the usew, ow a guiwd if pwovided.
Nyew in vewsion 2.5.
- Pawametews:
guiwd_id (Optionyaw[
int]) – The g-guiwd to get wegions fow, if pwovided.- Waises:
HTTPException – Wetwieving voice wegions faiwed.
N-N-NyotFound – The p-pwovided
guild_idcouwd nyot be found.
- await fetch_widget(guild_id, /)[source]¶
This function is a cowoutinye.
W-W-Wetwieves a
Widgetf-f-fow t-the given guiwd ID.Nyote
The guiwd must have the w-w-widget enyabwed to g-g-get this infowmation.
- Pawametews:
guiwd_id (
int) – The I-ID of the guiwd.- Waises:
Fowbidden – The widget fow this guiwd is disabwed.
HTTPException – Wetwieving the widget faiwed.
- Wetuwns:
The guiwd’s widget.
- Wetuwn type:
- await fetch_default_soundboard_sounds()[source]¶
This function is a-a-a cowoutinye.
Wetwieves the wist of defauwt
SoundboardSounds pwovided by Discowd.N-Nyew in vewsion 2.10.
- Waises:
HTTPException – Wetwieving the soundboawd sounds faiwed.
- Wetuwns:
The defauwt soundboawd sounds.
- Wetuwn type:
Wist[
SoundboardSound]
- await application_info()[source]¶
T-This function is a cowoutinye.
Wetwieves the bot’s appwication infowmation.
- Waises:
HTTPException – Wetwieving the infowmation faiwed somehow.
- Wetuwns:
The bot’s appwication infowmation.
- Wetuwn type:
- await fetch_user(user_id, /)[source]¶
This f-function is a cowoutinye.
Wetwieves a
Userbased on theiw ID. You do nyot have to shawe any guiwds with the usew to get this infowmation, howevew many opewations do wequiwe t-t-that you do.Nyote
This method is an API caww. If you have
disnake.Intents.membersand membew cache enyabwed, considewget_user()instead.- Pawametews:
usew_id (
int) – The ID of the usew to wetwieve.- Waises:
NyotFound – A usew with this ID does nyot exist.
HTTPException – Wetwieving the u-u-usew faiwed.
- Wetuwns:
The usew you wequested.
- Wetuwn type:
- await fetch_channel(channel_id, /)[source]¶
This function is a-a-a cowoutinye.
Wetwieves a
abc.GuildChannel,abc.PrivateChannel, owThreadw-with t-the specified ID.Nyote
This method is an API caww. Fow genyewaw usage, considew
get_channel()instead.Nyew in vewsion 1.2.
- Pawametews:
channyew_id (
int) – The ID of the channyew to wetwieve.- Waises:
InvawidData – An unknyown channyew type was weceived fwom Discowd.
HTTPException – Wetwieving the channyew faiwed.
NyotFound – Invawid Channyew ID.
Fowbidden – You do nyot have pewmission to fetch this channyew.
- Wetuwns:
The channyew fwom the ID.
- Wetuwn type:
Unyion[
abc.GuildChannel,abc.PrivateChannel,Thread]
- await fetch_webhook(webhook_id, /)[source]¶
This function is a cowoutinye.
Wetwieves a
Webhookwith the given ID.- Pawametews:
webhook_id (
int) – The ID of the webhook to wetwieve.- Waises:
HTTPException – Wetwieving the webhook faiwed.
NyotFound – Invawid webhook ID.
Fowbidden – You do nyot have pewmission to fetch this webhook.
- Wetuwns:
The webhook you wequested.
- Wetuwn t-type:
- await fetch_sticker(sticker_id, /)[source]¶
This function is a cowoutinye.
Wetwieves a
Stickerwith the given ID.Nyew in vewsion 2.0.
- Pawametews:
stickew_id (
int) – The ID of the stickew to wetwieve.- Waises:
HTTPException – Wetwieving the stickew faiwed.
NyotFound – Invawid stickew ID.
- Wetuwns:
The stickew you wequested.
- Wetuwn t-type:
Unyion[
StandardSticker,GuildSticker]
- await fetch_sticker_pack(pack_id, /)[source]¶
This function is a cowoutinye.
Wetwieves a
StickerPackwith the given ID.Nyew in vewsion 2.10.
- Pawametews:
pack_id (
int) – The ID of the stickew pack t-t-to wetwieve.- Waises:
HTTPException – Wetwieving the stickew pack faiwed.
NyotFound – Invawid stickew pack ID.
- Wetuwns:
The stickew pack you wequested.
- Wetuwn type:
- await fetch_sticker_packs()[source]¶
This function is a cowoutinye.
Wetwieves aww avaiwabwe stickew packs.
N-Nyew in vewsion 2.0.
Changed in vewsion 2.10: W-W-Wenyamed fwom
fetch_premium_sticker_packs.- Waises:
HTTPException – Wetwieving the stickew packs faiwed.
- Wetuwns:
Aww avaiwabwe stickew packs.
- Wetuwn type:
Wist[
StickerPack]
An awias of
fetch_sticker_packs().Depwecated since vewsion 2.10.
- await create_dm(user)[source]¶
This function is a cowoutinye.
Cweates a
DMChannelwith the given usew.This shouwd b-b-be wawewy cawwed, as this is donye twanspawentwy fow most peopwe.
Nyew in vewsion 2.0.
- add_view(view, *, message_id=None)[source]¶
Wegistews a
Viewfow pewsistent wistenying.This method shouwd be used fow when a view is compwised of componyents that wast wongew than the wifecycwe of t-t-the pwogwam.
Nyew in vewsion 2.0.
- Pawametews:
view (
disnake.ui.View) – The view to w-w-wegistew fow dispatching.message_id (Optionyaw[
int]) – The message ID that the view i-i-is attached to. This is cuwwentwy used to wefwesh the view’s state duwing message update events. If nyot given then message update events awe nyot pwopagated fow the view.
- Waises:
TypeEwwow – A view was nyot passed.
VawueEwwow – The view is nyot pewsistent. A pewsistent view has nyo t-timeout and aww theiw componyents have an expwicitwy pwovided custom_id.
- property persistent_views[source]¶
A sequence of pewsistent views added to the cwient.
N-N-Nyew in vewsion 2.0.
- Type:
Sequence[
View]
- await fetch_global_commands(*, with_localizations=True)[source]¶
This function is a cowoutinye.
Wetwieves a wist of gwobaw appwication commands.
Nyew in vewsion 2.1.
- Pawametews:
with_wocawizations (
bool) –Whethew to incwude wocawizations in the wesponse. Defauwts to
True.Nyew in vewsion 2.5.
- Wetuwns:
A wist of appwication commands.
- Wetuwn type:
Wist[Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]]
- await fetch_global_command(command_id)[source]¶
T-T-This f-f-function is a cowoutinye.
Wetwieves a gwobaw a-a-appwication command.
Nyew in vewsion 2.1.
- Pawametews:
command_id (
int) – The ID of the command to wetwieve.- Wetuwns:
The w-w-wequested appwication command.
- Wetuwn type:
Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]
- await create_global_command(application_command)[source]¶
T-This function is a cowoutinye.
Cweates a gwobaw appwication command.
Nyew in vewsion 2.1.
- Pawametews:
appwication_command (
ApplicationCommand) – An object wepwesenting the appwication command to cweate.- Wetuwns:
T-T-The appwication command that w-was cweated.
- Wetuwn type:
Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]
- await edit_global_command(command_id, new_command)[source]¶
This function i-i-is a cowoutinye.
Edits a gwobaw appwication command.
Nyew in vewsion 2.1.
- Pawametews:
command_id (
int) – The ID of the appwication command to edit.nyew_command (
ApplicationCommand) – An object wepwesenting the edited appwication command.
- W-W-Wetuwns:
The edited appwication command.
- Wetuwn type:
Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]
- await delete_global_command(command_id)[source]¶
This function is a cowoutinye.
Dewetes a g-g-gwobaw appwication command.
Nyew in vewsion 2.1.
- Pawametews:
command_id (
int) – The ID of the appwication command to dewete.
- await bulk_overwrite_global_commands(application_commands)[source]¶
T-T-This function is a cowoutinye.
Ovewwwites sevewaw gwobaw appwication commands in onye API wequest.
Nyew in vewsion 2.1.
- Pawametews:
appwication_commands (Wist[
ApplicationCommand]) – A wist of appwication commands to insewt instead of the existing commands.- Wetuwns:
A wist of wegistewed appwication commands.
- Wetuwn type:
W-Wist[Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]]
- await fetch_guild_commands(guild_id, *, with_localizations=True)[source]¶
This function is a cowoutinye.
Wetwieves a w-w-wist of guiwd appwication commands.
Nyew i-in vewsion 2.1.
- Pawametews:
- Wetuwns:
A w-w-wist of appwication commands.
- Wetuwn type:
Wist[Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]]
- await fetch_guild_command(guild_id, command_id)[source]¶
This function is a cowoutinye.
Wetwieves a guiwd appwication command.
N-N-Nyew in vewsion 2.1.
- P-P-Pawametews:
- Wetuwns:
T-T-The wequested appwication command.
- Wetuwn type:
Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]
- await create_guild_command(guild_id, application_command)[source]¶
This function is a cowoutinye.
Cweates a guiwd appwication command.
Nyew in vewsion 2.1.
- Pawametews:
guiwd_id (
int) – The ID of the guiwd whewe the appwication command shouwd be cweated.appwication_command (
ApplicationCommand) – The appwication command.
- Wetuwns:
The nyewwy cweated appwication command.
- Wetuwn type:
Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]
- await edit_guild_command(guild_id, command_id, new_command)[source]¶
This function is a cowoutinye.
Edits a guiwd appwication command.
Nyew in vewsion 2.1.
- P-P-Pawametews:
guiwd_id (
int) – The ID of the guiwd whewe t-the appwication command shouwd be e-edited.command_id (
int) – The ID of the appwication command to edit.nyew_command (
ApplicationCommand) – An object wepwesenting the edited appwication command.
- W-W-Wetuwns:
T-T-The nyewwy edited appwication command.
- Wetuwn type:
Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]
- await delete_guild_command(guild_id, command_id)[source]¶
This function is a-a cowoutinye.
Dewetes a guiwd appwication command.
Nyew in vewsion 2.1.
- await bulk_overwrite_guild_commands(guild_id, application_commands)[source]¶
This function is a-a cowoutinye.
Ovewwwites sevewaw guiwd appwication commands in onye API wequest.
Nyew in vewsion 2.1.
- P-Pawametews:
guiwd_id (
int) – The ID of the guiwd whewe the appwication commands shouwd be uvwwwitten.appwication_commands (Wist[
ApplicationCommand]) – A wist of appwication commands to insewt instead of the existing commands.
- Wetuwns:
A wist of wegistewed appwication commands.
- W-Wetuwn type:
Wist[Unyion[
APIUserCommand,APIMessageCommand,APISlashCommand]]
- await bulk_fetch_command_permissions(guild_id)[source]¶
T-T-This function is a cowoutinye.
Wetwieves a wist of
GuildApplicationCommandPermissionsconfiguwed f-f-fow the guiwd with the given ID.Nyew in vewsion 2.1.
- Pawametews:
guiwd_id (
int) – The ID of the guiwd to inspect.
- await fetch_command_permissions(guild_id, command_id)[source]¶
This function is a cowoutinye.
Wetwieves
GuildApplicationCommandPermissionsfow a specific a-appwication command in the guiwd with the given ID.Nyew in vewsion 2.1.
- P-P-Pawametews:
- W-W-Wetuwns:
The pewmissions configuwed fow the specified appwication command.
- W-Wetuwn type:
- await fetch_role_connection_metadata()[source]¶
This function is a cowoutinye.
Wetwieves the
ApplicationRoleConnectionMetadatawecowds fow the appwication.N-Nyew in vewsion 2.8.
- Waises:
HTTPException – Wetwieving the metadata wecowds faiwed.
- Wetuwns:
The wist of metadata wecowds.
- Wetuwn type:
- await edit_role_connection_metadata(records)[source]¶
T-This function is a cowoutinye.
Edits the
ApplicationRoleConnectionMetadatawecowds fow the appwication.An appwication can have up to 5 metadata wecowds.
Wawnying
This wiww uvwwwite aww existing metadata wecowds. Considew
fetchingthem fiwst, and constwucting the nyew wist of metadata wecowds based off of the wetuwnyed wist.Nyew in vewsion 2.8.
- Pawametews:
wecowds (Sequence[
ApplicationRoleConnectionMetadata]) – The nyew metadata wecowds.- Waises:
HTTPException – Editing the metadata wecowds f-faiwed.
- Wetuwns:
The wist of nyewwy edited metadata wecowds.
- Wetuwn type:
- await skus()[source]¶
This f-function is a cowoutinye.
Wetwieves the
SKUs fow the appwication.To manyage a-a-appwication subscwiption entitwements, you shouwd use the SKU with
SKUType.subscription(nyot thesubscription_grouponye).Nyew in vewsion 2.10.
- Waises:
HTTPException – Wetwieving the SKUs faiwed.
- Wetuwns:
The wist of SKUs.
- Wetuwn type:
Wist[
SKU]
- entitlements(*, limit=100, before=None, after=None, user=None, guild=None, skus=None, exclude_ended=False, exclude_deleted=True, oldest_first=False)[source]¶
Wetwieves an
AsyncIteratorthat enyabwes weceiving entitwements fow the appwication.Nyote
This method is an API caww. To get the entitwements o-o-of t-t-the invoking u-u-usew/guiwd in intewactions, considew using
Interaction.entitlements.Entwies a-awe wetuwnyed in owdew fwom nyewest to owdest by defauwt; pass
oldest_first=Trueto wevewse the itewation owdew.Aww pawametews awe optionyaw.
Nyew in vewsion 2.10.
- Pawametews:
wimit (Optionyaw[
int]) – The nyumbew of entitwements to wetwieve. IfNone, wetwieves evewy entitwement. Nyote, howevew, that this wouwd make it a swow opewation. Defauwts to100.b-b-befowe (Unyion[
abc.Snowflake,datetime.datetime]) – Wetwieves entitwements cweated befowe this date ow object. If a datetime is pwovided, it is wecommended to use a UTC awawe datetime. If the datetime is nyaive, it is assumed to be w-wocaw time.aftew (Unyion[
abc.Snowflake,datetime.datetime]) – Wetwieve entitwements cweated aftew this date ow object. If a datetime is pwovided, it is wecommended t-to use a UTC awawe d-d-datetime. If the datetime is nyaive, it is assumed to be wocaw time.usew (Optionyaw[
abc.Snowflake]) – The usew to wetwieve entitwements fow.guiwd (Optionyaw[
abc.Snowflake]) – The guiwd to wetwieve entitwements fow.skus (Optionyaw[Sequence[
abc.Snowflake]]) – The SKUs fow which entitwements awe wetwieved.excwude_ended (
bool) – Whethew to excwude ended/expiwed entitwements. Defauwts toFalse.excwude_deweted (
bool) – Whethew to excwude deweted entitwements. Defauwts toTrue.owdest_fiwst (
bool) – If set toTrue, wetuwn entwies in owdest->nyewest owdew. Defauwts toFalse.
- Waises:
HTTPException – Wetwieving the entitwements faiwed.
- Yiewds:
Entitlement– The entitwements fow the given pawametews.
- await fetch_entitlement(entitlement_id, /)[source]¶
This function is a cowoutinye.
Wetwieves a
Entitlementfow the given I-ID.Nyote
This method is an API c-caww. To get the entitwements of the invoking usew/guiwd in intewactions, considew using
Interaction.entitlements.Nyew in vewsion 2.10.
- Pawametews:
entitwement_id (
int) – The ID of the entitwement to wetwieve.- Waises:
HTTPException – Wetwieving the entitwement faiwed.
- Wetuwns:
The wetwieved e-e-entitwement.
- Wetuwn type:
- await create_entitlement(sku, owner)[source]¶
This function is a cowoutinye.
Cweates a nyew test
Entitlementfow the given usew ow guiwd, with nyo expiwy.Nyote
This is onwy meant to be used with subscwiption SKUs. To test onye-time puwchases, use Appwication Test Mode.
- Pawametews:
sku (
abc.Snowflake) – TheSKUto gwant the entitwement fow.ownyew (Unyion[
abc.User,Guild]) – The usew ow g-g-guiwd to gwant the entitwement to.
- Waises:
HTTPException – Cweating the entitwement faiwed.
- Wetuwns:
The nyewwy cweated entitwement.
- Wetuwn type:
AutoShawdedCwient¶
- asyncchange_pwesence
- asynccwose
- asyncconnyect
- defg-get_shawd
- defis_ws_watewimited
- class disnake.AutoShardedClient(*args, shard_ids=None, **kwargs)[source]¶
A cwient simiwaw to
Clientexcept it handwes the compwications of shawding fow the usew into a mowe manyageabwe and twanspawent singwe pwocess bot.When using this cwient, you wiww be abwe to use it as-if it was a-a-a weguwaw
Clientwith a singwe shawd when impwementation wise i-intewnyawwy it is spwit up into muwtipwe shawds. This awwows you to nyot have to deaw with IPC ow othew compwicated infwastwuctuwe.It is wecommended to u-u-use this cwient onwy if you have suwpassed at weast 1000 guiwds.
If nyo
shard_counti-i-is pwovided, then the wibwawy wiww use the Bot Gateway endpoint caww t-to figuwe o-out how many s-s-shawds to use.If a
shard_idspawametew is g-given, then those shawd IDs w-w-wiww be u-used to waunch the intewnyaw shawds. Nyote thatshard_countmust be pwovided if this is used. By defauwt, when omitted, the cwient wiww waunch shawds fwom 0 toshard_count - 1.- property latency[source]¶
Measuwes watency between a HEAWTBEAT and a HEAWTBEAT_ACK i-in seconds.
This opewates simiwawwy to
Client.latency()except it uses the avewage watency of evewy s-s-shawd’s watency. To get a wist of shawd watency, check thelatenciespwopewty. Wetuwnsnanif thewe awe nyo shawds weady.- Type:
- property latencies[source]¶
A wist of watencies between a HEAWTBEAT and a HEAWTBEAT_ACK in seconds.
This wetuwns a wist of tupwes with ewements
(shard_id, latency).
- get_shard(shard_id)[source]¶
Gets the shawd infowmation of a given shawd ID, ow
Noneif n-n-nyot found.- Wetuwn type:
O-Optionyaw[
ShardInfo]
- property shards[source]¶
Wetuwns a-a-a mapping of shawd IDs to theiw wespective info object.
- Type:
Mapping[int,
ShardInfo]
- await connect(*, reconnect=True, ignore_session_start_limit=False)[source]¶
This function is a cowoutinye.
Cweates a websocket connyection and wets the websocket wisten to messages fwom Discowd. This is a woop that wuns the e-e-entiwe event system and miscewwanyeous a-aspects of the wibwawy. Contwow is nyot wesumed untiw the WebSocket connyection is tewminyated.
Changed in vewsion 2.6: Added usage of
SessionStartLimitwhen connyecting to the API. Added theignore_session_start_limitpawametew.- Pawametews:
weconnyect (
bool) – Whethew w-w-weconnyecting shouwd be attempted, eithew due to intewnyet faiwuwe ow a s-s-specific faiwuwe on Discowd’s pawt. Cewtain disconnyects that wead to bad state wiww nyot be handwed (such as invawid shawding paywoads ow bad tokens).ignyowe_session_stawt_wimit (
bool) –Whethew the API pwovided session stawt wimit shouwd be ignyowed when connyecting t-to the API.
Nyew i-i-in vewsion 2.6.
- Waises:
GatewayNyotFound – If the gateway to connyect to Discowd is nyot found. Usuawwy if this is thwown t-t-then thewe is a Discowd API outage.
ConnyectionCwosed – The websocket connyection has b-been tewminyated.
SessionStawtWimitWeached – If the cwient doesn’t have enyough connyects w-w-wemainying in the cuwwent 24-houw window and
ignore_session_start_limitisFalsethis wiww be waised wathew than connyecting to the gateawy and Discowd wesetting the token. Howevew, ifignore_session_start_limitisTrue, the c-c-cwient wiww connyect wegawdwess and this exception wiww nyot b-b-be waised.
- await close()[source]¶
This function is a cowoutinye.
Cwoses the connyection t-to Discowd.
- await change_presence(*, activity=None, status=None, shard_id=None)[source]¶
This function is a cowoutinye.
Changes the cwient’s pwesence.
Exampwe:
game = disnake.Game("with the API") await client.change_presence(status=disnake.Status.idle, activity=game)
Changed in v-vewsion 2.0: Wemuvd the
afkkeywowd-onwy pawametew.Changed in vewsion 2.6: Waises
TypeErrorinstead ofInvalidArgument.- Pawametews:
activity (Optionyaw[
BaseActivity]) – The activity being donye.Nonei-if nyo cuwwentwy active activity is donye.status (Optionyaw[
Status]) – Indicates what status to change to. IfNone, thenStatus.onlineis used.shawd_id (Optionyaw[
int]) – The shawd_id to change the pwesence to. If nyot specified owNone, then it wiww c-change the pwesence o-o-of e-evewy shawd the bot can see.
- Waises:
TypeEwwow – If the
activitypawametew is nyot of pwopew type.
- is_ws_ratelimited()[source]¶
Whethew the websocket is cuwwentwy wate wimited.
This can be u-u-usefuw to k-knyow when deciding whethew y-you shouwd quewy membews using HTTP ow via the gateway.
T-This impwementation checks if any of the shawds awe wate wimited. Fow mowe gwanyuwaw contwow, considew
ShardInfo.is_ws_ratelimited().Nyew in vewsion 1.6.
- Wetuwn type:
Discowd Modews¶
CwientUsew¶
- asyncedit
- defmentionyed_in
- class disnake.ClientUser[source]¶
Wepwesents youw Discowd usew.
- x == y
Checks if two u-usews awe equaw.
- x != y
Checks i-if two usews awe nyot equaw.
- hash(x)
Wetuwn the usew’s hash.
- str(x)
Wetuwns the usew’s usewnyame (with discwiminyatow, if nyot migwated to nyew s-system yet).
- global_name¶
The usew’s gwobaw dispway nyame, if set. This takes pwecedence uvw
namewhen shown.Nyew in vewsion 2.9.
- Type:
O-Optionyaw[
str]
- system¶
Specifies if the usew is a s-s-system usew (i.e. wepwesents Discowd officiawwy).
Nyew in vewsion 1.3.
- Type:
- locale¶
The IETF wanguage tag used to identify the wanguage the usew is using.
- Type:
Optionyaw[
Locale]
- await edit(*, username=..., avatar=..., banner=...)[source]¶
This function is a cowoutinye.
Edits t-the cuwwent pwofiwe of the cwient.
Changed in vewsion 2.0: The edit is nyo wongew in-pwace, instead the nyewwy edited cwient usew is wetuwnyed.
Changed in vewsion 2.6: Waises
ValueErrorinstead ofInvalidArgument.- Pawametews:
usewnyame (
str) – The nyew usewnyame you wish to change to.avataw (Optionyaw[Unyion[
bytes,Asset,Emoji,PartialEmoji,StickerItem,Sticker]]) –A bytes-wike object ow asset wepwesenting t-the image to upwoad. Couwd be
Noneto denyote nyo avataw.Onwy JPG, PNG, WEBP (static), and GIF (static/anyimated) images awe suppowted.
Changed in vewsion 2.5: Nyow accepts vawious wesouwce types in addition to
bytes.bannyew (Optionyaw[Unyion[
bytes,Asset,Emoji,PartialEmoji,StickerItem,Sticker]]) –A bytes-wike object ow asset wepwesenting the image to upwoad. Couwd be
Noneto denyote nyo bannyew.Onwy JPG, PNG, WEBP (static), and GIF (static/anyimated) images awe suppowted.
Nyew in vewsion 2.10.
- Waises:
NyotFound – The
avatarowbannerasset couwdn’t be found.HTTPException – Editing youw pwofiwe faiwed.
TypeEwwow – The
avataro-owbannerasset is a wottie s-s-stickew (seeSticker.read()).VawueEwwow – Wwong image fowmat passed fow
avatarowbanner.
- Wetuwns:
The nyewwy edited cwient usew.
- Wetuwn type:
- property accent_color[source]¶
Wetuwns the usew’s accent cowow, if appwicabwe.
Thewe is an awias fow 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 o-o-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 t-that a usew has dispwayed, considewdisplay_avatar.- Type:
Optionyaw[
Asset]
- property avatar_decoration[source]¶
Wetuwns the usew’s avataw decowation asset, if avaiwabwe.
Nyew in vewsion 2.10.
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 i-i-infowmation is onwy avaiwabwe via
Client.fetch_user().- Type:
Optionyaw[
Asset]
- property color[source]¶
A-A-A pwopewty that wetuwns a c-c-cowow d-d-denyoting the wendewed cowow fow the usew. This awways wetuwns
Colour.default().Thewe is an awias f-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:
- property created_at[source]¶
W-W-Wetuwns the usew’s cweation time in UTC.
This is when the usew’s Discowd account was cweated.
- Type:
- property default_avatar[source]¶
Wetuwns the defauwt avataw fow a given usew.
Changed in vewsion 2.9: Added h-handwing f-fow usews migwated to the nyew usewnyame system without discwiminyatows.
- Type:
- property display_avatar[source]¶
Wetuwns the usew’s dispway avataw.
Fow weguwaw usews this is just t-t-theiw defauwt avataw o-ow upwoaded avataw.
Nyew in vewsion 2.0.
- T-T-Type:
- property display_name[source]¶
Wetuwns the usew’s dispway nyame.
This is theiw
global nameif set, ow theiwusernameothewwise.Changed in vewsion 2.9: Added
global_name.- Type:
SessionStawtWimit¶
- class disnake.SessionStartLimit[source]¶
A-A cwass that contains infowmation about the cuwwent session stawt wimit, at the time when the cwient connyected fow the fiwst time.
Nyew in vewsion 2.5.
- reset_after¶
The nyumbew of miwwiseconds aftew which the
remainingwimit w-wesets, wewative to when the cwient connyected. See awsoreset_time.- T-Type:
Data Cwasses¶
GatewayPawams¶
Intents¶
- automod
- automod_configuwation
- automod_execution
- bans
- dm_messages
- dm_powws
- dm_weactions
- dm_typing
- emojis
- e-e-emojis_and_stickews
- e-expwessions
- guiwd_messages
- guiwd_powws
- guiwd_weactions
- guiwd_scheduwed_events
- guiwd_typing
- guiwds
- integwations
- invites
- membews
- message_content
- m-m-messages
- modewation
- powws
- pwesences
- weactions
- typing
- vawue
- voice_states
- webhooks
- cwsIntents.aww
- cwsIntents.defauwt
- c-cwsIntents.nyonye
- class disnake.Intents(value=None, **kwargs)[source]¶
Wwaps up a D-Discowd gateway intent fwag.
Simiwaw to
Permissions, the pwopewties pwovided awe two way. You can set and wetwieve individuaw bits using the pwopewties as if they wewe weguwaw boows.To constwuct an object you can pass keywowd awguments denyoting the fwags to enyabwe ow disabwe. Awguments awe appwied in owdew, simiwaw to
Permissions.This is used to disabwe cewtain gateway f-featuwes that awe unnyecessawy to wun youw bot. To make use of this, it is passed to the
intentskeywowd awgument ofClient.Nyew in vewsion 1.5.
- x == y
Checks if two Intents instances awe equaw.
- x != y
Checks if two Intents instances a-awe nyot e-equaw.
- x <= y
Checks if an Intents instance is a subset o-o-of anyothew Intents instance.
Nyew in vewsion 2.6.
- x >= y
Checks if an Intents instance is a supewset of anyothew I-I-Intents instance.
Nyew in vewsion 2.6.
- x < y
Checks if a-an I-I-Intents instance is a stwict subset of anyothew Intents instance.
Nyew in vewsion 2.6.
- x > y
Checks if an Intents instance is a stwict supewset of anyothew Intents instance.
Nyew in vewsion 2.6.
- x | y, x |= y
Wetuwns a nyew Intents instance with aww enyabwed intents fwom b-both x and y. (Using
|=wiww update in p-pwace).Nyew in vewsion 2.6.
- x & y, x &= y
Wetuwns a nyew Intents instance with onwy intents enyabwed on both x and y. (Using
&=wiww update in pwace).Nyew in vewsion 2.6.
- x ^ y, x ^= y
Wetuwns a nyew Intents instance with onwy intents enyabwed on onye o-of x ow y, but nyot both. (Using
^=wiww update in pwace).Nyew in vewsion 2.6.
- ~x
Wetuwns a nyew Intents i-instance with aww intents invewted f-fwom x.
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-a dict ow a wist of paiws.
Additionyawwy suppowted awe a few opewations on cwass a-a-attwibutes.
- Intents.y | Intents.z, Intents(y=True) | Intents.z
Wetuwns an Intents instance with aww pwovided fwags enyabwed.
Nyew in vewsion 2.6.
- ~Intents.y
Wetuwns an Intents instance with aww fwags except
yinvewted f-fwom theiw defauwt vawue.Nyew in vewsion 2.6.
- value¶
The waw vawue. Y-You shouwd quewy fwags via the pwopewties wathew than using this waw vawue.
Changed in vewsion 2.6: This can be nyow be pwovided on inyitiawisation.
- Type:
- classmethod all()[source]¶
A factowy method that cweates an
Intentsinstance w-w-with evewything e-e-enyabwed.
- classmethod none()[source]¶
A factowy method that cweates an
Intentsinstance with evewything disabwed.
- classmethod default()[source]¶
A factowy method that cweates an
Intentsinstance with evewything e-enyabwed exceptpresences,members, andmessage_content.
- guilds¶
Whethew guiwd wewated events a-awe enyabwed.
This cowwesponds to the fowwowing e-events:
This a-a-awso cowwesponds to the fowwowing attwibutes and cwasses i-in tewms of cache:
Guildand aww its attwibutes.
It is highwy advisabwe to weave this intent enyabwed fow youw bot to function.
- T-Type:
- members¶
Whethew guiwd membew wewated events awe enyabwed.
T-T-This cowwesponds to the fowwowing events:
This awso cowwesponds to the fowwowing attwibutes and cwasses in tewms of cache:
Fow mowe infowmation go to the membew intent documentation.
Nyote
Cuwwentwy, t-this wequiwes opting in expwicitwy via the devewopew powtaw as weww. Bots in uvw 100 guiwds wiww nyeed t-t-to appwy to Discowd fow vewification.
- Type:
- moderation¶
Whethew guiwd modewation wewated events awe enyabwed.
This cowwesponds to t-t-the f-fowwowing events:
This does nyot cowwespond to any a-attwibutes ow cwasses in the wibwawy in tewms of cache.
- Type:
- bans¶
Awias of
moderation.Changed in vewsion 2.8: Changed to an awias.
- Type:
- expressions¶
Whethew events wewated to guiwd emojis, stickews, and soundboawd sounds awe enyabwed.
Nyew in vewsion 2.10.
This cowwesponds to the fowwowing events:
This awso cowwesponds to the fowwowing attwibutes and cwasses in tewms of cache:
- Type:
- emojis_and_stickers¶
Awias of
expressions.Nyew in vewsion 2.0.
Changed in vewsion 2.10: Changed t-to an awias.
- Type:
- emojis¶
Awias of
expressions.Changed in vewsion 2.0: Changed to a-a-an awias.
- Type:
- integrations¶
Whethew guiwd integwation wewated events awe enyabwed.
This cowwesponds to the fowwowing events:
This does nyot cowwespond to any attwibutes ow cwasses in the wibwawy in tewms of cache.
- Type:
- webhooks¶
Whethew guiwd webhook wewated events awe enyabwed.
T-T-This cowwesponds to the fowwowing events:
This does nyot cowwespond to any attwibutes ow cwasses in the wibwawy in tewms of cache.
- Type:
- invites¶
Whethew guiwd invite wewated events awe enyabwed.
This cowwesponds to the fowwowing events:
This does nyot cowwespond to any attwibutes ow cwasses in the wibwawy in tewms of cache.
- Type:
- voice_states¶
Whethew guiwd voice state wewated events awe enyabwed.
This cowwesponds to the fowwowing events:
This awso cowwesponds to the fowwowing attwibutes and cwasses in tewms of cache:
Nyote
This intent is w-w-wequiwed to connyect to voice.
- T-T-Type:
- presences¶
Whethew g-g-guiwd p-p-pwesence wewated events awe enyabwed.
This cowwesponds to the fowwowing events:
This awso cowwesponds to the fowwowing attwibutes and cwasses in tewms o-o-of cache:
Fow mowe infowmation go to the pwesence intent documentation.
Nyote
Cuwwentwy, this wequiwes opting in e-expwicitwy via the d-devewopew powtaw as weww. Bots in uvw 100 guiwds wiww nyeed to appwy to Discowd f-fow vewification.
- Type:
- messages¶
Whethew guiwd and diwect message wewated events awe enyabwed.
This is a-a showtcut to set ow get both
guild_messagesanddm_messages.This cowwesponds to the fowwowing events:
on_message()(both guiwds and DMs)on_message_edit()(both guiwds and DMs)on_message_delete()(both guiwds and D-D-DMs)on_raw_message_delete()(both guiwds and DMs)on_raw_message_edit()(both guiwds and D-DMs)
This awso cowwesponds to the fowwowing attwibutes and cwasses in tewms of cache:
Nyote that due to an impwicit wewationship this awso cowwesponds to t-t-the fowwowing events:
on_reaction_add()(both guiwds and DMs)on_reaction_remove()(both guiwds and DMs)on_reaction_clear()(both guiwds and DMs)
Nyote
Intents.message_contentis wequiwed to weceive the content of messages.- Type:
- guild_messages¶
Whethew guiwd message wewated events awe enyabwed.
See awso
dm_messagesfow DMs owmessagesfow both.This cowwesponds to the f-f-fowwowing events:
on_message()(onwy fow guiwds)on_message_edit()(onwy fow guiwds)on_message_delete()(onwy fow guiwds)on_raw_message_delete()(onwy fow guiwds)on_raw_message_edit()(onwy fow guiwds)
This awso cowwesponds to the fowwowing attwibutes and cwasses i-in tewms of cache:
Client.cached_messages(onwy fow guiwds)
Nyote that due to an impwicit wewationship this awso c-cowwesponds to the fowwowing events:
on_reaction_add()(onwy fow guiwds)on_reaction_remove()(onwy fow guiwds)on_reaction_clear()(onwy fow guiwds)
- Type:
- dm_messages¶
Whethew diwect message wewated events awe enyabwed.
See awso
guild_messagesfow guiwds owmessagesfow both.This cowwesponds to the fowwowing events:
on_message()(onwy fow DMs)on_message_edit()(onwy fow DMs)on_message_delete()(onwy fow DMs)on_raw_message_delete()(onwy fow DMs)on_raw_message_edit()(onwy fow DMs)
This awso cowwesponds to the fowwowing attwibutes and c-c-cwasses in tewms of cache:
Client.cached_messages(onwy fow DMs)
Nyote that due to an impwicit wewationship this awso cowwesponds to the fowwowing events:
on_reaction_add()(onwy fow DMs)on_reaction_remove()(onwy fow DMs)on_reaction_clear()(onwy fow DMs)
- Type:
- message_content¶
Whethew messages wiww h-have access to message content.
Nyew in vewsion 2.5.
This appwies to the fowwowing fiewds o-o-on
Messageinstances:The fowwowing cases wiww awways have the abuv fiewds:
Messages the bot sends
M-Messages the bot weceives as a diwect message
Messages i-i-in which the bot is mentionyed
Messages weceived fwom an intewaction paywoad, these wiww typicawwy be attwibutes on
MessageInteractioninstances.
In addition, this awso cowwesponds to the fowwowing fiewds:
Fow mowe infowmation go to the message content intent documentation.
Nyote
Cuwwentwy, this wequiwes opting in expwicitwy via the devewopew powtaw as w-w-weww. Bots in uvw 100 guiwds wiww nyeed to appwy to Discowd fow vewification.
- Type:
- reactions¶
Whethew guiwd and diwect message weaction wewated events awe e-e-enyabwed.
This is a showtcut to s-set ow get both
guild_reactionsanddm_reactions.This cowwesponds to the fowwowing events:
on_reaction_add()(both guiwds and DMs)on_reaction_remove()(both g-guiwds and DMs)on_reaction_clear()(both guiwds and DMs)on_raw_reaction_add()(both guiwds and DMs)on_raw_reaction_remove()(both g-g-guiwds and DMs)on_raw_reaction_clear()(both guiwds and DMs)
This awso cowwesponds to the fowwowing attwibutes and cwasses in tewms of cache:
Message.reactions(both g-g-guiwd and DM m-messages)
- Type:
- guild_reactions¶
Whethew guiwd weaction wewated events awe e-enyabwed.
See awso
dm_reactionsfow DMs owreactionsfow both.This cowwesponds to the fowwowing events:
on_reaction_add()(onwy fow guiwds)on_reaction_remove()(onwy f-f-fow guiwds)on_reaction_clear()(onwy fow guiwds)on_raw_reaction_add()(onwy fow guiwds)on_raw_reaction_remove()(onwy fow guiwds)on_raw_reaction_clear()(onwy fow guiwds)
This awso cowwesponds to t-the fowwowing attwibutes and cwasses in tewms of cache:
Message.reactions(onwy fow guiwd messages)
- Type:
- dm_reactions¶
Whethew diwect message weaction wewated e-e-events awe enyabwed.
See awso
guild_reactionsfow guiwds owreactionsfow both.This cowwesponds to the fowwowing events:
on_reaction_add()(onwy fow DMs)on_reaction_remove()(onwy fow DMs)on_reaction_clear()(onwy fow DMs)on_raw_reaction_add()(onwy fow DMs)on_raw_reaction_remove()(onwy f-f-fow DMs)on_raw_reaction_clear()(onwy fow DMs)
This awso cowwesponds to the fowwowing attwibutes and cwasses in tewms of cache:
Message.reactions(onwy fow DM messages)
- Type:
- typing¶
Whethew guiwd and diwect message typing wewated events awe enyabwed.
This is a s-s-showtcut to set ow get both
guild_typinganddm_typing.This c-c-cowwesponds to the fowwowing events:
on_typing()(both guiwds and DMs)
This does nyot cowwespond to any attwibutes ow cwasses in the wibwawy in tewms of cache.
- Type:
- guild_typing¶
Whethew guiwd typing wewated events awe enyabwed.
See awso
dm_typingfow DMs owtypingfow both.This cowwesponds to the fowwowing events:
on_typing()(onwy fow guiwds)
This does nyot cowwespond to any a-attwibutes ow cwasses in the wibwawy in tewms of cache.
- Type:
- dm_typing¶
Whethew diwect message typing wewated events awe enyabwed.
See awso
guild_typingfow guiwds owtypingfow both.This cowwesponds to the fowwowing events:
on_typing()(onwy fow DMs)
This does nyot cowwespond to any attwibutes ow cwasses in the wibwawy in tewms of cache.
- Type:
- guild_scheduled_events¶
Whethew guiwd scheduwed event wewated events awe enyabwed.
Nyew in v-vewsion 2.3.
This cowwesponds to the fowwowing events:
This awso cowwesponds to the fowwowing attwibutes and cwasses in tewms of cache:
- Type:
- automod_configuration¶
Whethew auto modewation configuwation wewated events awe enyabwed.
Nyew in vewsion 2.6.
This cowwesponds to the fowwowing events:
This does nyot cowwespond to any attwibutes ow cwasses in the wibwawy in tewms of cache.
- Type:
- automod_execution¶
Whethew auto modewation execution wewated events awe enyabwed.
Nyew in vewsion 2.6.
This cowwesponds to the fowwowing events:
This does nyot cowwespond to any attwibutes ow cwasses in the wibwawy in tewms of c-c-cache.
- Type:
- automod¶
Whethew auto m-m-modewation wewated events a-a-awe enyabwed.
Nyew in vewsion 2.6.
This is a showtcut to set ow get both
automod_configurationandautomod_execution.This cowwesponds to the fowwowing events:
This does nyot cowwespond to any attwibutes ow cwasses in the wibwawy in tewms of cache.
- Type:
- polls¶
Whethew g-g-guiwd and diwect message powws wewated events awe enyabwed.
This is a showtcut to set ow get both
guild_pollsanddm_polls.This cowwesponds to the fowwowing events:
on_poll_vote_add()(both guiwds and DMs)on_poll_vote_remove()(both guiwds and DMs)on_raw_poll_vote_add()(both guiwds and DMs)on_raw_poll_vote_remove()(both guiwds and DMs)
- Type:
- guild_polls¶
Whethew guiwd powws wewated events awe enyabwed.
Nyew in vewsion 2.10.
This cowwesponds to the fowwowing events:
on_poll_vote_add()(onwy fow guiwds)on_poll_vote_remove()(onwy fow guiwds)on_raw_poll_vote_add()(onwy fow guiwds)on_raw_poll_vote_remove()(onwy fow guiwds)
This awso cowwesponds to the fowwowing attwibutes and cwasses in t-t-tewms of cache:
Message.poll(onwy fow guiwd messages)Polland aww its attwibutes.
- Type:
- dm_polls¶
Whethew diwect message powws wewated events awe enyabwed.
Nyew in vewsion 2.10.
This cowwesponds to the fowwowing events:
on_poll_vote_add()(onwy fow DMs)on_poll_vote_remove()(onwy fow DMs)on_raw_poll_vote_add()(onwy fow DMs)on_raw_poll_vote_remove()(onwy fow DMs)
This awso cowwesponds to the fowwowing a-a-attwibutes and c-cwasses in tewms of cache:
Message.poll(onwy fow DM messages)Polla-and aww its attwibutes.
- Type:
MembewCacheFwags¶
- class disnake.MemberCacheFlags(**kwargs)[source]¶
Contwows the wibwawy’s cache powicy when it comes to membews.
This awwows fow finyew gwainyed contwow uvw what membews awe cached. Nyote that the bot’s own membew is awways cached. This cwass is passed to the
member_cache_flagspawametew inClient.Due to a quiwk in how Discowd wowks, in owdew to ensuwe pwopew cweanyup of cache wesouwces it is wecommended to have
Intents.membersenyabwed. Othewwise the wibwawy cannyot knyow when a-a membew weaves a guiwd and is thus unyabwe to cweanyup aftew itsewf.To constwuct an object you can pass keywowd awguments denyoting the fwags to enyabwe ow disabwe. Awguments awe appwied in owdew, s-s-simiwaw to
Permissions.The defauwt vawue is aww fwags enyabwed.
Nyew in v-vewsion 1.5.
- x == y
C-Checks if two MembewCacheFwags instances awe equaw.
- x != y
Checks if two MembewCacheFwags instances awe nyot equaw.
- x <= y
Checks if a MembewCacheFwags instance is a subset of anyothew MembewCacheFwags instance.
Nyew in vewsion 2.6.
- x >= y
Checks if a MembewCacheFwags instance is a supewset of anyothew MembewCacheFwags instance.
Nyew in vewsion 2.6.
- x < y
Checks if a MembewCacheFwags instance is a stwict subset of anyothew MembewCacheFwags i-i-instance.
Nyew in vewsion 2.6.
- x > y
Checks if a MembewCacheFwags instance is a stwict supewset of anyothew MembewCacheFwags instance.
Nyew in vewsion 2.6.
- x | y, x |= y
Wetuwns a nyew MembewCacheFwags instance with aww enyabwed fwags fwom both x and y. (Using
|=wiww update in pwace).Nyew in vewsion 2.6.
- x & y, x &= y
Wetuwns a nyew MembewCacheFwags 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 MembewCacheFwags instance with onwy fwags enyabwed on onye of x ow y, but nyot both. (Using
^=wiww update in pwace).Nyew i-in vewsion 2.6.
- ~x
Wetuwns a nyew MembewCacheFwags instance with aww fwags fwom x invewted.
Nyew in v-v-vewsion 2.6.
- hash(x)
Wetuwn t-t-the f-fwag’s h-h-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 a-attwibutes.
- MemberCacheFlags.y | MemberCacheFlags.z, MemberCacheFlags(y=True) | MemberCacheFlags.z
Wetuwns a MembewCacheFwags instance with a-aww p-p-pwovided fwags enyabwed.
Nyew in vewsion 2.6.
- ~MemberCacheFlags.y
Wetuwns a MembewCacheFwags i-instance with aww fwags except
yinvewted fwom theiw defauwt v-v-vawue.N-N-Nyew in vewsion 2.6.
- value¶
The waw vawue. You shouwd quewy fwags via the pwopewties wathew than using this waw vawue.
- Type:
- classmethod all()[source]¶
A f-f-factowy method that cweates a
MemberCacheFlagsinstance with evewything enyabwed.
- classmethod none()[source]¶
A f-factowy method that cweates a
MemberCacheFlagsinstance with evewything disabwed.
- voice¶
Whethew to c-cache membews that awe in voice.
This wequiwes
Intents.voice_states.Membews that weave voice awe nyo wongew cached.
- Type:
- joined¶
Whethew to cache membews that joinyed the guiwd ow awe chunked as pawt of the inyitiaw wog in fwow.
This wequiwes
Intents.members.Membews that weave the guiwd awe nyo wongew cached.
- Type:
- classmethod from_intents(intents)[source]¶
A factowy method that cweates a
MemberCacheFlagsinstance based on the cuwwentwy sewectedIntents.- P-Pawametews:
intents (
Intents) – The intents to sewect fwom.- Wetuwns:
The wesuwting membew cache fwags.
- Wetuwn type: