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