Natural Power
Natural Power

Reputation: 3

Edit a message in a specific channel in Discord.py

(Discord.py)

I'm trying to make a "Status" message in a dedicated channel, this message will be affected by messages sent in other channels For this I need to select my message in said channel and then edit it

I've been looking around and trying stuff for about an hour now but I can't find anything that works, the closest I got is this:

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

With the error: AttributeError: 'coroutine' object has no attribute 'edit'

I believe I need a different editting command?

( I'm using @client.event and this needs to happen in async def on_message(message): )

Upvotes: 0

Views: 632

Answers (1)

Aditya Tomar
Aditya Tomar

Reputation: 1639

You need to await the fetch_message function based on the docs.

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

Upvotes: 1

Related Questions