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:
- guild_id¶
The ID of the guild this slash command is enabled in, or
None
if it’s global.- Type:
Optional[
int
]
- 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
None
is returned, it means everyone can use the command by default. If an emptyPermissions
object is returned (that is, all permissions set toFalse
), this means no one can use the command.New in version 2.5.
- Type:
Optional[
Permissions
]
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:
- guild_id¶
The ID of the guild this user command is enabled in, or
None
if it’s global.- Type:
Optional[
int
]
- 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
None
is returned, it means everyone can use the command by default. If an emptyPermissions
object is returned (that is, all permissions set toFalse
), this means no one can use the command.New in version 2.5.
- Type:
Optional[
Permissions
]
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:
- guild_id¶
The ID of the guild this message command is enabled in, or
None
if it’s global.- Type:
Optional[
int
]
- 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
None
is returned, it means everyone can use the command by default. If an emptyPermissions
object is returned (that is, all permissions set toFalse
), this means no one can use the command.New in version 2.5.
- Type:
Optional[
Permissions
]
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
.- Type:
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:
- dm_permission¶
Whether this command can be used in DMs. Defaults to
True
.New in version 2.5.
- Type:
- nsfw¶
Whether this command is age-restricted. Defaults to
False
.New in version 2.8.
- 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
None
is returned, it means everyone can use the command by default. If an emptyPermissions
object is returned (that is, all permissions set toFalse
), this means no one can use the command.New in version 2.5.
- Type:
Optional[
Permissions
]
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:
- dm_permission¶
Whether this command can be used in DMs. Defaults to
True
.New in version 2.5.
- Type:
- nsfw¶
Whether this command is age-restricted. Defaults to
False
.New in version 2.8.
- 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
None
is returned, it means everyone can use the command by default. If an emptyPermissions
object is returned (that is, all permissions set toFalse
), this means no one can use the command.New in version 2.5.
- Type:
Optional[
Permissions
]
UserCommand¶
- class disnake.UserCommand[source]¶
A user context menu command.
- name_localizations¶
Localizations for
name
.New in version 2.5.
- Type:
- dm_permission¶
Whether this command can be used in DMs. Defaults to
True
.New in version 2.5.
- Type:
- nsfw¶
Whether this command is age-restricted. Defaults to
False
.New in version 2.8.
- 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
None
is returned, it means everyone can use the command by default. If an emptyPermissions
object is returned (that is, all permissions set toFalse
), this means no one can use the command.New in version 2.5.
- Type:
Optional[
Permissions
]
MessageCommand¶
- class disnake.MessageCommand[source]¶
A message context menu command
- name_localizations¶
Localizations for
name
.New in version 2.5.
- Type:
- dm_permission¶
Whether this command can be used in DMs. Defaults to
True
.New in version 2.5.
- Type:
- nsfw¶
Whether this command is age-restricted. Defaults to
False
.New in version 2.8.
- 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
None
is returned, it means everyone can use the command by default. If an emptyPermissions
object is returned (that is, all permissions set toFalse
), this means no one can use the command.New in version 2.5.
- Type:
Optional[
Permissions
]
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:
name (Union[
str
,Localized
]) –The option’s name.
Changed in version 2.5: Added support for localizations.
description (Optional[Union[
str
,Localized
]]) –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 (Union[Sequence[
OptionChoice
], Sequence[Union[str
,int
,float
]], Mapping[str
, Union[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_command
or@main_cmd.sub_command_group
decorators.channel_types (List[
ChannelType
]) – The list of channel types that your option supports, if the type isOptionType.channel
. By default, it supports all channel types.autocomplete (
bool
) – Whether this option can be autocompleted.min_value (Union[
int
,float
]) – The minimum value permitted.max_value (Union[
int
,float
]) – The maximum value permitted.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:
List[
OptionChoice
]
- options¶
The list of sub options. Normally you don’t have to specify it directly, instead consider using
@main_cmd.sub_command
or@main_cmd.sub_command_group
decorators.- Type:
List[
Option
]
- 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:
List[
ChannelType
]
- 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¶
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.