首页 > 解决方案 > 无法在 Discord 中编辑机器人自己的消息

问题描述

    @client.command()
async def inspire(context):
    wait_msg = await context.send("Finding a quote for ya...")
    await wait_msg.edit(content=inspire())



Error : RuntimeWarning: coroutine 'Command.__call__' was never awaited
  await wait_msg.edit(content=inspire())
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

此方法适用于 @client.event ,但我在 @client.command 上遇到运行时错误,我是机器人开发的新手,所以谁能告诉我如何解决这个问题。

标签: pythondiscorddiscord.py

解决方案


@client.command()
async def inspire(context):
    wait_msg = await context.send("Finding a quote for ya...")
    await wait_msg.edit(content="this is the edit")

当您要求进行编辑时,您必须更改消息的实际属性,这意味着如果您想更改内容,您需要给他一个新的内容来更改。错误的原因是您在无限循环中递归自己,所以这是运行时错误。


推荐阅读