简体   繁体   English

如何使用 discord.py 使用我的不和谐机器人编辑嵌入颜色

[英]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.我想知道如何使用 edit_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' discord.ext.commands.errors.CommandInvokeError:命令引发异常:AttributeError:'Bot'对象没有属性'edit_message'

Which version of discord.py are you using?您使用的是哪个版本的 discord.py? Your code looks like it was written for v0.16 or older.您的代码看起来像是为 v0.16 或更早版本编写的。

After v1.0.0 you would use Message.edit()在 v1.0.0 之后,您将使用Message.edit()

await msg.edit(embed=em2)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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