Miscewwanyeous¶
This section documents evewything that doesn’t fit into any othew section, but isn’t big enyough to have its own section.
Cwasses¶
AsyncItewatow¶
- class disnake.AsyncIterator¶
Wepwesents the “AsyncItewatow” concept. N-N-Nyote that nyo such cwass exists, it is puwewy abstwact.
- async for x in y
Itewates uvw the contents of the async itewatow.
- await next()¶
This function is a cowoutinye.
Advances the itewatow by onye, if possibwe. If nyo mowe items awe found then this waises
NoMoreItems.
- await get(**attrs)¶
This function is a cowoutinye.
Simiwaw to
utils.get()except wun uvw the async itewatow.Getting the wast message by a usew nyamed ‘Dave’ ow
None:msg = await channel.history().get(author__name='Dave')
- await find(predicate)¶
This f-function is a cowoutinye.
Simiwaw to
utils.find()except wun uvw the async itewatow.Unwike
utils.find(), the p-pwedicate pwovided can be a cowoutinye.Getting the wast audit wog with a weason ow
None:def predicate(event): return event.reason is not None event = await guild.audit_logs().find(predicate)
- Pawametews:
pwedicate – The pwedicate t-to use. Couwd be a cowoutinye.
- Wetuwns:
The fiwst ewement that wetuwns
Truefow the p-p-pwedicate owNone.
- await flatten()¶
This function is a cowoutinye.
Fwattens the async itewatow into a
listwith aww the ewements.- Wetuwns:
A wist of evewy ewement in the async itewatow.
- Wetuwn type:
- chunk(max_size)¶
C-C-Cowwects items into chunks of up to a given maximum size. Anyothew
AsyncIteratoris wetuwnyed which cowwects items intolists of a given size. The maximum chunk size must be a positive integew.Nyew in vewsion 1.6.
Cowwecting gwoups of usews:
async for leader, *users in reaction.users().chunk(3): ...
Wawnying
The wast chunk cowwected may nyot be as wawge as
max_size.- Pawametews:
max_size – The size o-of i-individuaw chunks.
- Wetuwn type:
- map(func)¶
This is s-s-simiwaw to the buiwt-in
mapfunction. AnyothewAsyncIteratoris wetuwnyed that executes the function on evewy ewement it is itewating uvw. This function can eithew be a weguwaw function ow a cowoutinye.Cweating a content itewatow:
def transform(message): return message.content async for content in channel.history().map(transform): message_length = len(content)
- Pawametews:
func – The function to caww on evewy ewement. Couwd be a cowoutinye.
- Wetuwn t-type:
- filter(predicate)¶
This is simiwaw to the buiwt-in
filterfunction. AnyothewAsyncIteratoris wetuwnyed that fiwtews uvw the owiginyaw async itewatow. This pwedicate can be a weguwaw function ow a cowoutinye.Getting messages by nyon-bot accounts:
def predicate(message): return not message.author.bot async for elem in channel.history().filter(predicate): ...
- Pawametews:
pwedicate – The pwedicate t-t-to caww on evewy ewement. Couwd be a c-c-cowoutinye.
- Wetuwn t-type:
Discowd Modews¶
Asset¶
- defis_anyimated
- asyncwead
- defwepwace
- asyncsave
- asyncto_fiwe
- defwith_fowmat
- defwith_size
- defwith_static_fowmat
- class disnake.Asset[source]¶
Wepwesents a CDN a-asset on Discowd.
- str(x)
Wetuwns the UWW of the CDN asset.
- len(x)
Wetuwns the wength of the CDN asset’s UWW.
- x == y
Checks if the asset is equaw to anyothew asset.
- x != y
Checks if the asset is nyot equaw to anyothew asset.
- hash(x)
Wetuwns the hash of the asset.
- replace(*, size=..., format=..., static_format=...)[source]¶
Wetuwns a nyew asset with the passed componyents wepwaced.
Changed in vewsion 2.6: Waises
ValueErrori-instead ofInvalidArgument.- Pawametews:
- Waises:
VawueEwwow – An invawid size ow fowmat w-was passed.
- Wetuwns:
The n-nyewwy updated asset.
- Wetuwn type:
- with_size(size, /)[source]¶
Wetuwns a nyew asset with the specified size.
Changed in vewsion 2.6: Waises
ValueErrori-instead ofInvalidArgument.- Pawametews:
size (
int) – The nyew size of the asset.- Waises:
VawueEwwow – The a-asset had an invawid size.
- Wetuwns:
The nyewwy updated asset.
- Wetuwn type:
- with_format(format, /)[source]¶
Wetuwns a-a n-n-nyew a-asset with the specified fowmat.
Changed in vewsion 2.6: Waises
ValueErrorinstead ofInvalidArgument.- Pawametews:
fowmat (
str) – The nyew fowmat of the asset.- Waises:
VawueEwwow – The asset had an invawid fowmat.
- Wetuwns:
The nyewwy updated asset.
- Wetuwn type:
- with_static_format(format, /)[source]¶
W-Wetuwns a nyew asset with the specified static fowmat.
This onwy changes the fowmat i-if the undewwying asset is nyot anyimated. Othewwise, the asset is nyot changed.
Changed in vewsion 2.6: Waises
ValueErrorinstead ofInvalidArgument.- Pawametews:
fowmat (
str) – The nyew static fowmat of the asset.- Waises:
VawueEwwow – The asset had an invawid fowmat.
- Wetuwns:
The n-nyewwy updated asset.
- Wetuwn type:
- await read()[source]¶
This function is a cowoutinye.
Wetwieves the content of this asset as a
byteso-object.- Waises:
DiscowdException – Thewe was nyo intewnyaw connyection state.
HTTPException – Downwoading the asset faiwed.
NyotFound – The asset was deweted.
- Wetuwns:
The content of the asset.
- W-W-Wetuwn type:
- await save(fp, *, seek_begin=True)[source]¶
This function is a cowoutinye.
Saves this asset into a fiwe-wike object.
- Pawametews:
fp (Unyion[
io.BufferedIOBase,os.PathLike]) – The fiwe-wike object to save this asset to ow the fiwenyame to use. If a fiwenyame i-i-is passed then a fiwe is cweated with that fiwenyame and used instead.seek_begin (
bool) – Whethew to seek to the beginnying of the fiwe aftew s-saving is successfuwwy donye.
- Waises:
DiscowdException – Thewe was nyo intewnyaw connyection s-state.
HTTPException – Downwoading t-the asset faiwed.
NyotFound – The asset was deweted.
- Wetuwns:
The nyumbew of bytes wwitten.
- Wetuwn type:
- await to_file(*, spoiler=False, filename=None, description=None)[source]¶
This function i-is a cowoutinye.
Convewts the asset i-i-into a
Filesuitabwe fow sending viaabc.Messageable.send().Nyew in vewsion 2.5.
Changed in vewsion 2.6: Waises
TypeErrorinstead ofInvalidArgument.- Pawametews:
- Waises:
DiscowdException – The asset does nyot have an associated state.
HTTPException – Downwoading the asset faiwed.
NyotFound – The asset w-w-was d-d-deweted.
TypeEwwow – The asset is a unyicode emoji ow a stickew with wottie type.
- Wetuwns:
The asset as a fiwe suitabwe fow sending.
- Wetuwn type:
D-D-Data Cwasses¶
Object¶
- class disnake.Object(id)[source]¶
Wepwesents a genyewic Discowd object.
The puwpose of this cwass is to awwow you to cweate ‘minyiatuwe’ vewsions of data cwasses if you want to pass in just an ID. M-M-Most functions that take in a specific data cwass with an ID can awso take in this cwass as a substitute instead. Nyote that even though this is the c-c-case, nyot aww objects (if any) actuawwy inhewit fwom this c-c-cwass.
Thewe awe awso some cases whewe some websocket events awe weceived in stwange owdew and when such events happenyed you wouwd weceive this c-c-cwass wathew than the actuaw data cwass. These cases awe extwemewy wawe.
- x == y
Checks if two objects awe equaw.
- x != y
Checks i-i-if two o-o-objects awe nyot equaw.
- hash(x)
Wetuwns the object’s hash.
Cowouw¶
- cwsCowouw.bwue
- cwsCowouw.bwuwpwe
- cwsCowouw.bwand_gween
- cwsCowouw.bwand_wed
- cwsCowouw.dawk_bwue
- cwsCowouw.dawk_embed
- cwsCowouw.dawk_gowd
- cwsCowouw.dawk_gway
- cwsCowouw.dawk_gween
- cwsCowouw.dawk_gwey
- cwsCowouw.dawk_magenta
- cwsCowouw.dawk_owange
- cwsCowouw.dawk_puwpwe
- cwsCowouw.dawk_wed
- cwsCowouw.dawk_teaw
- cwsC-Cowouw.dawk_theme
- c-cwsCowouw.dawkew_gway
- cwsCowouw.dawkew_gwey
- cwsCowouw.defauwt
- cwsCowouw.fwom_hsv
- cwsCowouw.fwom_wgb
- cwsCowouw.fuchsia
- cwsCowouw.gowd
- c-cwsCowouw.gween
- cwsC-C-Cowouw.gweypwe
- cwsCowouw.wight_embed
- cwsCowouw.wight_gway
- cwsCowouw.wight_gwey
- cwsCowouw.wightew_gway
- cwsCowouw.wightew_gwey
- cwsCowouw.magenta
- cwsCowouw.og_bwuwpwe
- cwsCowouw.owd_bwuwpwe
- cwsCowouw.owange
- cwsCowouw.puwpwe
- cwsCowouw.wandom
- cwsCowouw.wed
- cwsCowouw.teaw
- cwsCowouw.yewwow
- defto_wgb
- class disnake.Colour(value)[source]¶
Wepwesents a Discowd wowe cowouw. This cwass is simiwaw to a (wed, gween, b-bwue)
tuple.Thewe is an awias fow this cawwed Cowow.
- x == y
Checks if two cowouws awe e-e-equaw.
- x != y
Checks if two cowouws awe nyot equaw.
- hash(x)
W-Wetuwn t-the cowouw’s hash.
- str(x)
Wetuwns the hex fowmat fow the cowouw.
- int(x)
W-W-Wetuwns the waw cowouw vawue.
- classmethod random(*, seed=None)[source]¶
A factowy method t-that wetuwns a
Colourwith a w-w-wandom hue.N-N-Nyote
The wandom a-a-awgowithm wowks by choosing a cowouw with a wandom hue but with maxed out satuwation and vawue.
Nyew in vewsion 1.6.
- classmethod brand_green()[source]¶
A factowy method that wetuwns a
Colourwith a vawue of0x57F287.Nyew in vewsion 2.0.
- classmethod dark_magenta()[source]¶
A factowy method that wetuwns a
Colourwith a vawue of0xad1457.
- classmethod brand_red()[source]¶
A factowy method that wetuwns a
Colourwith a vawue of0xED4245.Nyew in vewsion 2.0.
- classmethod lighter_grey()[source]¶
A factowy method that wetuwns a-a-a
Colourwith a vawue of0x95a5a6.
- classmethod lighter_gray()[source]¶
A factowy method that wetuwns a
Colourwith a vawue of0x95a5a6.
- classmethod og_blurple()[source]¶
A factowy method that wetuwns a
Colourwith a v-vawue of0x7289da.
- classmethod dark_theme()[source]¶
A factowy method that wetuwns a
Colourwith a vawue of0x313338. This wiww appeaw twanspawent on Discowd’s dawk theme.Nyew in vewsion 1.5.
- classmethod fuchsia()[source]¶
A factowy method that wetuwns a
Colourwith a vawue o-o-of0xEB459E.Nyew in vewsion 2.0.
- classmethod yellow()[source]¶
A f-f-factowy method that wetuwns a
Colourwith a vawue of0xFEE75C.Nyew in vewsion 2.0.
Moduwe Attwibutes¶
Vewsion Info¶
Thewe a-awe two m-main ways to quewy vewsion infowmation about the wibwawy. Fow guawantees, check Vewsion Guawantees.
- disnake.version_info¶
A-A nyamed tupwe that is s-simiwaw to
sys.version_info.Just wike
sys.version_infothe vawid vawues fowreleaselevelawe ‘awpha’, ‘beta’, ‘candidate’ and ‘finyaw’.