Skip to content

Modify the help command

Christian Krüger edited this page Mar 11, 2021 · 6 revisions

Plugin Category

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.

String

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.

DefaultCategories

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.MISC for miscellaneous commands that are hard to find a suitable category for.
  • DefaultCategories.MOD for commands that are primarily used by mods.
  • DefaultCategories.ADMIN for commands that are primarily used by bot admins.
  • DefaultCategories.GAMES for games.

HelpCategory

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)
  • name is the category name.
  • description is the category description.
  • order is an instance of help.subsystems.CategoryOrder that roughly determines the sorting order. Possible instances are:
    • CategoryOrder.FIRST
    • CategoryOrder.MIDDLE (default)
    • CategoryOrder.LAST
  • To add your plugin to your newly created HelpCategory, use HelpCategory.add_plugin(plugin).

HelpCategory has the following overridable methods:

  • HelpCategory.send_category_help(self, ctx) is a coroutine that is called when help is 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.

Localization

  • Override the coroutine BasePlugin.command_help(self, ctx, command) to handle a help for your commands command yourself. Raise base.NotFound to resume the default help handling.
  • Override the function BasePlugin.command_help_string(self, command) to return a short help string that is determined at runtime (e.g. for localization). For help purposes, this overrides Command.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). For help purposes, this overrides Command.description.

Manually display help

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.

Clone this wiki locally