This is going to be a short-ish guide on sub-classing help as ?tag new help
isn't great at explaining things.
- Don't subclass
HelpCommand
unless you're going to override every one of thesend_x
methods, because that class does not do anything (it literally just returns None) DefaultHelpCommand
is for the default help command (the code block one)MinimalHelpCommand
is a minimalistic version of the help command, this is an example of the command produced if you copy?tag new help
HelpCommand
is a completely blank slate and can be subclassed to look any way you want, although most people use them for embeds
The first thing you need with any subclassed help command is an __init__
. For the main examples I will use the HelpCommand
class as it is the one I am most familiar with.
class HelpCommand(commands.HelpCommand):
def __init__(self):
super().__init__(command_attrs={
'help': 'Shows help about the bot, a command, or a category' # This is the command.help string
'cooldown': commands.Cooldown(1, 3.0, commands.BucketType.member), # this is a custom attribute passed to the help command - cooldown
})
This example was taken from R. Danny but should work for any sub-classed help command.
Things you normally get in a cog/command
ctx
- self.context
bot
- self.context.bot
There are methods that you can override in your HelpCommand
: The docs go much more in depth on these methods, I would advise reading these before creating one of the functions
• async def send_bot_help(self, mapping)
- handles the invocation of help with no args
• async def send_cog_help(self, cog):
- sends help for a specific cog
• async def send_group_help(self, group)
- sends help for an individual group
• async def send_command_help(self, command)
- sends help for an individual command
• def get_command_signature(command)
- a method for retrieving the signature (the args) of a command
These aren't to copy, or if you do please try to understand what they do.
• async def send_bot_help(self, mapping)
• async def send_cog_help(self, cog):
If you are ever in any doubt or need help with writing a help command the discord.py server will always be willing to help.