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

夙愿已清 提交于 2021-01-28 06:30:51

问题


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?


回答1:


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')


来源:https://stackoverflow.com/questions/51170844/place-the-default-help-command-of-a-discord-bot-in-a-category-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!