RuntimeWarning:从未等待协程 'Command.__call__'

RuntimeWarning: couroutine 'Command.__call__' was never awaited

我遇到问题的命令:

@bot.command()
async def auction(ctx, starting, items, items2):
    price = starting

    embed1=discord.Embed(title=f'**__Auction Starting!__**', description=f'**{ctx.author}** is starting an auction for **{items} {items2}**.\nThe starting price is **⏣ {starting}**.', color=discord.Color.gold())
    await ctx.send(embed=embed1)
    embed2=discord.Embed(title=f'**__Current Price__**', description=f'The price is currently:\n**⏣ {price}**.', color=discord.Color.gold())
    message1 = await ctx.send(embed=embed2)

    end = False
    while not end:
      try:
        user = await bot.wait_for('message', check=check, timeout=3600)
        bid = int(user.content)
        if int(bid) > 0:
          price += f"{bid}"
          await message1.edit(embed=embed2)
      except asyncio.TimeoutError:
        end = True

错误是:

RuntimeWarning: couroutine 'Command.__call__' was never awaited.
  super().dispatch(event_name, *args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback.

如果需要,这里是完整的代码: https://mystb.in/MechanicsRoommatePhone.python

感谢您的回答!

您的问题很可能出在 check() 函数(您未在此处显示)。

确保将 check() 函数定义为同步函数,而不是 async!

def check(m):

如果你真的需要 check() 作为一个异步函数,你将需要使用类似 asyncio.create_task() (in Python >=3.7) or loop.create_task() (in Python >=3.4.2) or asyncio.ensure_future() 的东西(在 Python >=3.4.4 中)。

请注意 asyncio.create_task()(和其他函数)会立即 return,不会等待任务完成。该任务将在其他地方 安排 到 运行 一个或多个 await 秒后。