Application Commands¶
This section documents everything related to Discord’s application commands.
Discord Models¶
APISlashCommand¶
- defadd_option
- class disnake.APISlashCommand[source]¶
- A slash command returned by the API. - New in version 2.4. - name_localizations¶
- Localizations for - name.- New in version 2.5. - Type:
 
 - description_localizations¶
- Localizations for - description.- New in version 2.5. - Type:
 
 - nsfw¶
- Whether this command is age-restricted. - New in version 2.8. - Type:
 
 - install_types¶
- The installation types where the command is available. Defaults to - ApplicationInstallTypes.guildonly. Only available for global commands.- New in version 2.10. - Type:
 
 - contexts¶
- The interaction contexts where the command can be used. Only available for global commands. - New in version 2.10. - 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 current list of options, parameters are the same as for - Option
 - property default_member_permissions[source]¶
- The default required member permissions for this command. A member must have all these permissions to be able to invoke the command in a guild. - This is a default value, the set of users/roles that may invoke this command can be overridden by moderators on a guild-specific basis, disregarding this setting. - If - Noneis returned, it means everyone can use the command by default. If an empty- Permissionsobject is returned (that is, all permissions set to- False), this means no one can use the command.- New in version 2.5. - Type:
 
 - property dm_permission[source]¶
- Whether this command can be used in DMs with the bot. - New in version 2.5. - Deprecated since version 2.10: Use - contextsinstead. This is equivalent to the- InteractionContextTypes.bot_dmflag.
 
APIUserCommand¶
- class disnake.APIUserCommand[source]¶
- A user context menu command returned by the API. - New in version 2.4. - name_localizations¶
- Localizations for - name.- New in version 2.5. - Type:
 
 - nsfw¶
- Whether this command is age-restricted. - New in version 2.8. - Type:
 
 - install_types¶
- The installation types where the command is available. Defaults to - ApplicationInstallTypes.guildonly. Only available for global commands.- New in version 2.10. - Type:
 
 - contexts¶
- The interaction contexts where the command can be used. Only available for global commands. - New in version 2.10. - Type:
 
 - property default_member_permissions[source]¶
- The default required member permissions for this command. A member must have all these permissions to be able to invoke the command in a guild. - This is a default value, the set of users/roles that may invoke this command can be overridden by moderators on a guild-specific basis, disregarding this setting. - If - Noneis returned, it means everyone can use the command by default. If an empty- Permissionsobject is returned (that is, all permissions set to- False), this means no one can use the command.- New in version 2.5. - Type:
 
 - property dm_permission[source]¶
- Whether this command can be used in DMs with the bot. - New in version 2.5. - Deprecated since version 2.10: Use - contextsinstead. This is equivalent to the- InteractionContextTypes.bot_dmflag.
 
APIMessageCommand¶
- class disnake.APIMessageCommand[source]¶
- A message context menu command returned by the API. - New in version 2.4. - name_localizations¶
- Localizations for - name.- New in version 2.5. - Type:
 
 - nsfw¶
- Whether this command is age-restricted. - New in version 2.8. - Type:
 
 - install_types¶
- The installation types where the command is available. Defaults to - ApplicationInstallTypes.guildonly. Only available for global commands.- New in version 2.10. - Type:
 
 - contexts¶
- The interaction contexts where the command can be used. Only available for global commands. - New in version 2.10. - Type:
 
 - property default_member_permissions[source]¶
- The default required member permissions for this command. A member must have all these permissions to be able to invoke the command in a guild. - This is a default value, the set of users/roles that may invoke this command can be overridden by moderators on a guild-specific basis, disregarding this setting. - If - Noneis returned, it means everyone can use the command by default. If an empty- Permissionsobject is returned (that is, all permissions set to- False), this means no one can use the command.- New in version 2.5. - Type:
 
 - property dm_permission[source]¶
- Whether this command can be used in DMs with the bot. - New in version 2.5. - Deprecated since version 2.10: Use - contextsinstead. This is equivalent to the- InteractionContextTypes.bot_dmflag.
 
ApplicationCommandPermissions¶
- defis_all_channels
- defis_everyone
GuildApplicationCommandPermissions¶
- class disnake.GuildApplicationCommandPermissions[source]¶
- Represents application command permissions in a guild. - Changed in version 2.5: Can now also represent application-wide permissions that apply to every command by default. - id¶
- The application command’s ID, or the application ID if these are application-wide permissions. - Type:
 
 - permissions¶
- A list of - ApplicationCommandPermissions.
 
Data Classes¶
ApplicationCommand¶
- class disnake.ApplicationCommand[source]¶
- The base class for application commands. - The following classes implement this ABC: - type¶
- The command type - Type:
 
 - name_localizations¶
- Localizations for - name.- New in version 2.5. - Type:
 
 - nsfw¶
- Whether this command is age-restricted. Defaults to - False.- New in version 2.8. - Type:
 
 - install_types¶
- The installation types where the command is available. Defaults to - ApplicationInstallTypes.guildonly. Only available for global commands.- New in version 2.10. - Type:
 
 - contexts¶
- The interaction contexts where the command can be used. Only available for global commands. - New in version 2.10. - Type:
 
 - property default_member_permissions[source]¶
- The default required member permissions for this command. A member must have all these permissions to be able to invoke the command in a guild. - This is a default value, the set of users/roles that may invoke this command can be overridden by moderators on a guild-specific basis, disregarding this setting. - If - Noneis returned, it means everyone can use the command by default. If an empty- Permissionsobject is returned (that is, all permissions set to- False), this means no one can use the command.- New in version 2.5. - Type:
 
 - property dm_permission[source]¶
- Whether this command can be used in DMs with the bot. - New in version 2.5. - Deprecated since version 2.10: Use - contextsinstead. This is equivalent to the- InteractionContextTypes.bot_dmflag.
 
SlashCommand¶
- defadd_option
- class disnake.SlashCommand[source]¶
- The base class for building slash commands. - name_localizations¶
- Localizations for - name.- New in version 2.5. - Type:
 
 - description_localizations¶
- Localizations for - description.- New in version 2.5. - Type:
 
 - nsfw¶
- Whether this command is age-restricted. Defaults to - False.- New in version 2.8. - Type:
 
 - install_types¶
- The installation types where the command is available. Defaults to - ApplicationInstallTypes.guildonly. Only available for global commands.- New in version 2.10. - Type:
 
 - contexts¶
- The interaction contexts where the command can be used. Only available for global commands. - New in version 2.10. - 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 current list of options, parameters are the same as for - Option
 - property default_member_permissions[source]¶
- The default required member permissions for this command. A member must have all these permissions to be able to invoke the command in a guild. - This is a default value, the set of users/roles that may invoke this command can be overridden by moderators on a guild-specific basis, disregarding this setting. - If - Noneis returned, it means everyone can use the command by default. If an empty- Permissionsobject is returned (that is, all permissions set to- False), this means no one can use the command.- New in version 2.5. - Type:
 
 - property dm_permission[source]¶
- Whether this command can be used in DMs with the bot. - New in version 2.5. - Deprecated since version 2.10: Use - contextsinstead. This is equivalent to the- InteractionContextTypes.bot_dmflag.
 
UserCommand¶
- class disnake.UserCommand[source]¶
- A user context menu command. - name_localizations¶
- Localizations for - name.- New in version 2.5. - Type:
 
 - nsfw¶
- Whether this command is age-restricted. Defaults to - False.- New in version 2.8. - Type:
 
 - install_types¶
- The installation types where the command is available. Defaults to - ApplicationInstallTypes.guildonly. Only available for global commands.- New in version 2.10. - Type:
 
 - contexts¶
- The interaction contexts where the command can be used. Only available for global commands. - New in version 2.10. - Type:
 
 - property default_member_permissions[source]¶
- The default required member permissions for this command. A member must have all these permissions to be able to invoke the command in a guild. - This is a default value, the set of users/roles that may invoke this command can be overridden by moderators on a guild-specific basis, disregarding this setting. - If - Noneis returned, it means everyone can use the command by default. If an empty- Permissionsobject is returned (that is, all permissions set to- False), this means no one can use the command.- New in version 2.5. - Type:
 
 - property dm_permission[source]¶
- Whether this command can be used in DMs with the bot. - New in version 2.5. - Deprecated since version 2.10: Use - contextsinstead. This is equivalent to the- InteractionContextTypes.bot_dmflag.
 
MessageCommand¶
- class disnake.MessageCommand[source]¶
- A message context menu command - name_localizations¶
- Localizations for - name.- New in version 2.5. - Type:
 
 - nsfw¶
- Whether this command is age-restricted. Defaults to - False.- New in version 2.8. - Type:
 
 - install_types¶
- The installation types where the command is available. Defaults to - ApplicationInstallTypes.guildonly. Only available for global commands.- New in version 2.10. - Type:
 
 - contexts¶
- The interaction contexts where the command can be used. Only available for global commands. - New in version 2.10. - Type:
 
 - property default_member_permissions[source]¶
- The default required member permissions for this command. A member must have all these permissions to be able to invoke the command in a guild. - This is a default value, the set of users/roles that may invoke this command can be overridden by moderators on a guild-specific basis, disregarding this setting. - If - Noneis returned, it means everyone can use the command by default. If an empty- Permissionsobject is returned (that is, all permissions set to- False), this means no one can use the command.- New in version 2.5. - Type:
 
 - property dm_permission[source]¶
- Whether this command can be used in DMs with the bot. - New in version 2.5. - Deprecated since version 2.10: Use - contextsinstead. This is equivalent to the- InteractionContextTypes.bot_dmflag.
 
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]¶
- Represents a slash command option. - Parameters:
- The option’s name. - Changed in version 2.5: Added support for localizations. 
- description ( - str|- Localized|- None) –- The option’s description. - Changed in version 2.5: Added support for localizations. 
- type ( - OptionType) – The option type, e.g.- OptionType.user.
- required ( - bool) – Whether this option is required.
- choices ( - Sequence[- OptionChoice] |- Sequence[- str|- int|- float] |- Mapping[- str,- str|- int|- float]) – The pre-defined choices for this option.
- options ( - list[- Option]) – The list of sub options. Normally you don’t have to specify it directly, instead consider using- @main_cmd.sub_commandor- @main_cmd.sub_command_groupdecorators.
- channel_types ( - list[- ChannelType]) – The list of channel types that your option supports, if the type is- OptionType.channel. By default, it supports all channel types.
- autocomplete ( - bool) – Whether this option can be autocompleted.
- min_length ( - int) –- The minimum length for this option if this is a string option. - New in version 2.6. 
- max_length ( - int) –- The maximum length for this option if this is a string option. - New in version 2.6. 
 
 - type¶
- The option type, e.g. - OptionType.user.- Type:
 
 - choices¶
- The list of pre-defined choices. - Type:
 
 - options¶
- The list of sub options. Normally you don’t have to specify it directly, instead consider using - @main_cmd.sub_commandor- @main_cmd.sub_command_groupdecorators.
 - channel_types¶
- The list of channel types that your option supports, if the type is - OptionType.channel. By default, it supports all channel types.- Type:
 
 - min_length¶
- The minimum length for this option if this is a string option. - New in version 2.6. - Type:
 
 - max_length¶
- The maximum length for this option if this is a string option. - New in version 2.6. - Type:
 
 - add_choice(name, value)[source]¶
- Adds an OptionChoice to the list of current choices, parameters are the same as for - OptionChoice.
 
OptionChoice¶
ApplicationInstallTypes¶
- class disnake.ApplicationInstallTypes[source]¶
- Represents the location(s) in which an application or application command can be installed. - See the official documentation for more info. - x == y
- Checks if two ApplicationInstallTypes instances are equal. 
 - x != y
- Checks if two ApplicationInstallTypes instances are not equal. 
 - x <= y
- Checks if an ApplicationInstallTypes instance is a subset of another ApplicationInstallTypes instance. 
 - x >= y
- Checks if an ApplicationInstallTypes instance is a superset of another ApplicationInstallTypes instance. 
 - x < y
- Checks if an ApplicationInstallTypes instance is a strict subset of another ApplicationInstallTypes instance. 
 - x > y
- Checks if an ApplicationInstallTypes instance is a strict superset of another ApplicationInstallTypes instance. 
 - x | y, x |= y
- Returns a new ApplicationInstallTypes instance with all enabled flags from both x and y. (Using - |=will update in place).
 - x & y, x &= y
- Returns a new ApplicationInstallTypes instance with only flags enabled on both x and y. (Using - &=will update in place).
 - x ^ y, x ^= y
- Returns a new ApplicationInstallTypes instance with only flags enabled on one of x or y, but not both. (Using - ^=will update in place).
 - ~x
- Returns a new ApplicationInstallTypes instance with all flags from x inverted. 
 - hash(x)
- Returns the flag’s hash. 
 - iter(x)
- Returns an iterator of - (name, value)pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
 - Additionally supported are a few operations on class attributes. - ApplicationInstallTypes.y | ApplicationInstallTypes.z, ApplicationInstallTypes(y=True) | ApplicationInstallTypes.z
- Returns an ApplicationInstallTypes instance with all provided flags enabled. 
 - ~ApplicationInstallTypes.y
- Returns an ApplicationInstallTypes instance with all flags except - yinverted from their default value.
 - New in version 2.10. - value¶
- The raw value. You should query flags via the properties rather than using this raw value. - Type:
 
 - classmethod all()[source]¶
- A factory method that creates an - ApplicationInstallTypesinstance with everything enabled.
 
InteractionContextTypes¶
- class disnake.InteractionContextTypes[source]¶
- Represents the context(s) in which an application command can be used. - See the official documentation for more info. - x == y
- Checks if two InteractionContextTypes instances are equal. 
 - x != y
- Checks if two InteractionContextTypes instances are not equal. 
 - x <= y
- Checks if an InteractionContextTypes instance is a subset of another InteractionContextTypes instance. 
 - x >= y
- Checks if an InteractionContextTypes instance is a superset of another InteractionContextTypes instance. 
 - x < y
- Checks if an InteractionContextTypes instance is a strict subset of another InteractionContextTypes instance. 
 - x > y
- Checks if an InteractionContextTypes instance is a strict superset of another InteractionContextTypes instance. 
 - x | y, x |= y
- Returns a new InteractionContextTypes instance with all enabled flags from both x and y. (Using - |=will update in place).
 - x & y, x &= y
- Returns a new InteractionContextTypes instance with only flags enabled on both x and y. (Using - &=will update in place).
 - x ^ y, x ^= y
- Returns a new InteractionContextTypes instance with only flags enabled on one of x or y, but not both. (Using - ^=will update in place).
 - ~x
- Returns a new InteractionContextTypes instance with all flags from x inverted. 
 - hash(x)
- Returns the flag’s hash. 
 - iter(x)
- Returns an iterator of - (name, value)pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
 - Additionally supported are a few operations on class attributes. - InteractionContextTypes.y | InteractionContextTypes.z, InteractionContextTypes(y=True) | InteractionContextTypes.z
- Returns an InteractionContextTypes instance with all provided flags enabled. 
 - ~InteractionContextTypes.y
- Returns an InteractionContextTypes instance with all flags except - yinverted from their default value.
 - New in version 2.10. - value¶
- The raw value. You should query flags via the properties rather than using this raw value. - Type:
 
 - classmethod all()[source]¶
- A factory method that creates an - InteractionContextTypesinstance with everything enabled.
 
Enumerations¶
OptionType¶
- class disnake.OptionType[source]¶
- Represents the type of an option. - New in version 2.1. - sub_command¶
- Represents a sub command of the main command or group. 
 - sub_command_group¶
- Represents a sub command group of the main command. 
 - string¶
- Represents a string option. 
 - integer¶
- Represents an integer option. 
 - boolean¶
- Represents a boolean option. 
 - user¶
- Represents a user option. 
 - channel¶
- Represents a channel option. 
 - role¶
- Represents a role option. 
 - mentionable¶
- Represents a role + user option. 
 - number¶
- Represents a float option. 
 - attachment¶
- Represents an attachment option. - New in version 2.4.