Discord bot的帮助命令上的类别 [英] Categories on help command for Discord bot

查看:49
本文介绍了Discord bot的帮助命令上的类别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如您所见,类别显示为无类别".如何更改命令的类别?

As you can see, the category says "No category". How can I change the category for a command?

我的代码:

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

推荐答案

如果您不希望为简单的bot添加Cogs如此复杂,则可以重写"No Category"(无类别).通过修改HelpCommand的字符串:https://discordpy.readthedocs.io/zh-CN/latest/ext/commands/api.html#discord.ext.commands.DefaultHelpCommand.no_category

If you don't want the complexity of adding Cogs for a simple bot, you can rewrite the "No Category" string by modifying the HelpCommand: 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
...

这篇关于Discord bot的帮助命令上的类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆