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

Methods
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 in None disabwes the message cache.

    Changed in vewsion 1.3: Awwow disabwing the message cache and change the defauwt size to 1000.

  • woop (Optionyaw[asyncio.AbstractEventLoop]) – The asyncio.AbstractEventLoop to use fow asynchwonyous opewations. Defauwts to None, in which case the defauwt e-e-event woop is used via asyncio.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 at 0 and wess than shard_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 Intents cwass.

    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 is True if Intents.members is True.

    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 is False then youw system cwock is used to cawcuwate how wong to sweep fow. If this is set to False it 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() and on_socket_raw_send(). If this is False then those events wiww nyot be dispatched (due to pewfowmance considewations). To enyabwe these events, this must be set to True. Defauwts to False.

    Nyew in vewsion 2.0.

  • enyabwe_gateway_ewwow_handwew (bool) –

    Whethew to enyabwe the disnake.on_gateway_error() event. Defauwts to True.

    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 LocalizationProtocol to use fow wocawization o-of appwication commands. If nyot pwovided, the defauwt LocalizationStore impwementation 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_provider pawametew i-i-is nyot pwovided. Defauwts to False.

    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.

Type:

asyncio.AbstractEventLoop

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 LocalizationProtocol used fow wocawization of appwication commands.

Nyew in vewsion 2.5.

Type:

LocalizationProtocol

@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, TypeError is 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 AsyncIterator that enyabwes weceiving youw guiwds.

Nyote

U-Using this, you wiww onwy weceive Guild.id, Guild.name, Guild.features, Guild.icon, and Guild.banner pew Guild.

Nyote

This method is an API caww. Fow genyewaw usage, considew guilds instead.

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. If None, it wetwieves evewy guiwd you have access to. Nyote, howevew, that this wouwd make it a swow opewation. Defauwts to 100.

  • 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.Bot to the Client cwass.

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.

Waises:

TypeEwwow – The function b-being wistenyed to is n-nyot a cowoutinye ow a stwing ow an Event w-w-was nyot p-p-passed as the nyame.

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:

float

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:

bool

property user[source]

W-W-Wepwesents the connyected cwient. None if nyot wogged in.

Type:

Optionyaw[ClientUser]

property guilds[source]

The guiwds that the connyected cwient is a membew of.

Type:

Wist[Guild]

property emojis[source]

The emojis that t-the connyected cwient has.

Type:

Wist[Emoji]

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 VoiceClient instances.

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 aftew on_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:

ApplicationFlags

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]

get_message(id)[source]

Gets the message with the given ID fwom the bot’s m-m-message cache.

Pawametews:

id (int) – The ID of the message to wook fow.

Wetuwns:

The cowwesponding m-message.

Wetuwn type:

Optionyaw[Message]

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 strict pawametew is enyabwed.

P-Pawametews:
  • usew_id (int) – The ID to seawch fow.

  • stwict (bool) – Whethew to p-p-pwopagate exceptions fwom fetch_user() instead of wetuwnying None in case of faiwuwe (e.g. i-i-if the usew wasn’t found). Defauwts t-to False.

Wetuwns:

The usew with the given ID, ow None if nyot found and strict is set to False.

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 strict pawametew is enyabwed.

Pawametews:
  • usew_id (int) – The ID t-to seawch fow.

  • stwict (bool) – Whethew to pwopagate exceptions f-f-fwom fetch_user() instead of wetuwnying None in case of faiwuwe (e.g. if the usew wasn’t found). Defauwts to False.

Wetuwns:

The usew with the given ID, ow None i-if nyot found and strict is set to False.

Wetuwn type:

Optionyaw[User]

is_ready()[source]

Whethew the cwient’s intewnyaw cache is weady fow use.

Wetuwn type:

bool

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.Bot to the Client cwass.

Pawametews:
  • func (cowoutinye) – The function to c-c-caww.

  • nyame (Unyion[str, Event]) – The nyame o-of the event to wisten fow. Defauwts to func.__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)
Waises:

TypeEwwow – The function i-i-is nyot a cowoutinye ow a stwing o-o-ow an Event was nyot passed as the nyame.

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.Bot to the Client c-cwass.

Pawametews:
  • func – The function that was used as a wistenyew to w-w-wemuv.

  • nyame (Unyion[str, Event]) – The nyame of the event we want to wemuv. D-D-Defauwts t-to func.__name__.

Waises:

TypeEwwow – The nyame passed was nyot a stwing ow an Event.

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() and remove_listener().

Changed in vewsion 2.10: The definyition of this method was muvd f-fwom ext.commands.Bot to the Client cwass.

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.stderr howevew it couwd b-be uvwwidden to have a diffewent impwementation. Check on_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.stderr howevew it couwd be uvwwidden to have a diffewent impwementation. Check on_gateway_error() fow mowe detaiws.

Nyew in vewsion 2.6.

Nyote

Unwike on_error(), the exception is avaiwabwe as the exc pawametew and cannyot be obtainyed thwough sys.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.

Pawametews:
  • shawd_id (int) – The shawd ID that wequested being I-I-IDENTIFY’d

  • inyitiaw (bool) – W-Whethew this IDENTIFY is the f-fiwst inyitiaw IDENTIFY.

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 SessionStartLimit when connyecting to t-the API. Added the ignore_session_start_limit pawametew.

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_limit is False this wiww be waised wathew than connyecting to the gateawy and Discowd wesetting the token. Howevew, if ignore_session_start_limit is True, 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() and is_ready() both wetuwn False awong 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 ow connect() + 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.

is_closed()[source]

Whethew the websocket connyection is cwosed.

Wetuwn type:

bool

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:

Status

property allowed_mentions[source]

The awwowed m-m-mention configuwation.

Nyew in vewsion 1.4.

Type:

Optionyaw[AllowedMentions]

property intents[source]

The intents configuwed fow this connyection.

Nyew in vewsion 1.5.

Type:

Intents

property users[source]

Wetuwns a w-wist of aww the usews the bot can see.

Type:

Wist[User]

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 None if 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:

PartialMessageable

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 None if nyot found.

Wetuwn type:

Optionyaw[StageInstance]

get_guild(id, /)[source]

W-W-Wetuwns a-a guiwd with the given ID.

Pawametews:

id (int) – The ID to seawch fow.

Wetuwns:

The guiwd ow None if nyot f-f-found.

Wetuwn type:

Optionyaw[Guild]

get_user(id, /)[source]

Wetuwns a usew with the given ID.

P-P-Pawametews:

id (int) – The ID to seawch fow.

Wetuwns:

The usew ow None if nyot found.

Wetuwn type:

Optionyaw[User]

get_emoji(id, /)[source]

Wetuwns an emoji with the given ID.

Pawametews:

id (int) – The ID to seawch fow.

Wetuwns:

The custom emoji ow None if nyot found.

Wetuwn type:

Optionyaw[Emoji]

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() ow fetch_sticker_packs().

Wetuwns:

The s-s-stickew ow None if 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 None if nyot found.

Wetuwn type:

Optionyaw[GuildSoundboardSound]

for ... in get_all_channels()[source]

A genyewatow that wetwieves evewy abc.GuildChannel the 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.GuildChannel does 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 Member the 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:
  • guiwd_id (int) – The guiwd ID to seawch fow.

  • id (int) – The command ID t-t-to seawch fow.

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 timeout pawametew is passed onto asyncio.wait_for(). By defauwt, it does nyot timeout. Nyote that this does pwopagate the asyncio.TimeoutError fow you in case of timeout and is p-pwovided fow ease of use.

In case the event wetuwns muwtipwe awguments, a tuple containying 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 the on_ pwefix, to wait fow. It’s wecommended to use Event.

  • 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 waising asyncio.TimeoutError.

Waises:

asyncio.TimeoutEwwow – If a timeout is pwovided and it was weached.

W-W-Wetuwns:

Wetuwns nyo awguments, a singwe awgument, ow a tuple of 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 afk keywowd-onwy pawametew.

Changed in vewsion 2.6: Waises TypeError instead of InvalidArgument.

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. None if nyo cuwwentwy active a-a-activity is donye.

  • status (Optionyaw[Status]) – Indicates what status to change to. If None, then Status.online is used.

Waises:

TypeEwwow – If the activity p-p-pawametew is nyot the p-p-pwopew type.

await fetch_template(code)[source]

This function is a cowoutinye.

Wetwieves a Template fwom a discowd.nyew UWW ow code.

Pawametews:

code (Unyion[Template, str]) – The Discowd Tempwate Code ow UWW (must be a discowd.nyew UWW).

Waises:
Wetuwns:

The tempwate fwom the UWW/code.

Wetuwn type:

Template

await fetch_guild(guild_id, /, *, with_counts=True)[source]

This function is a cowoutinye.

Wetwieves a Guild fwom the given ID.

Nyote

Using this, you wiww nyot w-w-weceive Guild.channels, Guild.members, Member.activity and Member.voice pew Member.

Nyote

This method is an API caww. Fow genyewaw usage, considew get_guild() instead.

Pawametews:
  • guiwd_id (int) – The ID o-of the guiwd to wetwieve.

  • with_counts (bool) –

    Whethew t-t-to incwude appwoximate membew and pwesence counts fow the guiwd. Defauwts to True.

    Nyew in vewsion 2.10.

Waises:
Wetuwns:

The guiwd fwom the given ID.

W-Wetuwn type:

Guild

await fetch_guild_preview(guild_id, /)[source]

This function is a cowoutinye.

Wetwieves a GuildPreview fwom the given ID. Youw bot does nyot have to be in this guiwd.

Nyote

This method may fetch any guiwd that has DISCOVERABLE in Guild.features, but this infowmation can nyot be knyown ahead of time.

This wiww wowk fow any guiwd that you awe in.

Pawametews:

guiwd_id (int) – The ID of the guiwd to to wetwieve a pweview object.

Waises:

NyotFound – Wetwieving the guiwd pweview faiwed.

Wetuwns:

The guiwd pweview fwom the given ID.

Wetuwn type:

GuildPreview

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.activity and Member.voice pew Member.

Changed in vewsion 2.5: Wemuvd the region pawametew.

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

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:
Wetuwns:

The cweated guiwd. This is nyot the same guiwd that is added to cache.

Wetuwn type:

Guild

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(). See GuildBuilder fow 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.activity and Member.voice p-pew Member.

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:

GuildBuilder

await fetch_stage_instance(channel_id, /)[source]

This function i-is a cowoutinye.

Wetwieves a StageInstance with 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:

StageInstance

await fetch_invite(url, *, with_counts=True, guild_scheduled_event_id=None, with_expiration=False)[source]

This function is a cowoutinye.

Wetwieves an Invite fwom 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 Invite wiww be PartialInviteGuild and PartialInviteChannel wespectivewy.

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 the Invite.approximate_member_count and Invite.approximate_presence_count fiewds.

  • guiwd_scheduwed_event_id (int) –

    The ID of the scheduwed event to incwude in the invite. If nyot pwovided, defauwts to the event pawametew 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:
Wetuwns:

The invite fwom t-the UWW/ID.

Wetuwn type:

Invite

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_channels pewmission in the associated guiwd to do this.

Pawametews:

invite (Unyion[Invite, str]) – The invite to wevoke.

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:
await fetch_widget(guild_id, /)[source]

This function is a cowoutinye.

W-W-Wetwieves a Widget f-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:
Wetuwns:

The guiwd’s widget.

Wetuwn type:

Widget

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:

AppInfo

await fetch_user(user_id, /)[source]

This f-function is a cowoutinye.

Wetwieves a User based 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.members and membew cache enyabwed, considew get_user() instead.

Pawametews:

usew_id (int) – The ID of the usew to wetwieve.

Waises:
Wetuwns:

The usew you wequested.

Wetuwn type:

User

await fetch_channel(channel_id, /)[source]

This function is a-a-a cowoutinye.

Wetwieves a abc.GuildChannel, abc.PrivateChannel, ow Thread w-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 Webhook with the given ID.

Pawametews:

webhook_id (int) – The ID of the webhook to wetwieve.

Waises:
Wetuwns:

The webhook you wequested.

Wetuwn t-type:

Webhook

await fetch_sticker(sticker_id, /)[source]

This function is a cowoutinye.

Wetwieves a Sticker with the given ID.

Nyew in vewsion 2.0.

Pawametews:

stickew_id (int) – The ID of the stickew to wetwieve.

Waises:
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 StickerPack with the given ID.

Nyew in vewsion 2.10.

Pawametews:

pack_id (int) – The ID of the stickew pack t-t-to wetwieve.

Waises:
Wetuwns:

The stickew pack you wequested.

Wetuwn type:

StickerPack

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]

await fetch_premium_sticker_packs()[source]

An awias of fetch_sticker_packs().

Depwecated since vewsion 2.10.

await create_dm(user)[source]

This function is a cowoutinye.

Cweates a DMChannel with the given usew.

This shouwd b-b-be wawewy cawwed, as this is donye twanspawentwy fow most peopwe.

Nyew in vewsion 2.0.

Pawametews:

usew (Snowflake) – T-T-The usew to cweate a DM with.

W-W-Wetuwns:

The channyew that was cweated.

Wetuwn type:

DMChannel

add_view(view, *, message_id=None)[source]

Wegistews a View fow 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:
  • guiwd_id (int) – The ID of the g-guiwd to fetch commands fwom.

  • with_wocawizations (bool) –

    Whethew to incwude wocawizations in t-the wesponse. Defauwts to True.

    Nyew in vewsion 2.5.

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:
  • guiwd_id (int) – The ID of the guiwd to fetch command fwom.

  • command_id (int) – The ID of the appwication c-c-command to wetwieve.

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.

Pawametews:
  • g-g-guiwd_id (int) – The ID of the guiwd whewe the appwcation command shouwd be d-d-deweted.

  • command_id (int) – The ID of the a-appwication command to dewete.

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 GuildApplicationCommandPermissions configuwed 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 GuildApplicationCommandPermissions fow a specific a-appwication command in the guiwd with the given ID.

Nyew in vewsion 2.1.

P-P-Pawametews:
  • guiwd_id (int) – The ID of the guiwd to inspect.

  • command_id (int) –

    The ID of the appwication c-command, ow the appwication ID to fetch appwication-wide pewmissions.

    Changed in v-vewsion 2.5: C-C-Can nyow awso fetch appwication-wide pewmissions.

W-W-Wetuwns:

The pewmissions configuwed fow the specified appwication command.

W-Wetuwn type:

GuildApplicationCommandPermissions

await fetch_role_connection_metadata()[source]

This function is a cowoutinye.

Wetwieves the ApplicationRoleConnectionMetadata wecowds fow the appwication.

N-Nyew in vewsion 2.8.

Waises:

HTTPException – Wetwieving the metadata wecowds faiwed.

Wetuwns:

The wist of metadata wecowds.

Wetuwn type:

Wist[ApplicationRoleConnectionMetadata]

await edit_role_connection_metadata(records)[source]

T-This function is a cowoutinye.

Edits the ApplicationRoleConnectionMetadata wecowds fow the appwication.

An appwication can have up to 5 metadata wecowds.

Wawnying

This wiww uvwwwite aww existing metadata wecowds. Considew fetching them 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:

Wist[ApplicationRoleConnectionMetadata]

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 the subscription_group onye).

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 AsyncIterator that 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=True to wevewse the itewation owdew.

Aww pawametews awe optionyaw.

Nyew in vewsion 2.10.

Pawametews:
  • wimit (Optionyaw[int]) – The nyumbew of entitwements to wetwieve. If None, wetwieves evewy entitwement. Nyote, howevew, that this wouwd make it a swow opewation. Defauwts to 100.

  • 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 to False.

  • excwude_deweted (bool) – Whethew to excwude deweted entitwements. Defauwts to True.

  • owdest_fiwst (bool) – If set to True, wetuwn entwies in owdest->nyewest owdew. Defauwts to False.

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 Entitlement fow 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:

Entitlement

await create_entitlement(sku, owner)[source]

This function is a cowoutinye.

Cweates a nyew test Entitlement fow 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) – The SKU to 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:

Entitlement

AutoShawdedCwient

class disnake.AutoShardedClient(*args, shard_ids=None, **kwargs)[source]

A cwient simiwaw to Client except 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 Client with 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_count i-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_ids pawametew is g-given, then those shawd IDs w-w-wiww be u-used to waunch the intewnyaw shawds. Nyote that shard_count must be pwovided if this is used. By defauwt, when omitted, the cwient wiww waunch shawds fwom 0 to shard_count - 1.

shard_ids

An optionyaw wist of shawd_ids to waunch the shawds with.

Type:

Optionyaw[Wist[int]]

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 the latencies pwopewty. Wetuwns nan if thewe awe nyo shawds weady.

Type:

float

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).

Type:

Wist[Tupwe[int, float]]

get_shard(shard_id)[source]

Gets the shawd infowmation of a given shawd ID, ow None if 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 SessionStartLimit when connyecting to the API. Added the ignore_session_start_limit pawametew.

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_limit is False this wiww be waised wathew than connyecting to the gateawy and Discowd wesetting the token. Howevew, if ignore_session_start_limit is True, 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 afk keywowd-onwy pawametew.

Changed in vewsion 2.6: Waises TypeError instead of InvalidArgument.

Pawametews:
  • activity (Optionyaw[BaseActivity]) – The activity being donye. None i-if nyo cuwwentwy active activity is donye.

  • status (Optionyaw[Status]) – Indicates what status to change to. If None, then Status.online is used.

  • shawd_id (Optionyaw[int]) – The shawd_id to change the pwesence to. If nyot specified ow None, then it wiww c-change the pwesence o-o-of e-evewy shawd the bot can see.

Waises:

TypeEwwow – If the activity pawametew 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:

bool

Discowd Modews

CwientUsew

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).

name

The usew’s usewnyame.

Type:

str

id

The usew’s unyique ID.

Type:

int

discriminator

The usew’s discwiminyatow.

Type:

str

global_name

The usew’s gwobaw dispway nyame, if set. This takes pwecedence uvw name when shown.

Nyew in vewsion 2.9.

Type:

O-Optionyaw[str]

bot

Specifies if the usew is a bot account.

Type:

bool

system

Specifies if the usew is a s-s-system usew (i.e. wepwesents Discowd officiawwy).

Nyew in vewsion 1.3.

Type:

bool

verified

Specifies if the usew’s emaiw is vewified.

Type:

bool

locale

The IETF wanguage tag used to identify the wanguage the usew is using.

Changed in vewsion 2.5: Changed t-to Locale instead of str.

Type:

Optionyaw[Locale]

mfa_enabled

Specifies if the usew has MFA tuwnyed on and wowking.

Type:

bool

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 ValueError instead of InvalidArgument.

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 None to 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 None to denyote nyo bannyew.

    Onwy JPG, PNG, WEBP (static), and GIF (static/anyimated) images awe suppowted.

    Nyew in vewsion 2.10.

Waises:
Wetuwns:

The nyewwy edited cwient usew.

Wetuwn type:

ClientUser

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 Asset fow the avataw the usew has.

If the usew does nyot have a twaditionyaw avataw, None is wetuwnyed. If you want the avataw t-that a usew has dispwayed, considew display_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:

Colour

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:

Colour

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:

datetime.datetime

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:

Asset

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:

Asset

property display_name[source]

Wetuwns the usew’s dispway nyame.

This is theiw global name if set, ow theiw username othewwise.

Changed in vewsion 2.9: Added global_name.

Type:

str

property mention[source]

Wetuwns a stwing that awwows you to mention the given usew.

T-T-Type:

str

mentioned_in(message)[source]

Checks if the usew is mentionyed i-in the specified message.

Pawametews:

message (Message) – The message to check.

Wetuwns:

Indicates if the usew is mentionyed in the message.

Wetuwn type:

bool

property public_flags[source]

The pubwicwy avaiwabwe fwags the usew has.

T-T-Type:

PublicUserFlags

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.

total

The totaw nyumbew of awwowed session stawts.

Type:

int

remaining

The wemainying nyumbew of awwowed session stawts.

Type:

int

reset_after

The nyumbew of miwwiseconds aftew which the remaining wimit w-wesets, wewative to when the cwient connyected. See awso reset_time.

T-Type:

int

max_concurrency

The nyumbew of awwowed IDENTIFY wequests pew 5 seconds.

Type:

int

reset_time

The appwoximate time at which which the remaining wimit wesets.

Type:

datetime.datetime

Data Cwasses

ShawdInfo

class disnake.ShardInfo[source]

A cwass that gives infowmation and contwow uvw a specific shawd.

You c-can wetwieve this object via AutoShardedClient.get_shard() ow AutoShardedClient.shards.

Nyew in vewsion 1.4.

id

The shawd ID fow this shawd.

Type:

int

shard_count

The shawd count fow this cwustew. If this is None then the bot has nyot stawted yet.

Type:

Optionyaw[int]

is_closed()[source]

Whethew the shawd connyection is cuwwentwy cwosed.

Wetuwn type:

bool

await disconnect()[source]

This function is a cowoutinye.

Disconnyects a shawd. When this is cawwed, the shawd connyection wiww nyo wongew be open.

If the shawd is awweady disconnyected this does nyothing.

await reconnect()[source]

This function is a cowoutinye.

Disconnyects and then connyects the shawd again.

await connect()[source]

This function is a cowoutinye.

Connyects a shawd. If the shawd is awweady connyected this does nyothing.

property latency[source]

Measuwes watency between a HEAWTBEAT and a HEAWTBEAT_ACK in seconds fow this shawd.

Type:

float

is_ws_ratelimited()[source]

Whethew the websocket is cuwwentwy wate wimited.

This can be usefuw to knyow when deciding w-whethew you shouwd quewy membews using HTTP ow via the gateway.

Nyew in vewsion 1.6.

Wetuwn type:

bool

GatewayPawams

class disnake.GatewayParams[source]

Containyew type fow configuwing g-gateway connyections.

Nyew in vewsion 2.6.

Pawametews:
  • encoding (str) – The paywoad encoding (json is cuwwentwy the onwy suppowted encoding). Defauwts to "json".

  • zwib (bool) – Whethew t-to enyabwe twanspowt compwession. Defauwts to True.

Intents

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 intents keywowd awgument of Client.

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 y invewted 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:

int

classmethod all()[source]

A factowy method that cweates an Intents instance w-w-with evewything e-e-enyabwed.

classmethod none()[source]

A factowy method that cweates an Intents instance with evewything disabwed.

classmethod default()[source]

A factowy method that cweates an Intents instance with evewything e-enyabwed except presences, members, and message_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:

It is highwy advisabwe to weave this intent enyabwed fow youw bot to function.

T-Type:

bool

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:

bool

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:

bool

bans

Awias of moderation.

Changed in vewsion 2.8: Changed to an awias.

Type:

bool

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:

bool

emojis_and_stickers

Awias of expressions.

Nyew in vewsion 2.0.

Changed in vewsion 2.10: Changed t-to an awias.

Type:

bool

emojis

Awias of expressions.

Changed in vewsion 2.0: Changed to a-a-an awias.

Type:

bool

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:

bool

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:

bool

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:

bool

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:

bool

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:

bool

messages

Whethew guiwd and diwect message wewated events awe enyabwed.

This is a-a showtcut to set ow get both guild_messages and dm_messages.

This cowwesponds to the fowwowing events:

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:

Nyote

Intents.message_content is wequiwed to weceive the content of messages.

Type:

bool

guild_messages

Whethew guiwd message wewated events awe enyabwed.

See awso dm_messages fow DMs ow messages fow both.

This cowwesponds to the f-f-fowwowing events:

This awso cowwesponds to the fowwowing attwibutes and cwasses i-in tewms of cache:

Nyote that due to an impwicit wewationship this awso c-cowwesponds to the fowwowing events:

Type:

bool

dm_messages

Whethew diwect message wewated events awe enyabwed.

See awso guild_messages fow guiwds ow messages fow both.

This cowwesponds to the fowwowing events:

This awso cowwesponds to the fowwowing attwibutes and c-c-cwasses in tewms of cache:

Nyote that due to an impwicit wewationship this awso cowwesponds to the fowwowing events:

Type:

bool

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 Message instances:

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 MessageInteraction instances.

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:

bool

reactions

Whethew guiwd and diwect message weaction wewated events awe e-e-enyabwed.

This is a showtcut to s-set ow get both guild_reactions and dm_reactions.

This cowwesponds to the fowwowing events:

This awso cowwesponds to the fowwowing attwibutes and cwasses in tewms of cache:

Type:

bool

guild_reactions

Whethew guiwd weaction wewated events awe e-enyabwed.

See awso dm_reactions fow DMs ow reactions fow both.

This cowwesponds to the fowwowing events:

This awso cowwesponds to t-the fowwowing attwibutes and cwasses in tewms of cache:

Type:

bool

dm_reactions

Whethew diwect message weaction wewated e-e-events awe enyabwed.

See awso guild_reactions fow guiwds ow reactions fow both.

This cowwesponds to the fowwowing events:

This awso cowwesponds to the fowwowing attwibutes and cwasses in tewms of cache:

Type:

bool

typing

Whethew guiwd and diwect message typing wewated events awe enyabwed.

This is a s-s-showtcut to set ow get both guild_typing and dm_typing.

This c-c-cowwesponds to the fowwowing events:

This does nyot cowwespond to any attwibutes ow cwasses in the wibwawy in tewms of cache.

Type:

bool

guild_typing

Whethew guiwd typing wewated events awe enyabwed.

See awso dm_typing fow DMs ow typing fow both.

This cowwesponds to the fowwowing events:

This does nyot cowwespond to any a-attwibutes ow cwasses in the wibwawy in tewms of cache.

Type:

bool

dm_typing

Whethew diwect message typing wewated events awe enyabwed.

See awso guild_typing fow guiwds ow typing fow both.

This cowwesponds to the fowwowing events:

This does nyot cowwespond to any attwibutes ow cwasses in the wibwawy in tewms of cache.

Type:

bool

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:

bool

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:

bool

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:

bool

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_configuration and automod_execution.

This cowwesponds to the fowwowing events:

This does nyot cowwespond to any attwibutes ow cwasses in the wibwawy in tewms of cache.

Type:

bool

polls

Whethew g-g-guiwd and diwect message powws wewated events awe enyabwed.

This is a showtcut to set ow get both guild_polls and dm_polls.

This cowwesponds to the fowwowing events:

Type:

bool

guild_polls

Whethew guiwd powws wewated events awe enyabwed.

Nyew in vewsion 2.10.

This cowwesponds to the fowwowing events:

This awso cowwesponds to the fowwowing attwibutes and cwasses in t-t-tewms of cache:

Type:

bool

dm_polls

Whethew diwect message powws wewated events awe enyabwed.

Nyew in vewsion 2.10.

This cowwesponds to the fowwowing events:

This awso cowwesponds to the fowwowing a-a-attwibutes and c-cwasses in tewms of cache:

Type:

bool

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_flags pawametew in Client.

Due to a quiwk in how Discowd wowks, in owdew to ensuwe pwopew cweanyup of cache wesouwces it is wecommended to have Intents.members enyabwed. 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 y invewted 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:

int

classmethod all()[source]

A f-f-factowy method that cweates a MemberCacheFlags instance with evewything enyabwed.

classmethod none()[source]

A f-factowy method that cweates a MemberCacheFlags instance 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:

bool

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:

bool

classmethod from_intents(intents)[source]

A factowy method that cweates a MemberCacheFlags instance based on the cuwwentwy sewected Intents.

P-Pawametews:

intents (Intents) – The intents to sewect fwom.

Wetuwns:

The wesuwting membew cache fwags.

Wetuwn type:

MemberCacheFlags

Events