python - Discord bot 帮助命令的类别

标签 python discord

/image/Ezv5m.png

如您所见,类别显示“无类别”。
如何更改命令的类别?

我的代码:

@bot.command(pass_context=True)
async def ping(ctx):
    """Pong"""
    await bot.say(":ping_pong: Pong!")
    print ("user has pinged")

最佳答案

如果您不想为简单的机器人添加 Cogs 的复杂性,您可以通过修改 HelpCommand 来重写“No Category”字符串:https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.DefaultHelpCommand.no_category
例如:

...
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
)
结果应如下所示:
This is the bot description

​Commands:
  something Do something
...

关于python - Discord bot 帮助命令的类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50006738/

相关文章:

python - 使用python(robobrowser)下载图片和pdf

python - 当合并的行不匹配时,如何填写 pandas merge 中的值

python - genfromtxt() 中的 NumPy dtype 问题,将字符串读取为 bytestring

javascript - 如何让 Discord 机器人等待我的消息?

javascript - 提及在机器人状态中具有特定角色的用户

python-3.x - Discord.py 删除除 pin 消息之外的所有消息

python - 运行机器人示例代码时,出现此错误

python - 使用队列进行训练与测试

python - openAI DALL-E ModuleNotFoundError

python - 我如何在 Python 中为 discord 机器人创建重新加载命令?