0

我希望我的机器人在一段时间后发送一条消息并再次处理它我已经尝试过什么:

@client.command()
async def test(ctx):
    await ctx.send ('content')
    await asyncio.sleep(3)
    await message.edit(content="newcontent")

错误信息:

AttributeError: module 'discord.message' has no attribute 'edit'

我使用以下内容:

  • Python版本:3.7.4
  • discord.py 版本 1.6.0
4

2 回答 2

3

你必须先定义message

@client.command()
async def test(ctx):
    message = await ctx.send("content")
    await asyncio.sleep(3)
    await message.edit(content="newcontent")
于 2021-01-21T16:22:36.957 回答
1

您的代码中有一些错误。ctx.send一:你和你的消息之间有一个空格('content')。您当前的代码:

await ctx.send ('content')

应改为:

await ctx.send('content')

上述内容无需更改,但建议更改。另外,请确保定义message

message = await ctx.send('content')

然后你可以edit留言:

await message.edit('new_content')
于 2021-01-21T17:29:53.467 回答