I’m working on a Discord bot using discord.py and I want to customize the help command output. Right now when users type the help command, my bot commands don’t have proper descriptions.
I need to figure out two main things:
How to add descriptions to individual commands so they show up in the help menu
How to organize commands into different categories like Music, Moderation, etc.
I have some experience with programming but I’m pretty new to Python. Here’s a sample of what I’m working with:
For example, if I want my test command to show a description like “Sends a greeting message” in the help menu, where exactly do I put that? Any guidance would be helpful.
Your test command function’s missing the ctx parameter - that’s your syntax error. For descriptions, just add them directly to the command decorator: @bot.command(description='Sends a greeting message'). Here’s the fix:
@bot.command(description='Sends a greeting message')
async def test(ctx):
await ctx.send('Hello world!')
To organize commands into categories, use Cogs. Create separate class files for each category and load them as extensions. Your code stays cleaner and the help command automatically groups related commands. Trust me - I learned this after my main bot file turned into a nightmare with commands everywhere.
quick tip - you can use the description parameter right in the function definition like async def test(ctx, *, description='your desc here'): but most people don’t do it that way. I like the decorator approach better since it’s cleaner. also, don’t forget intents=discord.Intents.default() when you create your bot or you’ll hit permission issues later.
Besides the missing ctx parameter that Neo_Stars mentioned, you can add descriptions using the help parameter in the decorator. Both work fine:
@bot.command(help='Sends a greeting message')
async def test(ctx):
await ctx.send('Hello world!')
For categories without jumping into Cogs right away, use the brief parameter for short descriptions and customize the default help command. I found this easier when starting out since Cogs can be overwhelming at first. You can modify the help command’s appearance by subclassing commands.DefaultHelpCommand and overriding its methods. This gives you control over formatting and grouping without restructuring your entire bot architecture.