本文介绍了将Discord机器人的默认帮助命令放在类别(Python)中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用默认的help命令时,它会分类显示我的所有命令,但 No Category 下的help命令除外.如何将其添加到齿轮?
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?
推荐答案
这可能不是最佳解决方案,但是由于不和谐,您可以删除'help'命令,然后在齿轮中重新添加'help'命令..py不允许您更改命令的 cog_name
.默认的帮助命令存储在 commands.bot._default_help_command
中.
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')
这篇关于将Discord机器人的默认帮助命令放在类别(Python)中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!