Search code examples
pythonbotsdiscord

Place the default help command of a Discord bot in a category (Python)


When I used the default help command, it displayed all my commands categorically except for the help command which was under No Category. How do I add this to a cog?


Solution

  • This might not be the best solution, but you can remove the 'help' command, and re-add the 'help' command within your cog, since discord.py does not allow you to change a command's cog_name. The default help command is stored commands.bot._default_help_command.

    from discord.ext import commands
    
    bot = commands.Bot('.')
    bot.remove_command('help')
    
    
    class ACog:
        @commands.command(pass_context=True)
        async def help(self, ctx, *args: str):
            """Shows this message."""
            return await commands.bot._default_help_command(ctx, *args)
    
    
    bot.add_cog(ACog())
    
    bot.run('TKOEN')