Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Categories on help command for Discord bot

Tags:

python

discord

https://i.stack.imgur.com/Ezv5m.png

As you can see, the category says "No category". How can I change the category for a command?

My code:

@bot.command(pass_context=True)
async def ping(ctx):
    """Pong"""
    await bot.say(":ping_pong: Pong!")
    print ("user has pinged")
like image 352
David Drg Avatar asked Jan 28 '23 05:01

David Drg


1 Answers

If you don't want the complexity of adding Cogs for a simple bot, you can rewrite the "No Category" string by modifying the HelpCommand: https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.DefaultHelpCommand.no_category

For example:

...
from discord.ext import commands
...

# Change only the no_category default string
help_command = commands.DefaultHelpCommand(
    no_category = 'Commands'
)

# Create the bot and pass it the modified help_command
bot = commands.Bot(
    command_prefix = commands.when_mentioned_or('?'),
    description = description,
    help_command = help_command
)

The result should look like:

This is the bot description

​Commands:
  something Do something
...
like image 83
Garrett Guillotte Avatar answered Jan 31 '23 09:01

Garrett Guillotte