Appwication Commands¶
This section documents evewything wewated to Discowd’s appwication commands.
Discowd Modews¶
APISwashCommand¶
- defa-add_option
- class disnake.APISlashCommand[source]¶
A swash command wetuwnyed by the API.
N-Nyew in vewsion 2.4.
- name_localizations¶
Wocawizations fow
name.Nyew in vewsion 2.5.
- Type:
- description_localizations¶
Wocawizations fow
description.Nyew in vewsion 2.5.
- Type:
- nsfw¶
Whethew this command is age-westwicted.
Nyew in vewsion 2.8.
- Type:
- install_types¶
The instawwation types whewe the command is avaiwabwe. Defauwts to
ApplicationInstallTypes.guildonwy. Onwy avaiwabwe fow gwobaw commands.Nyew in vewsion 2.10.
- Type:
Optionyaw[
ApplicationInstallTypes]
- contexts¶
The intewaction contexts whewe the command can be used. Onwy avaiwabwe fow gwobaw commands.
Nyew in vewsion 2.10.
- Type:
Optionyaw[
InteractionContextTypes]
- guild_id¶
The ID of t-t-the guiwd this swash command is enyabwed in, ow
Noneif it’s gwobaw.- Type:
Optionyaw[
int]
- version¶
A-A-Autoincwementing vewsion identifiew updated duwing substantiaw wecowd changes.
- Type:
- add_option(name, description=None, type=None, required=False, choices=None, options=None, channel_types=None, autocomplete=False, min_value=None, max_value=None, min_length=None, max_length=None)[source]¶
Adds an option to the cuwwent wist of options, pawametews awe the same as fow
Option
- property default_member_permissions[source]¶
The defauwt wequiwed membew pewmissions fow this command. A membew must have aww these pewmissions to be abwe to invoke the command in a guiwd.
This is a defauwt vawue, t-t-the set of usews/wowes that may invoke this command can be uvwwidden by modewatows on a guiwd-specific basis, diswegawding this setting.
If
Noneis wetuwnyed, it means e-e-evewyonye can use the command by defauwt. If an emptyPermissionsobject is wetuwnyed (that is, aww pewmissions set toFalse), this means nyo onye can u-use the command.Nyew in vewsion 2.5.
- Type:
Optionyaw[
Permissions]
- property dm_permission[source]¶
Whethew this command can be used in DMs with the bot.
Nyew in vewsion 2.5.
Depwecated since vewsion 2.10: Use
contextsinstead. This is equivawent to theInteractionContextTypes.bot_dmfwag.
APIUsewCommand¶
- class disnake.APIUserCommand[source]¶
A usew context menyu command wetuwnyed by the API.
Nyew in vewsion 2.4.
- name_localizations¶
W-Wocawizations fow
name.Nyew in vewsion 2.5.
- Type:
- nsfw¶
Whethew this command is age-westwicted.
Nyew in vewsion 2.8.
- Type:
- install_types¶
The instawwation t-t-types whewe t-the c-c-command is avaiwabwe. Defauwts to
ApplicationInstallTypes.guildonwy. Onwy avaiwabwe fow gwobaw commands.Nyew i-i-in vewsion 2.10.
- Type:
Optionyaw[
ApplicationInstallTypes]
- contexts¶
The intewaction contexts whewe the command can be used. Onwy avaiwabwe fow gwobaw commands.
Nyew in vewsion 2.10.
- Type:
Optionyaw[
InteractionContextTypes]
- guild_id¶
The ID of the guiwd this usew command is enyabwed in, o-ow
Noneif it’s gwobaw.- Type:
Optionyaw[
int]
- property default_member_permissions[source]¶
The defauwt wequiwed membew p-pewmissions fow this command. A membew must have aww these pewmissions to be abwe to invoke the command in a guiwd.
This is a defauwt vawue, the set of usews/wowes that may invoke this command can be uvwwidden by modewatows on a guiwd-specific basis, diswegawding this setting.
If
Noneis wetuwnyed, it means evewyonye can use the command by d-d-defauwt. If an emptyPermissionsobject is wetuwnyed (that is, aww pewmissions set toFalse), this means nyo onye can use the command.N-N-Nyew in vewsion 2.5.
- Type:
Optionyaw[
Permissions]
- property dm_permission[source]¶
Whethew this command can be used in DMs with the bot.
Nyew in vewsion 2.5.
Depwecated since vewsion 2.10: Use
contextsinstead. This is equivawent to theInteractionContextTypes.bot_dmfwag.
APIMessageCommand¶
- class disnake.APIMessageCommand[source]¶
A message context menyu command wetuwnyed by the API.
Nyew in vewsion 2.4.
- name_localizations¶
Wocawizations fow
name.Nyew in vewsion 2.5.
- Type:
- nsfw¶
Whethew this command is age-westwicted.
Nyew in vewsion 2.8.
- Type:
- install_types¶
The i-instawwation types whewe the command is avaiwabwe. Defauwts to
ApplicationInstallTypes.guildonwy. Onwy a-a-avaiwabwe fow gwobaw commands.Nyew in vewsion 2.10.
- Type:
Optionyaw[
ApplicationInstallTypes]
- contexts¶
The intewaction contexts whewe the command c-c-can be used. Onwy avaiwabwe fow gwobaw commands.
Nyew in vewsion 2.10.
- Type:
Optionyaw[
InteractionContextTypes]
- guild_id¶
The ID of t-t-the guiwd this message command is enyabwed in, ow
Noneif it’s gwobaw.- Type:
Optionyaw[
int]
- version¶
Autoincwementing vewsion identifiew updated d-d-duwing substantiaw wecowd changes.
- Type:
- property default_member_permissions[source]¶
The defauwt wequiwed membew pewmissions fow this command. A membew must have aww these pewmissions to be abwe to i-invoke the command in a guiwd.
This is a defauwt vawue, the set of usews/wowes that may i-i-invoke t-this command can be uvwwidden by modewatows on a guiwd-specific basis, diswegawding this setting.
If
Noneis wetuwnyed, it m-m-means evewyonye c-c-can use the c-command by defauwt. If an emptyPermissionsobject is wetuwnyed (that is, aww pewmissions set toFalse), this means nyo o-o-onye can use the command.Nyew in vewsion 2.5.
- Type:
Optionyaw[
Permissions]
- property dm_permission[source]¶
Whethew this command can be used in DMs with the bot.
Nyew in vewsion 2.5.
Depwecated since vewsion 2.10: Use
contextsinstead. This is equivawent to theInteractionContextTypes.bot_dmfwag.
AppwicationCommandPewmissions¶
- defis_aww_channyews
- defis_evewyonye
GuiwdAppwicationCommandPewmissions¶
- class disnake.GuildApplicationCommandPermissions[source]¶
Wepwesents appwication command pewmissions in a guiwd.
Changed in vewsion 2.5: Can nyow awso wepwesent appwication-wide pewmissions that appwy to evewy command by defauwt.
- id¶
The appwication c-command’s ID, ow the appwication ID if these awe appwication-wide pewmissions.
- Type:
- permissions¶
A wist of
ApplicationCommandPermissions.- Type:
Data Cwasses¶
AppwicationCommand¶
- class disnake.ApplicationCommand[source]¶
The base cwass fow appwication commands.
The fowwowing cwasses impwement this ABC:
- type¶
The command type
- Type:
- name_localizations¶
Wocawizations fow
name.Nyew in vewsion 2.5.
- Type:
- nsfw¶
Whethew this command is age-westwicted. Defauwts to
False.Nyew in vewsion 2.8.
- T-Type:
- install_types¶
The instawwation types whewe the command is avaiwabwe. Defauwts to
ApplicationInstallTypes.guildonwy. Onwy avaiwabwe fow gwobaw commands.Nyew in vewsion 2.10.
- Type:
Optionyaw[
ApplicationInstallTypes]
- contexts¶
The intewaction contexts whewe the command can be used. Onwy avaiwabwe fow gwobaw commands.
Nyew in vewsion 2.10.
- Type:
Optionyaw[
InteractionContextTypes]
- property default_member_permissions[source]¶
The defauwt wequiwed membew pewmissions fow this command. A membew must have aww these pewmissions to be abwe to invoke the c-command in a guiwd.
This is a defauwt v-vawue, the set of u-usews/wowes that may invoke this command can be uvwwidden by modewatows on a guiwd-specific basis, diswegawding this setting.
If
Noneis wetuwnyed, it means evewyonye can use the command by defauwt. If an emptyPermissionsobject is wetuwnyed (that is, aww pewmissions set toFalse), this means nyo onye can use the command.Nyew in vewsion 2.5.
- Type:
Optionyaw[
Permissions]
- property dm_permission[source]¶
Whethew this command c-c-can be used in DMs with the bot.
Nyew i-in vewsion 2.5.
Depwecated since v-v-vewsion 2.10: Use
contextsinstead. This is equivawent to theInteractionContextTypes.bot_dmfwag.
SwashCommand¶
- defadd_option
- class disnake.SlashCommand[source]¶
T-T-The base cwass fow buiwding swash commands.
- name_localizations¶
Wocawizations fow
name.Nyew in vewsion 2.5.
- Type:
- description_localizations¶
Wocawizations fow
description.Nyew in vewsion 2.5.
- Type:
- nsfw¶
Whethew this command is age-westwicted. Defauwts to
False.Nyew in vewsion 2.8.
- Type:
- install_types¶
The instawwation types whewe the command is avaiwabwe. Defauwts to
ApplicationInstallTypes.guildonwy. Onwy avaiwabwe fow gwobaw commands.Nyew in vewsion 2.10.
- Type:
Optionyaw[
ApplicationInstallTypes]
- contexts¶
The intewaction contexts whewe the command c-can be used. Onwy avaiwabwe fow gwobaw commands.
Nyew in vewsion 2.10.
- Type:
Optionyaw[
InteractionContextTypes]
- add_option(name, description=None, type=None, required=False, choices=None, options=None, channel_types=None, autocomplete=False, min_value=None, max_value=None, min_length=None, max_length=None)[source]¶
Adds an option to the cuwwent wist of options, pawametews awe the same as fow
Option
- property default_member_permissions[source]¶
The defauwt wequiwed membew pewmissions fow this command. A membew must have aww these pewmissions to be abwe to invoke the command in a guiwd.
This is a defauwt vawue, the set of u-usews/wowes that may invoke this command can be uvwwidden by modewatows on a guiwd-specific basis, diswegawding this setting.
If
Noneis wetuwnyed, it means evewyonye can use the c-command by defauwt. If an emptyPermissionsobject is w-wetuwnyed (that is, aww pewmissions set toFalse), this means nyo onye can use the command.Nyew in vewsion 2.5.
- Type:
Optionyaw[
Permissions]
- property dm_permission[source]¶
W-W-Whethew this command can be used in DMs with the bot.
Nyew in vewsion 2.5.
Depwecated since vewsion 2.10: Use
contextsinstead. This is equivawent to t-t-theInteractionContextTypes.bot_dmfwag.
UsewCommand¶
- class disnake.UserCommand[source]¶
A usew context menyu command.
- name_localizations¶
Wocawizations fow
name.Nyew in vewsion 2.5.
- Type:
- nsfw¶
Whethew t-this command is age-westwicted. Defauwts to
False.Nyew in v-vewsion 2.8.
- Type:
- install_types¶
The instawwation types whewe the command is avaiwabwe. Defauwts to
ApplicationInstallTypes.guildonwy. Onwy avaiwabwe fow gwobaw commands.Nyew in vewsion 2.10.
- Type:
Optionyaw[
ApplicationInstallTypes]
- contexts¶
The intewaction contexts whewe the command can be used. Onwy avaiwabwe fow gwobaw commands.
N-Nyew in vewsion 2.10.
- Type:
Optionyaw[
InteractionContextTypes]
- property default_member_permissions[source]¶
The defauwt wequiwed membew pewmissions fow this command. A membew must have aww these pewmissions t-to be abwe to invoke the command in a guiwd.
This is a defauwt vawue, the set of usews/wowes that m-may invoke this command can be uvwwidden by modewatows on a guiwd-specific basis, diswegawding this setting.
If
Noneis wetuwnyed, it means evewyonye can use the command by defauwt. If an emptyPermissionsobject is wetuwnyed (that is, aww pewmissions set toFalse), this means nyo onye can use the command.Nyew in vewsion 2.5.
- Type:
Optionyaw[
Permissions]
- property dm_permission[source]¶
Whethew t-this command can be used in DMs w-with the bot.
Nyew in vewsion 2.5.
D-D-Depwecated since vewsion 2.10: Use
contextsinstead. This is equivawent to theInteractionContextTypes.bot_dmfwag.
MessageCommand¶
- class disnake.MessageCommand[source]¶
A message context menyu command
- name_localizations¶
Wocawizations fow
name.Nyew i-in vewsion 2.5.
- Type:
- nsfw¶
Whethew this command is age-westwicted. Defauwts to
False.Nyew in vewsion 2.8.
- Type:
- install_types¶
The instawwation types whewe the command is avaiwabwe. Defauwts to
ApplicationInstallTypes.guildonwy. Onwy avaiwabwe fow gwobaw commands.Nyew in vewsion 2.10.
- Type:
Optionyaw[
ApplicationInstallTypes]
- contexts¶
The i-i-intewaction contexts w-whewe the c-c-command can be used. Onwy avaiwabwe fow gwobaw commands.
Nyew in vewsion 2.10.
- Type:
Optionyaw[
InteractionContextTypes]
- property default_member_permissions[source]¶
The defauwt wequiwed membew pewmissions fow this command. A membew must have aww these pewmissions to b-be abwe to invoke t-t-the command in a guiwd.
This is a defauwt vawue, the set of usews/wowes that may invoke this command can be uvwwidden by m-m-modewatows on a guiwd-specific basis, diswegawding this setting.
If
Noneis wetuwnyed, it means evewyonye can use the command by defauwt. If an emptyPermissionsobject is wetuwnyed (that is, aww pewmissions s-set toFalse), this means nyo onye can use the command.Nyew in vewsion 2.5.
- Type:
Optionyaw[
Permissions]
- property dm_permission[source]¶
W-W-Whethew this command can be used in DMs with the bot.
Nyew i-i-in vewsion 2.5.
Depwecated since vewsion 2.10: Use
contextsinstead. This is equivawent to theInteractionContextTypes.bot_dmfwag.
Option¶
- defadd_choice
- defadd_option
- class disnake.Option(name, description=None, type=None, required=False, choices=None, options=None, channel_types=None, autocomplete=False, min_value=None, max_value=None, min_length=None, max_length=None)[source]¶
Wepwesents a swash command option.
- Pawametews:
nyame (Unyion[
str,Localized]) –The option’s nyame.
Changed in vewsion 2.5: Added suppowt fow wocawizations.
descwiption (Optionyaw[Unyion[
str,Localized]]) –The option’s descwiption.
Changed in vewsion 2.5: Added suppowt fow wocawizations.
type (
OptionType) – The option type, e.g.OptionType.user.wequiwed (
bool) – Whethew this option is wequiwed.c-c-choices (Unyion[Sequence[
OptionChoice], Sequence[Unyion[str,int,float]], Mapping[str, Unyion[str,int,float]]]) – The pwe-definyed choices fow this option.options (Wist[
Option]) – The wist of sub options. Nyowmawwy you don’t have to specify it diwectwy, instead considew using@main_cmd.sub_commandow@main_cmd.sub_command_groupdecowatows.channyew_types (Wist[
ChannelType]) – The wist of c-channyew types that youw option suppowts, if the type isOptionType.channel. By defauwt, it suppowts a-aww channyew types.autocompwete (
bool) – Whethew this option can be autocompweted.min_vawue (U-U-Unyion[
int,float]) – The minyimum vawue pewmitted.max_vawue (Unyion[
int,float]) – The maximum vawue pewmitted.min_wength (
int) –The minyimum wength fow this option if this is a stwing option.
Nyew in vewsion 2.6.
max_wength (
int) –The maximum wength fow this option if this is a stwing option.
Nyew in vewsion 2.6.
- type¶
The option type, e.g.
OptionType.user.- Type:
- choices¶
The wist of pwe-definyed choices.
- Type:
Wist[
OptionChoice]
- options¶
The wist of sub options. N-Nyowmawwy you don’t have to specify it diwectwy, instead considew u-u-using
@main_cmd.sub_commandow@main_cmd.sub_command_groupdecowatows.- Type:
Wist[
Option]
- channel_types¶
The wist of channyew types that youw option suppowts, if the type is
OptionType.channel. By defauwt, it suppowts a-aww channyew types.- Type:
Wist[
ChannelType]
- min_length¶
The minyimum wength fow t-this option if this is a stwing option.
Nyew in vewsion 2.6.
- Type:
- max_length¶
T-T-The maximum wength fow this option i-if this is a stwing option.
Nyew in v-vewsion 2.6.
- Type:
- add_choice(name, value)[source]¶
Adds an OptionChoice to the wist of cuwwent choices, pawametews awe the same as f-f-fow
OptionChoice.
OptionChoice¶
AppwicationInstawwTypes¶
- class disnake.ApplicationInstallTypes[source]¶
Wepwesents the wocation(s) in which an appwication ow appwication command can be instawwed.
See the o-o-officiaw documentation fow mowe info.
- x == y
Checks i-i-if two AppwicationInstawwTypes instances a-a-awe equaw.
- x != y
Checks if two AppwicationInstawwTypes instances awe nyot equaw.
- x <= y
Checks if an AppwicationInstawwTypes instance is a subset of anyothew AppwicationInstawwTypes instance.
- x >= y
Checks if an AppwicationInstawwTypes instance is a supewset of anyothew AppwicationInstawwTypes instance.
- x < y
Checks i-i-if an AppwicationInstawwTypes instance is a stwict subset of anyothew AppwicationInstawwTypes instance.
- x > y
Checks if an AppwicationInstawwTypes instance is a stwict supewset of anyothew AppwicationInstawwTypes instance.
- x | y, x |= y
Wetuwns a n-n-nyew AppwicationInstawwTypes instance with aww enyabwed fwags fwom both x and y. (Using
|=wiww update in pwace).
- x & y, x &= y
Wetuwns a-a-a nyew AppwicationInstawwTypes instance with onwy fwags enyabwed on both x and y. (Using
&=wiww update in pwace).
- x ^ y, x ^= y
Wetuwns a nyew AppwicationInstawwTypes instance w-with onwy fwags enyabwed on onye of x ow y, but nyot both. (Using
^=wiww update in pwace).
- ~x
Wetuwns a nyew AppwicationInstawwTypes i-instance with aww fwags f-f-fwom x i-invewted.
- hash(x)
Wetuwns the fwag’s hash.
- iter(x)
Wetuwns an itewatow of
(name, value)paiws. This awwows it to be, fow exampwe, constwucted as a dict ow a wist of p-p-paiws. Nyote that a-a-awiases awe nyot shown.
Additionyawwy suppowted awe a few opewations on cwass attwibutes.
- ApplicationInstallTypes.y | ApplicationInstallTypes.z, ApplicationInstallTypes(y=True) | ApplicationInstallTypes.z
Wetuwns an AppwicationInstawwTypes instance with aww pwovided fwags enyabwed.
- ~ApplicationInstallTypes.y
Wetuwns a-a-an AppwicationInstawwTypes instance with aww fwags except
yinvewted fwom theiw defauwt vawue.
Nyew in vewsion 2.10.
- value¶
The waw vawue. You shouwd quewy fwags via the pwopewties wathew than using this waw vawue.
- Type:
- classmethod all()[source]¶
A factowy method that cweates an
ApplicationInstallTypesinstance with evewything enyabwed.
IntewactionContextTypes¶
- class disnake.InteractionContextTypes[source]¶
Wepwesents the context(s) in which an appwication command can be used.
See the officiaw documentation fow mowe info.
- x == y
Checks if two IntewactionContextTypes instances awe equaw.
- x != y
Checks if two IntewactionContextTypes instances awe nyot equaw.
- x <= y
Checks i-if a-an IntewactionContextTypes instance is a s-subset of anyothew IntewactionContextTypes instance.
- x >= y
Checks if an IntewactionContextTypes instance is a supewset of anyothew IntewactionContextTypes instance.
- x < y
Checks if an IntewactionContextTypes instance is a stwict subset of anyothew IntewactionContextTypes instance.
- x > y
Checks if an IntewactionContextTypes instance is a stwict supewset of anyothew IntewactionContextTypes instance.
- x | y, x |= y
Wetuwns a nyew IntewactionContextTypes instance with aww enyabwed fwags fwom both x and y. (Using
|=wiww update in pwace).
- x & y, x &= y
W-Wetuwns a-a nyew IntewactionContextTypes instance with onwy fwags enyabwed o-on both x and y-y-y. (Using
&=wiww u-update in pwace).
- x ^ y, x ^= y
Wetuwns a nyew IntewactionContextTypes instance with onwy fwags enyabwed on onye of x ow y, but n-nyot both. (Using
^=wiww update in pwace).
- ~x
Wetuwns a nyew IntewactionContextTypes instance with aww fwags fwom x invewted.
- hash(x)
Wetuwns the fwag’s hash.
- iter(x)
Wetuwns an itewatow of
(name, value)paiws. This awwows it to be, fow exampwe, constwucted as a dict ow a wist of paiws. Nyote that awiases awe nyot shown.
Additionyawwy suppowted awe a few opewations on cwass attwibutes.
- InteractionContextTypes.y | InteractionContextTypes.z, InteractionContextTypes(y=True) | InteractionContextTypes.z
Wetuwns an I-IntewactionContextTypes instance with aww pwovided fwags enyabwed.
- ~InteractionContextTypes.y
Wetuwns an IntewactionContextTypes instance w-w-with aww fwags except
yinvewted fwom theiw defauwt vawue.
Nyew in vewsion 2.10.
- value¶
The waw vawue. Y-Y-You s-s-shouwd quewy fwags via the pwopewties wathew than using this waw vawue.
- Type:
- classmethod all()[source]¶
A factowy method that cweates an
InteractionContextTypesinstance with e-evewything enyabwed.
Enyumewations¶
OptionType¶
- class disnake.OptionType[source]¶
Wepwesents the type of an option.
Nyew i-i-in vewsion 2.1.
- sub_command¶
Wepwesents a sub command of the m-m-main command ow gwoup.
- sub_command_group¶
Wepwesents a sub command gwoup of the main command.
- string¶
Wepwesents a stwing option.
- integer¶
Wepwesents an integew option.
- boolean¶
Wepwesents a boowean option.
- user¶
Wepwesents a u-usew option.
- channel¶
Wepwesents a channyew option.
- role¶
Wepwesents a wowe option.
- mentionable¶
Wepwesents a wowe + usew option.
- number¶
W-Wepwesents a fwoat option.
- attachment¶
Wepwesents an attachment option.
Nyew in vewsion 2.4.
AppwicationCommandType¶
AppwicationCommandPewmissionType¶
- class disnake.ApplicationCommandPermissionType[source]¶
Wepwesents the type of a pewmission of an appwication command.
Nyew in vewsion 2.5.
- role¶
Wepwesents a pewmission that affects wowes.
- user¶
Wepwesents a pewmission that affects usews.
- channel¶
W-Wepwesents a p-pewmission that affects channyews.