Ace
Ace

Reputation: 33

How can I edit an embed color with my discord bot with discord.py

I've been working on a discord bot for fun. I was wondering how I could use edit_message to change the embed color of the message.

Here is my code:

@bot.command()
async def test(self):
    """Embed color changing"""
    em1 = discord.Embed(title="Red", colour=0xFF0000)
    msg = await self.message.channel.send(embed=em1)
    em2 = discord.Embed(title="Green", colour=0x00FF00)
    await self.bot.edit_message(msg, embed=em2)

When I run the command I get this error:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'edit_message'

Upvotes: 0

Views: 9100

Answers (2)

also did you try color with the "u" like: color=0xFF0000

Upvotes: -1

Scaarus
Scaarus

Reputation: 81

Which version of discord.py are you using? Your code looks like it was written for v0.16 or older.

After v1.0.0 you would use Message.edit()

await msg.edit(embed=em2)

Upvotes: 3

Related Questions