如您所见,类别显示“无类别”。
如何更改命令的类别?
我的代码:
@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/