ApplicationCommand
- class discord.ApplicationCommand
Bases:
objectThe base class for application commands
- @error(coro)
A decorator to set an error handler for this command similar to
on_application_command_error()but only for this command- Parameters:
coro (Callable[[
ApplicationCommandInteraction,Exception], Coroutine]) – The coroutine to use as an error handler.- Raises:
TypeError – If the error handler is not a coroutine.
- property cog
The cog associated with this command if any.
- Type:
Optional[
Cog]
- property id
The id of the command, only set if the bot is running
- Type:
Optional[
int]
- property created_at
The creation time of the command in UTC, only set if the bot is running
- Type:
Optional[
datetime]
- property guild_id
Th id this command belongs to, if any
- Type:
Optional[
int]
- await delete()
This function is a coroutine.
Deletes the application command
SlashCommand
- @autocomplete_callback
- asyncdelete
- @error
- class discord.SlashCommand
Bases:
ApplicationCommandRepresents a slash-command.
Note
You should use
discord.Client.slash_command()or in cogsslash_command()decorator by default to create this.- Parameters:
name (
str) – The name of the slash-command. Must be between 1 and 32 characters long and oly contain a-z, _ and -.description (
str) – The description of the command shows up in discord. Between 1 and 100 characters long.default_member_permissions (Optional[Union[
Permissions,int]]) – Permissions that a Member needs by default to execute(see) the command.allow_dm (Optional[
bool]) – Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible.is_nsfw (
bool) –Whether this command is an NSFW command, default
FalseNote
Currently all sub-commands of a command that is marked as NSFW are NSFW too.
options (Optional[List[
SlashCommandOption]]) – A list of max. 25 options for the command. Required options must be listed before optional ones.connector (Optional[Dict[
str,str]]) – A dictionary containing the name of function-parameters as keys and the name of the option as values. Useful for using non-ascii Letters in your option names without getting ide-errors.**kwargs – Keyword arguments used for internal handling.
- @autocomplete_callback(coro)
A decorator that sets a coroutine function as the function that will be called when discord sends an autocomplete interaction for this command.
- Parameters:
coro (Callable[[
AutocompleteInteraction, …], Coroutine]) – The function that should be set asSlashCommand.autocomplete_funcfor this command. Must take the same amount of params the command itself takes.- Raises:
TypeError – The function passed is not a coroutine.
- property mention
Returns a string the client renders as a mention of the command
Note
This requires that the bot is running and the command is cached
- Return type:
The mention of the command
- Raises:
TypeError – The bot is not running and so the id’s not cached
- property cog
The cog the slash command belongs to
- Type:
Optional[
ext.commands.Cog]
- property sub_commands
A list of sub-commands or sub-command groups the command has.
- Type:
List[Union[
SubCommand,SubCommandGroup]
- property options
A
listofSlashCommandOptionthe command has.
- property created_at
The creation time of the command in UTC, only set if the bot is running
- Type:
Optional[
datetime]
- await delete()
This function is a coroutine.
Deletes the application command
- error(coro)
A decorator to set an error handler for this command similar to
on_application_command_error()but only for this command- Parameters:
coro (Callable[[
ApplicationCommandInteraction,Exception], Coroutine]) – The coroutine to use as an error handler.- Raises:
TypeError – If the error handler is not a coroutine.
- property guild_id
Th id this command belongs to, if any
- Type:
Optional[
int]
- property id
The id of the command, only set if the bot is running
- Type:
Optional[
int]
- class discord.SubCommand
Bases:
SlashCommandOption- @autocomplete_callback(coro)
A decorator that sets a coroutine function as the function that will be called when discord sends an autocomplete interaction for this sub-command.
- Parameters:
coro (Callable[[
AutocompleteInteraction, …], Coroutine]) – The function that should be set as autocomplete_func for this command. Must take the same amount of params the sub-command itself takes.- Raises:
TypeError – The function passed is not a coroutine.
- @error(coro)
A decorator to set an error handler for this command similar to
on_application_command_error()but only for this command- Parameters:
coro (Callable[[
ApplicationCommandInteraction,Exception], Coroutine]) – The coroutine to use as an error handler.- Raises:
TypeError – If the error handler is not a coroutine.
- property base_command
Returns the base command of the sub-command
For example if the command is
/a b cor/a cthe base command would bea- Returns:
The base command of the sub-command
- Return type:
- property is_nsfw
Whether this command is nsfw
Note
Currently, any sub command of a base-command that is nsfw will be nsfw too.
- Returns:
Whether this command is nsfw or not
- Return type:
- property mention
Returns a string the client renders as a mention of the command
Note
This requires that the bot is running and the command is cached
- Return type:
The mention of the command
- Raises:
TypeError – The bot is not running and so the id’s not cached
SlashCommandOption
- class discord.SlashCommandOption
Bases:
objectRepresenting an option for a
SlashCommand/SubCommand.- Parameters:
option_type (Union[
OptionType,int,type]) –Could be any of
OptionType’s attributes, an integer between 0 and 10 or atypelikediscord.Member,discord.TextChannelorstr.Note
If the
option_typeis atype, that subclassesGuildChannelthe type of the channel would set as the defaultchannel_types.name (
str) – The 1-32 characters long name of the option shows up in discord. The name must be the same as the one of the parameter for the slash-command or connected usingconnectorofSlashCommand/SubCommandor the method that generates one of these.description (
str) – The 1-100 characters long description of the option shows up in discord.required (Optional[
bool]) – Weather this option must be provided by the user, defaultTrue. IfFalse, the parameter of the slash-command that takes this option needs a default value.choices (Optional[List[Union[
SlashCommandOptionChoice,str,int,float]]]) –A list of up to 25 choices the user could select. Only valid if the
option_typeis one ofstring,integerornumber.Note
If you want to have values that are not the same as their name, you can use
SlashCommandOptionChoiceThe
value’s of the choices must be of theoption_typeof this option (e.g.str,intorfloat). If choices are set they are the only options a user could pass.autocomplete (Optional[
bool]) –Whether to enable autocomplete interactions for this option, default
False. With autocomplete, you can check the user’s input and send matching choices to the client.min_value (Optional[Union[
int,float]]) – If theoption_typeis one ofintegerornumberthis is the minimum value the users input must be of.max_value (Optional[Union[
int,float]]) – If theoption_typeis one ofintegerornumberthis is the maximum value the users input could be of.min_length (Optional[
int]) – If theoption_typeisstring, this is the minimum length (minimum of0, maximum of6000)max_length (Optional[
int]) – If theoption_typeisstring, this is the maximum length (minimum of1, maximum of6000)channel_types (Optional[List[Union[
abc.GuildChannel,ChannelType,int]]]) – A list ofChannelTypeor the type itself likeTextChannelorStageChannelthe user could select. Only valid ifoption_typeischannel.default (Optional[Any]) – The default value that should be passed to the function if the option is not provided, default
None. Usually used for autocomplete callback.converter (Optional[Union[
discord.ext.commands.Greedy,discord.ext.commands.Converter]]) – A subclass ofConverterto use for converting the value. Only valid for option_typestringorintegerignore_conversion_failures (Optional[
bool]) – Whether conversion failures should be ignored and the value should be passed without conversion instead. DefaultFalse
- property autocomplete
Whether to enable autocomplete interactions for this option. With autocomplete, you can check the user’s input and send matching choices to the client.
- property choices
The choices that are set for this option
- Return type:
Optional[List[
SlashCommandOptionChoice]]
- property channel_types
The types of channels that could be selected.
- Return type:
Optional[List[
ChannelType]]
SlashCommandOptionChoice
- class discord.SlashCommandOptionChoice
Bases:
objectA class representing a choice for a
SlashCommandOptionor to use inAutocompleteInteraction.send_choices()- Parameters:
name (Union[
str,int,float]) – The 1-100 characters long name that will show in the client.value (Union[
str,int,float,None]) –The value that will send as the options value. Must be of the type the
SlashCommandOptionis of (str,intorfloat).Note
If this is left empty it takes the
nameas value.name_localizations (Optional[
Localizations]) – Localized names for the choice.
UserCommand
- class discord.UserCommand
Bases:
ApplicationCommandRepresents a user context-menu command
Note
You should use
discord.Client.user_command()or in cogsuser_command()decorator by default to create this.- Parameters:
name (Optional[
str]) – The name of the user-command, default to the functions name. Must be between 1-32 characters long.default_required_permissions (Optional[
Permissions]) – Permissions that a Member needs by default to execute(see) the command.allow_dm (
bool) – Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible.
- property cog
The cog associated with this command if any.
- Type:
Optional[
Cog]
- property created_at
The creation time of the command in UTC, only set if the bot is running
- Type:
Optional[
datetime]
- await delete()
This function is a coroutine.
Deletes the application command
- error(coro)
A decorator to set an error handler for this command similar to
on_application_command_error()but only for this command- Parameters:
coro (Callable[[
ApplicationCommandInteraction,Exception], Coroutine]) – The coroutine to use as an error handler.- Raises:
TypeError – If the error handler is not a coroutine.
- property guild_id
Th id this command belongs to, if any
- Type:
Optional[
int]
- property id
The id of the command, only set if the bot is running
- Type:
Optional[
int]
MessageCommand
- class discord.MessageCommand
Bases:
ApplicationCommandRepresents a message context-menu command
Note
You should use
discord.Client.message_command()or in cogsmessage_command()decorator by default to create this.- Parameters:
name (Optional[
str]) – The name of the message-command, default to the functions name. Must be between 1-32 characters long.default_required_permissions (Optional[
Permissions]) – Permissions that a Member needs by default to execute(see) the command.allow_dm (Optional[
Permissions]) – Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible.
- property cog
The cog associated with this command if any.
- Type:
Optional[
Cog]
- property created_at
The creation time of the command in UTC, only set if the bot is running
- Type:
Optional[
datetime]
- await delete()
This function is a coroutine.
Deletes the application command
- error(coro)
A decorator to set an error handler for this command similar to
on_application_command_error()but only for this command- Parameters:
coro (Callable[[
ApplicationCommandInteraction,Exception], Coroutine]) – The coroutine to use as an error handler.- Raises:
TypeError – If the error handler is not a coroutine.
- property guild_id
Th id this command belongs to, if any
- Type:
Optional[
int]
- property id
The id of the command, only set if the bot is running
- Type:
Optional[
int]
GuildAppCommandPermissions
- class discord.GuildAppCommandPermissions
Bases:
objectRepresents a list of permissions for an application command in a guild.
- permissions
The permissions for the guild’s application commands.
- Type:
List[
AppCommandPermission]
AppCommandPermissions
- class discord.AppCommandPermission
Bases:
objectRepresents a permission for an application command.
- id
The ID of the role, user, or channel.
Note
This can be the guild ID for the default role (
@everyone) or guild ID - 1 for all channels.
Represents a permission for an application command.
- Parameters: