在 Discord.py 的特定频道中编辑消息

Edit a message in a specific channel in Discord.py

(Discord.py)

我正在尝试在专用频道中发送“状态”消息,此消息会受到其他频道中发送的消息的影响 为此,我需要在所述频道中 select 我的消息,然后对其进行编辑

我已经环顾四周并尝试了大约一个小时,但我找不到任何有用的东西,我得到的最接近的是:

status_msg = "Placeholder"
status_channel = client.get_channel(channelID)
status_message = status_channel.fetch_message(messageID)
await status_message.edit(content=status_msg)

出现错误:AttributeError: 'coroutine' object has no attribute 'edit'

我想我需要一个不同的编辑命令?

(我正在使用 @client.event,这需要在 async def on_message(message): 中发生)

您需要await基于docsfetch_message函数。

status_msg = "Placeholder"
status_channel = client.get_channel(channelID)
status_message = await status_channel.fetch_message(messageID)
await status_message.edit(content=status_msg)