Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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): )

>Solution :

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading