【问题标题】:Unable to edit, bot's own message in Discord无法在 Discord 中编辑机器人自己的消息
【发布时间】:2021-08-18 20:34:36
【问题描述】:
    @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 上遇到运行时错误,我是机器人开发新手,所以谁能告诉我如何解决这个问题。

【问题讨论】:

  • content=inspire()需要改成你要设置的实际内容
  • Joshua Nixon,inspire() 函数返回一个字符串,那不行吗?
  • 它不返回字符串。激发是你的命令功能。确保函数具有唯一的名称

标签: python discord discord.py


【解决方案1】:
@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")

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

【讨论】:

    猜你喜欢
    • 2021-05-24
    • 2020-08-16
    • 2022-11-14
    • 2020-07-29
    • 2021-09-19
    • 1970-01-01
    • 1970-01-01
    • 2019-09-16
    • 2020-08-24
    相关资源
    最近更新 更多