【问题标题】:discord py error while making help command发出帮助命令时出现不和谐 py 错误
【发布时间】:2021-03-30 00:12:37
【问题描述】:

我有这个错误 Expected coroutine function, not 'Command' 该代码用于帮助命令

async def help(ctx, command_name=None):
    reactions = ["⬅️", "➡️"]

    embed = discord.Embed(title="         Help Command",description="Show The Help Command", color=0x87CEEB)
    embed.set_author(name="Gaming Bot", icon_url="https://upload.wikimedia.org/wikipedia/commons/c/c7/Loading_2.gif")
    embed.add_field(name="Member Text Commands", value="Help\nId\nInfo\nPing\nPoll", inline=True)
    embed.add_field(name="Member Voice Commands", value="Join\nDisconnect", inline=True)
    embed.add_field(name="Admin Commands", value="Prefix\nMute\nBan\nUnban\nClear\nKick", inline=False)
    oh_cool = await ctx.send(embed=embed)
    await oh_cool.add_reaction(reactions[0])
    await oh_cool.add_reaction(reactions[1])

【问题讨论】:

  • 能否请您添加完整回溯?
  • Traceback (most recent call last): File "main.py", line 151, in <module> async def help1(ctx, command_name=None): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 506, in decorator return Loop(func, **kwargs) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 76, in __init__ raise TypeError('Expected coroutine function, not {0.__name__!r}.'.format(type(self.coro))) TypeError: Expected coroutine function, not 'Command'
  • 编辑您的问题,不要在 cmets 中发布错误

标签: python discord.py


【解决方案1】:

您不需要添加帮助命令,因为已经有一个。就这样做@bot.command(name='test', help='[help message]') 然后只需执行 !help 即可显示命令和帮助信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-21
    • 1970-01-01
    • 2021-01-06
    • 2019-07-08
    • 1970-01-01
    • 2020-12-18
    相关资源
    最近更新 更多