我希望我的机器人发送一条消息并在一段时间后再次处理它 我已经尝试过的:
@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'
我使用以下内容:
答案 0 :(得分:3)
您必须先定义 message
。
@client.command()
async def test(ctx):
message = await ctx.send("content")
await asyncio.sleep(3)
await message.edit(content="newcontent")
答案 1 :(得分:1)
您的代码中有一些错误。一:在您的 ctx.send
和您的消息 ('content')
之间有一个空格。您当前的代码:
await ctx.send ('content')
应改为:
await ctx.send('content')
以上不需要更改,尽管建议这样做。另外,请确保定义 message
:
message = await ctx.send('content')
然后您可以edit
消息:
await message.edit('new_content')