/ in a chat.
SlashCommand
A class that implements the protocol for a slash command.Attributes
The name of the command.
The coroutine that is executed when the command is called.
The description for the command.
The ids of the guilds where this command will be registered.
The parameters for this command.
The parent group that this command belongs to.
None if there isn’t one.Whether the command should be restricted to 18+ channels and users. Apps intending to be listed in the App Directory cannot have NSFW commands.
The default permissions a member needs to be able to run the command.
The cog that this command belongs to.
None if there isn’t one.A list of predicates that verifies if the command could be executed with the given ApplicationContext as the sole parameter.
The cooldown applied when the command is invoked.
None if the command doesn’t have a cooldown.The name localizations for this command. The values of this should be
"locale": "name". See Discord’s locales documentation for valid locales.The description localizations for this command. The values should be
"locale": "description".The type of installation this command should be available to. Unapplicable for guild commands.
The location where this command can be used. Cannot be set if this is a guild command.
Properties
Returns a string that allows you to mention the slash command.
Returns
True if this command has a parent.Retrieves the fully qualified command name. For example, in
/one two three the qualified name would be one two three.Retrieves the fully qualified command ID. This is the root parent ID.
Methods
is_on_cooldown()
Checks whether the command is currently on cooldown.The invocation context to use when checking the command’s cooldown status.
bool - A boolean indicating if the command is on cooldown.
reset_cooldown()
Resets the cooldown on this command.The invocation context to reset the cooldown under.
get_cooldown_retry_after()
Retrieves the amount of seconds before this command can be tried again.The invocation context to retrieve the cooldown from.
float - The amount of time left on this command’s cooldown in seconds. If this is 0.0 then the command isn’t on cooldown.
copy()
Creates a copy of this command. Returns:SlashCommand - A new instance of this command.
error()
A decorator that registers a coroutine as a local error handler.The coroutine to register as the local error handler.
before_invoke()
A decorator that registers a coroutine as a pre-invoke hook. A pre-invoke hook is called directly before the command is called.The coroutine to register as the pre-invoke hook.
after_invoke()
A decorator that registers a coroutine as a post-invoke hook. A post-invoke hook is called directly after the command is called.The coroutine to register as the post-invoke hook.
SlashCommandGroup
A class that implements the protocol for a slash command group. Command groups allow you to organize related commands together.Attributes
The name of the command group.
The description for the command group.
The ids of the guilds where this command will be registered.
The parent group that this group belongs to.
None if there isn’t one.Whether the command should be restricted to 18+ channels and users.
The default permissions a member needs to be able to run the command.
A list of predicates that verifies if the command could be executed.
The name localizations for this command. Values should be
"locale": "name".The description localizations for this command.
The type of installation this command should be available to. Unapplicable for guild commands.
The location where this command can be used. Unapplicable for guild commands.
Methods
command()
A shortcut decorator for adding a subcommand to this slash command group.Keyword arguments to pass to the SlashCommand constructor.
Callable[..., SlashCommand] - A decorator that converts the provided function into a SlashCommand.
create_subgroup()
Creates a new subgroup under this slash command group.The name of the group to create.
The description of the group to create.
A list of the IDs of each guild this group should be added to, making it a guild command.
SlashCommandGroup - The slash command group that was created.
subgroup()
A shortcut decorator that initializes the provided subclass of SlashCommandGroup as a subgroup.The name of the group to create. This will resolve to the name of the decorated class if
None is passed.The description of the group to create.
A list of the IDs of each guild this group should be added to.
Callable[[Type[SlashCommandGroup]], SlashCommandGroup]
walk_commands()
An iterator that recursively walks through all slash commands and groups in this group. Yields:SlashCommand | SlashCommandGroup - A nested slash command or slash command group.
slash_command()
Decorator for creating slash commands.The name of the command. Defaults to the function name.
The description of the command. Defaults to the function’s docstring.
A list of guild IDs where this command will be registered. If not provided, the command is global.
The list of options for this command.
The default permissions required to use this command.
Whether the command is age-restricted.
The contexts where this command can be used.
The installation types this command is available for.
Callable[..., SlashCommand] - A decorator that converts the provided method into a SlashCommand.
