简体   繁体   中英

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'

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)

您是否也尝试使用“u”进行颜色处理,例如:color=0xFF0000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM