Red uses a subclass of discord.py’s
CommandTree object in order to allow Cog Creators to add application commands to their cogs without worrying about the command count limit and to support caching
AppCommand objects. When an app command is added to the bot’s tree, it will not show up in
tree.get_commands or other similar methods unless the command is “enabled” with
[p]slash enable (similar to “load”ing a cog) and
tree.red_check_enabled has been run since the command was added to the tree.
If you are adding app commands to the tree during load time, the loading process will call
tree.red_check_enabled for your cog and its app commands. If you are adding app commands to the bot outside of load time, a call to
tree.red_check_enabled after adding the commands is required to ensure the commands will appear properly.
If application commands from your cog show up in
[p]slash list as enabled from an
(unknown) cog and disabled from your cog at the same time, you did not follow the instructions above. You must manually call
tree.red_check_enabled after adding the commands to the tree.
- class redbot.core.tree.RedTree(*args, **kwargs)[source]
A container that holds application command information.
Internally does not actually add commands to the tree unless they are enabled with
[p]slash enable, to support Red’s modularity. See
discord.app_commands.CommandTreefor more information.
- add_command(command, /, *args, guild=..., guilds=..., override=False, **kwargs)[source]
Adds an application command to the tree.
Commands will be internally stored until enabled by
- clear_commands(*args, guild, type=None, **kwargs)[source]
Clears all application commands from the tree.
- await on_error(interaction, error, /, *args, **kwargs)[source]
Fallback error handler for app commands.
- await red_check_enabled()[source]
Restructures the commands in this tree, enabling commands that are enabled and disabling commands that are disabled.
After running this function, the tree will be populated with enabled commands only. If commands are manually added to the tree outside of the standard cog loading process, this must be run for them to be usable.
- remove_command(command, /, *args, guild=None, type=<AppCommandType.chat_input: 1>, **kwargs)[source]
Removes an application command from this tree.