-
Notifications
You must be signed in to change notification settings - Fork 2
Modify the help command
If the help command is executed without arguments, it displays the available categories. To set the category of your plugin, you need to specify the category at registering time:
bot.register(plugin, category=cat, category_desc=desc)
category can be a string, an instance of subsystems.help.DefaultCategories or an instance of subsystems.help.HelpCategory.
category_desc is a string that is only evaluated if category is a string as well.
If category is passed as a string, it is converted into a simple HelpCategory automatically. If category_desc is passed as well, it is used as the description of the category.
Note: For localization reasons, this method is the most unreliable. Do not use it for category coordination with other plugins.
There are a few default categories. To use one of these, pass an instance of the enum subsystems.help.DefaultCategories.
The default categories are:
-
DefaultCategories.MISCfor miscellaneous commands that are hard to find a suitable category for. -
DefaultCategories.MODfor commands that are primarily used by mods. -
DefaultCategories.ADMINfor commands that are primarily used by bot admins. -
DefaultCategories.GAMESfor games.
The most customizable way to handle the category of your plugin is by using an instance of subsystems.help.HelpCategory. The signature is as follows:
HelpCategory(name, description=str, order=CategoryOrder)-
nameis the category name. -
descriptionis the category description. -
orderis an instance ofhelp.subsystems.CategoryOrderthat roughly determines the sorting order. Possible instances are:CategoryOrder.FIRST-
CategoryOrder.MIDDLE(default) CategoryOrder.LAST
- To add your plugin to your newly created
HelpCategory, useHelpCategory.add_plugin(plugin).
HelpCategory has the following overridable methods:
-
HelpCategory.send_category_help(self, ctx)is a coroutine that is called whenhelpis requested for this category. You can override it to handle this yourself. -
HelpCategory.format_commands(self)is a function that returns a list of lines that denote the available commands in this category.
- Override the coroutine
BasePlugin.command_help(self, ctx, command)to handle ahelpfor your commands command yourself. Raisebase.NotFoundto resume the defaulthelphandling. - Override the function
BasePlugin.command_help_string(self, command)to return a short help string that is determined at runtime (e.g. for localization). Forhelppurposes, this overridesCommand.help. - Override the function
BasePlugin.command_description_string(self, command)to return a detailed description string that is determined at runtime (e.g. for localization). Forhelppurposes, this overridesCommand.description.
To display the help message for a command manually (e.g. if the usage was incorrect), use
await self.bot.helpsys.cmd_help(ctx, self, ctx.command)
from within your command.