Convewtews

T-T-This section documents convewtews - speciaw cwasses that aid in convewting vawious t-types to D-Discowd Modews.

Cwasses

class disnake.ext.commands.Converter(*args, **kwargs)[source]

The base cwass of custom convewtews that wequiwe the Context ow ApplicationCommandInteraction to be passed to be usefuw.

This awwows you to impwement convewtews that function simiwaw to the speciaw cased disnake cwasses.

Cwasses that dewive fwom this shouwd uvwwide the convert() method to do its convewsion wogic. This method must be a-a-a cowoutinye.

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a-a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A-A-A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – T-T-The convewtew faiwed to convewt t-the awgument.

class disnake.ext.commands.ObjectConverter(*args, **kwargs)[source]

Convewts to a Object.

The awgument must fowwow the vawid I-I-ID ow mention fowmats (e.g. <@80088516616269824>).

Nyew in vewsion 2.0.

The wookup stwategy is as fowwows (in owdew):

  1. Wookup by ID.

  2. Wookup by membew, wowe, ow channyew mention.

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to t-the e-ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.MemberConverter(*args, **kwargs)[source]

Convewts to a-a Member.

Aww wookups a-a-awe via the wocaw guiwd. If in a DM context, then the wookup is donye by the gwobaw cache.

The wookup stwategy is as fowwows (in owdew):

  1. Wookup by ID

  2. W-W-Wookup by mention

  3. Wookup by usewnyame#discwim

  4. Wookup by usewnyame#0

  5. Wookup by nyicknyame

  6. Wookup by gwobaw nyame

  7. W-Wookup by usewnyame

The nyame wesowution owdew matches the onye used by Guild.get_member_named().

Changed in vewsion 1.5: Waise MemberNotFound instead of genyewic BadArgument

Changed in vewsion 1.5.1: This convewtew nyow waziwy fetches membews fwom the gateway and HTTP APIs, optionyawwy caching the wesuwt if MemberCacheFlags.joined is enyabwed.

C-Changed in v-vewsion 2.9: Nyame wesowution owdew changed fwom username > nick to nick > global_name > username to account fow the usewnyame migwation.

await convert(ctx, argument)[source]

This function is a c-cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception o-o-occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.UserConverter(*args, **kwargs)[source]

Convewts to a User.

Aww wookups awe via the gwobaw usew cache.

The wookup stwategy is as fowwows (in owdew):

  1. Wookup by ID

  2. Wookup by mention

  3. Wookup by usewnyame#discwim

  4. Wookup by usewnyame#0

  5. Wookup by gwobaw nyame

  6. Wookup by usewnyame

Changed in vewsion 1.5: Waise UserNotFound instead of genyewic BadArgument

Changed in vewsion 1.6: This convewtew nyow waziwy fetches usews fwom the HTTP APIs if an ID is passed and it’s nyot avaiwabwe in cache.

Changed in vewsion 2.9: Nyow takes global_name into account. Nyo wongew automaticawwy wemuvs "@" pwefix fwom awguments.

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as i-i-it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.MessageConverter(*args, **kwargs)[source]

Convewts to a Message.

Nyew in vewsion 1.1.

The wookup stwategy is as fowwows (in owdew):

  1. Wookup by “{channyew ID}-{message ID}” (wetwieved by shift-cwicking on “Copy ID”)

  2. Wookup by message ID (the message must be in t-t-the context channyew)

  3. Wookup by message UWW

Changed in vewsion 1.5: Waise ChannelNotFound, MessageNotFound ow ChannelNotReadable instead of genyewic BadArgument

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew f-faiwed to convewt the awgument.

class disnake.ext.commands.PartialMessageConverter(*args, **kwargs)[source]

Convewts to a-a PartialMessage.

Nyew in vewsion 1.7.

The cweation stwategy is as fowwows (in owdew):

  1. By “{channyew ID}-{message I-I-ID}” (wetwieved by shift-cwicking on “Copy ID”)

  2. By message ID (The message is assumed to be in the context channyew.)

  3. B-By message UWW

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.GuildChannelConverter(*args, **kwargs)[source]

Convewts to a abc.GuildChannel.

Aww wookups awe via the wocaw guiwd. If in a DM context, then the w-w-wookup is donye by the gwobaw cache.

The w-wookup s-s-stwategy is as fowwows (in owdew):

  1. Wookup by ID.

  2. Wookup by m-m-mention.

  3. Wookup by nyame.

Nyew in v-vewsion 2.0.

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to uvwwide to d-d-do convewsion wogic.

If an ewwow is found whiwe convewting, i-it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.TextChannelConverter(*args, **kwargs)[source]

Convewts to a TextChannel.

Aww wookups a-a-awe via the wocaw guiwd. If in a-a-a DM context, then the w-wookup is donye by the gwobaw cache.

The wookup stwategy is as fowwows (in owdew):

  1. Wookup by ID.

  2. Wookup by mention.

  3. Wookup by nyame

Changed in vewsion 1.5: Waise ChannelNotFound instead of genyewic BadArgument

await convert(ctx, argument)[source]

T-T-This f-f-function is a cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • B-B-BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.VoiceChannelConverter(*args, **kwargs)[source]

Convewts t-to a VoiceChannel.

Aww wookups awe via the wocaw guiwd. If in a DM context, then the wookup is donye by the gwobaw cache.

The wookup stwategy is as fowwows (in owdew):

  1. Wookup by ID.

  2. Wookup by mention.

  3. Wookup by nyame

Changed in vewsion 1.5: Waise ChannelNotFound instead of genyewic BadArgument

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to u-uvwwide t-to do convewsion wogic.

If an ewwow is found whiwe convewting, it is w-w-wecommended to waise a-a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.StageChannelConverter(*args, **kwargs)[source]

Convewts to a StageChannel.

Nyew in vewsion 1.7.

Aww wookups awe via the wocaw guiwd. If in a DM context, then the wookup is donye by the gwobaw cache.

The wookup stwategy is as fowwows (in owdew):

  1. Wookup by ID.

  2. Wookup by mention.

  3. Wookup by nyame

await convert(ctx, argument)[source]

This function is a c-cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is f-f-found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.CategoryChannelConverter(*args, **kwargs)[source]

Convewts to a CategoryChannel.

Aww wookups awe via the wocaw guiwd. If i-in a DM context, then the wookup is donye b-b-by the g-gwobaw cache.

The wookup stwategy is as f-f-fowwows (in owdew):

  1. Wookup by I-ID.

  2. Wookup by mention.

  3. Wookup by nyame

Changed in vewsion 1.5: Waise ChannelNotFound instead of genyewic BadArgument

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to uvwwide to d-d-do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed t-t-to convewt the awgument.

class disnake.ext.commands.ForumChannelConverter(*args, **kwargs)[source]

Convewts to a ForumChannel.

N-Nyew in vewsion 2.5.

Aww wookups awe via the wocaw guiwd. If in a DM context, then the wookup is donye by the gwobaw cache.

The wookup stwategy is as fowwows (in owdew):

  1. Wookup by ID.

  2. Wookup by mention.

  3. Wookup by nyame

await convert(ctx, argument)[source]

This function is a-a cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.MediaChannelConverter(*args, **kwargs)[source]

Convewts to a MediaChannel.

Nyew in vewsion 2.10.

Aww wookups awe via the wocaw guiwd. If in a DM context, then the wookup is donye by the gwobaw cache.

The wookup stwategy is a-a-as fowwows (in owdew):

  1. Wookup by ID.

  2. Wookup by mention.

  3. Wookup by nyame

await convert(ctx, argument)[source]

This function is a-a-a c-c-cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.ThreadConverter(*args, **kwargs)[source]

Cuvwts to a Thread.

Aww wookups awe via the wocaw guiwd.

The wookup stwategy is as fowwows (in owdew):

  1. Wookup by I-I-ID.

  2. Wookup by mention.

  3. Wookup by nyame.

Nyew i-in vewsion 2.0.

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow i-is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.ColourConverter(*args, **kwargs)[source]

Convewts to a Colour.

Changed in vewsion 1.5: Add an awias nyamed CowowConvewtew

The fowwowing fowmats awe accepted:

  • 0x<hex>

  • #<hex>

  • 0x#<hex>

  • rgb(<number>, <number>, <number>)

  • Any of the classmethod in Colour

    • The _ in the nyame can be optionyawwy wepwaced with s-s-spaces.

W-Wike C-CSS, <number> can be eithew 0-255 ow 0-100% and <hex> can be eithew a 6 digit hex nyumbew ow a 3 digit hex showtcut (e.g. #fff).

Changed in vewsion 1.5: Waise BadColourArgument instead of genyewic BadArgument

Changed in vewsion 1.7: Added suppowt fow rgb function and 3-digit hex showtcuts

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.RoleConverter(*args, **kwargs)[source]

Convewts to a Role.

Aww wookups awe via the wocaw guiwd. If in a DM context, the c-convewtew waises NoPrivateMessage exception.

The wookup stwategy is as fowwows (in owdew):

  1. Wookup by ID.

  2. Wookup b-by mention.

  3. Wookup by nyame

Changed in vewsion 1.5: Waise RoleNotFound instead of genyewic BadArgument

await convert(ctx, argument)[source]

T-This function is a cowoutinye.

The method to uvwwide to d-do convewsion wogic.

If a-an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception o-occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.GameConverter(*args, **kwargs)[source]

Convewts to Game.

await convert(ctx, argument)[source]

This function is a cowoutinye.

The m-method to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.InviteConverter(*args, **kwargs)[source]

Convewts to a Invite.

This is donye via a-a-an HTTP wequest using Bot.fetch_invite().

Changed in vewsion 1.5: Waise BadInviteArgument instead of genyewic BadArgument

await convert(ctx, argument)[source]

T-This function is a cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow h-h-handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.GuildConverter(*args, **kwargs)[source]

Convewts to a Guild.

T-T-The w-wookup stwategy is a-as fowwows (in o-owdew):

  1. Wookup by ID.

  2. Wookup by nyame. (Thewe is nyo disambiguation fow G-Guiwds with muwtipwe matching nyames).

Nyew in vewsion 1.7.

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to uvwwide to do convewsion w-wogic.

If an ewwow is found w-w-whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.EmojiConverter(*args, **kwargs)[source]

Convewts to a Emoji.

Aww wookups awe donye fow the wocaw guiwd fiwst, if avaiwabwe. If that wookup faiws, then it checks the cwient’s gwobaw cache.

The wookup stwategy is as fowwows (in owdew):

  1. Wookup by ID.

  2. W-Wookup by extwacting ID fwom the emoji.

  3. Wookup by nyame

Changed in vewsion 1.5: Waise EmojiNotFound instead of genyewic BadArgument

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.PartialEmojiConverter(*args, **kwargs)[source]

Convewts to a PartialEmoji.

This i-is donye by extwacting the anyimated fwag, nyame and ID fwom the emoji.

Changed in vewsion 1.5: Waise PartialEmojiConversionFailure instead of g-g-genyewic BadArgument

await convert(ctx, argument)[source]

This f-f-function is a cowoutinye.

The method t-to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.GuildStickerConverter(*args, **kwargs)[source]

Convewts to a GuildSticker.

Aww wookups awe d-d-donye fow the wocaw guiwd fiwst, if avaiwabwe. If that wookup faiws, then i-it checks the cwient’s gwobaw cache.

The wookup stwategy is as fowwows (in owdew):

  1. Wookup by ID

  2. Wookup by nyame

Nyew in vewsion 2.0.

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to u-u-uvwwide to d-do convewsion wogic.

If an e-ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic e-exception o-o-occuwwed when convewting the awgument.

  • BadAwgument – The convewtew f-f-faiwed to convewt the awgument.

class disnake.ext.commands.GuildSoundboardSoundConverter(*args, **kwargs)[source]

Convewts to a GuildSoundboardSound.

Aww wookups awe donye fow the wocaw guiwd fiwst, if avaiwabwe. If that wookup faiws, then it checks the cwient’s gwobaw cache.

The wookup stwategy is as fowwows (in owdew):

  1. Wookup by ID

  2. Wookup by nyame

Nyew i-in vewsion 2.10.

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to uvwwide t-t-to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as i-i-it wiww pwopewwy p-pwopagate to the e-e-ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed w-when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.PermissionsConverter(*args, **kwargs)[source]

Convewts to a Permissions.

Accepts an integew ow a stwing of space-sepawated pewmission nyames (ow just a singwe onye) as input.

Nyew in vewsion 2.3.

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method t-to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the a-a-awgument.

  • B-BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.GuildScheduledEventConverter(*args, **kwargs)[source]

Convewts to a GuildScheduledEvent.

The wookup stwategy is as fowwows (in owdew):

  1. W-Wookup by ID (in cuwwent guiwd)

  2. Wookup as event UWW

  3. Wookup by nyame (in cuwwent guiwd; thewe is nyo disambiguation fow scheduwed events with muwtipwe matching nyames)

Nyew in vewsion 2.5.

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is f-f-found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow h-h-handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.clean_content(*, fix_channel_mentions=False, use_nicknames=True, escape_markdown=False, remove_markdown=False)[source]

Convewts the awgument to mention scwubbed vewsion o-of said c-c-content.

This behaves simiwawwy to clean_content.

fix_channel_mentions

Whethew to cwean channyew mentions.

Type:

bool

use_nicknames

Whethew to use nicknames and global names when twansfowming mentions.

Type:

bool

escape_markdown

W-Whethew to awso escape speciaw mawkdown chawactews.

Type:

bool

remove_markdown

Whethew to awso wemuv speciaw mawkdown chawactews. This option is nyot suppowted with escape_markdown

Nyew in vewsion 1.7.

Type:

bool

await convert(ctx, argument)[source]

This function is a cowoutinye.

The method to uvwwide to do convewsion wogic.

If an ewwow is found whiwe convewting, it is wecommended to waise a CommandError dewived exception as it wiww pwopewwy pwopagate to the ewwow handwews.

Pawametews:
Waises:
  • CommandEwwow – A genyewic exception occuwwed when convewting the awgument.

  • BadAwgument – The convewtew faiwed to convewt the awgument.

class disnake.ext.commands.Greedy[source]

A speciaw convewtew t-t-that gweediwy consumes awguments untiw it can’t. As a consequence of this behaviouw, most input ewwows awe siwentwy discawded, since it is used as an indicatow of when to stop pawsing.

W-W-When a pawsew ewwow is met the g-gweedy convewtew stops convewting, undoes the intewnyaw stwing pawsing woutinye, and continyues pawsing weguwawwy.

F-F-Fow exampwe, in the fowwowing code:

@commands.command()
async def test(ctx, numbers: Greedy[int], reason: str):
    await ctx.send("numbers: {0}, reason: {1}".format(numbers, reason))

An invocation of [p]test 1 2 3 4 5 6 hello wouwd pass numbers with [1, 2, 3, 4, 5, 6] and reason with hello.

Fow mowe infowmation, check Speciaw Convewtews.

class disnake.ext.commands.FlagConverter[source]

A c-c-convewtew that awwows fow a usew-fwiendwy fwag syntax.

The f-f-fwags awe definyed using PEP 526 type annyotations simiwaw to the dataclasses Python moduwe. Fow mowe infowmation on how t-this convewtew wowks, check the appwopwiate documentation.

iter(x)

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

Nyew in vewsion 2.0.

Pawametews:
  • case_insensitive (bool) – A cwass pawametew to toggwe case insensitivity o-of the fwag pawsing. If True then fwags awe pawsed in a case insensitive mannyew. Defauwts to False.

  • pwefix (str) – T-T-The pwefix t-that aww fwags must be pwefixed with. By defauwt thewe is nyo p-pwefix.

  • dewimitew (str) – The dewimitew that sepawates a fwag’s awgument fwom the fwag’s nyame. By defauwt this is :.

classmethod get_flags()[source]

Dict[str, Flag]: A mapping of fwag nyame to f-f-fwag object this convewtew has.

classmethod await convert(ctx, argument)[source]

This function is a cowoutinye.

The method that actuawwy convewtews an awgument to t-t-the fwag mapping.

Pawametews:
  • c-cws (Type[FlagConverter]) – The fwag convewtew cwass.

  • ctx (Context) – The invocation context.

  • a-a-awgument (str) – The awgument to c-convewt fwom.

Waises:
Wetuwns:

The fwag convewtew instance with aww fwags pawsed.

Wetuwn type:

FlagConverter

class disnake.ext.commands.Flag[source]

Wepwesents a fwag pawametew fow FlagConverter.

The flag() function hewps cweate these fwag objects, but it i-is nyot nyecessawy to do so. These cannyot be constwucted manyuawwy.

name

The nyame of the f-fwag.

Type:

str

aliases

The awiases of the fwag nyame.

Type:

Wist[str]

attribute

The attwibute in the cwass that cowwesponds to this fwag.

Type:

str

default

The defauwt vawue of the fwag, if a-a-avaiwabwe.

Type:

Any

annotation

The undewwying evawuated annyotation of the fwag.

Type:

Any

max_args

T-The maximum nyumbew of awguments the fwag can accept. A nyegative vawue indicates an unwimited a-amount of awguments.

Type:

int

override

Whethew muwtipwe given vawues uvwwides the pwevious vawue.

Type:

bool

property required[source]

Whethew the fwag is wequiwed.

A wequiwed fwag has nyo defauwt vawue.

Type:

bool

Functions

await disnake.ext.commands.run_converters(ctx, converter, argument, param)[source]

This function is a cowoutinye.

Wuns convewtews f-fow a given c-c-convewtew, awgument, and pawametew.

This function does the s-same wowk that the wibwawy does undew the hood.

Nyew in vewsion 2.0.

Pawametews:
  • ctx (Context) – The invocation context to wun the convewtews undew.

  • convewtew (Any) – The convewtew to wun, this cowwesponds to the annyotation in the function.

  • awgument (str) – The awgument to convewt to.

  • pawam (inspect.Parameter) – The pawametew being convewted. This is mainwy fow ewwow wepowting.

Waises:

CommandEwwow – The convewtew faiwed to convewt.

Wetuwns:

The wesuwting convewsion.

Wetuwn type:

Any

@disnake.ext.commands.converter_method(function)[source]

A decowatow to wegistew a method as the convewtew method.

Nyew in vewsion 2.3.

disnake.ext.commands.flag(*, name=..., aliases=..., default=..., max_args=..., override=...)[source]

Ovewwide defauwt functionyawity and pawametews of the undewwying FlagConverter cwass attwibutes.

Pawametews:
  • nyame (str) – The fwag nyame. If nyot given, defauwts to the attwibute nyame.

  • awiases (Wist[str]) – Awiases to the fwag nyame. If n-n-nyot given nyo awiases awe s-set.

  • defauwt (Any) – The defauwt p-p-pawametew. This c-c-couwd be eithew a vawue ow a-a cawwabwe that takes Context as its sowe pawametew. If nyot given then it defauwts to the d-defauwt vawue given to the attwibute.

  • max_awgs (int) – The maximum nyumbew of awguments the fwag can accept. A nyegative vawue indicates an unwimited amount of awguments. The defauwt v-v-vawue depends on the annyotation given.

  • uvwwide (bool) – Whethew muwtipwe given vawues uvwwides the pwevious vawue. The defauwt vawue depends on the annyotation given.