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

AttributeError: 'coroutine' object has no attribute 'edit' with discord.py

So I was working on a discord bot, that should edit its own message on a command, and I tried many things, but I kept getting the AttributeError: 'coroutine' object has no attribute 'edit' Error, my code is this:

embed = discord.Embed(title="title")
embed.set_author(name="name", icon_url="image")
embed.add_field(name="name", value="some text", inline=True)
channel = Client.get_channel(channel-id)
msg = channel.fetch_message(message-id)
await msg.edit(embed=embed)

# Also: I've "censored" the ID's

Apperently my error is at await msg.edit(embed=embed) Please help, I have no idea, I’ve searched throught the whole internet and I found nothing really helpful. Thanks

I’ve tried awaiting the msg.edit() function, as you see, but it still isn’t working.

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

>Solution :

channel.fetch_message is the coroutine. If you don’t use await on it, you get the coroutine object, not the ultimate result of the coroutine.

msg = await channel.fetch_message(message_id)
msg.edit(embed=embed)
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