Discord.py 重写所有命令的收集列表

Gen*_*erd 5 python discord.py discord.py-rewrite

我试图在重写时获取我的 Discord 机器人中所有命令的列表。我正在使用 Python 3.6 来编写这个

我试图通过这样做来打印命令列表 print(bot.commands) 这只为我提供了以下返回:

{<discord.ext.commands.core.Command object at 0x00000209EE6AD4E0>, <discord.ext.commands.core.Command object at 0x00000209EE6AD470>}

我希望通常的输出是clear(),因为这是迄今为止我在机器人中编程的唯一命令,该命令按预期工作。但它只打印上面的

小智 5

我想你正在寻找这样的东西。

@bot.command(name="help", description="Returns all commands available")
async def help(ctx):
    helptext = "```"
    for command in self.bot.commands:
        helptext+=f"{command}\n"
    helptext+="```"
    await ctx.send(helptext)
Run Code Online (Sandbox Code Playgroud)