如何使用 discord.py 使用我的 discord 机器人编辑嵌入颜色
How can I edit an embed color with my discord bot with discord.py
我一直在开发一个不和谐的机器人,只是为了好玩。我想知道如何使用 edit_message 来更改消息的嵌入颜色。
这是我的代码:
@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)
当我 运行 命令时,我得到这个错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an
exception: AttributeError: 'Bot' object has no attribute
'edit_message'
您使用的 discord.py 是哪个版本?您的代码看起来像是为 v0.16 或更早版本编写的。
在 v1.0.0 之后您将使用 Message.edit()
await msg.edit(embed=em2)
您是否也尝试过使用“u”的颜色,例如:color=0xFF0000
我一直在开发一个不和谐的机器人,只是为了好玩。我想知道如何使用 edit_message 来更改消息的嵌入颜色。
这是我的代码:
@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)
当我 运行 命令时,我得到这个错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'edit_message'
您使用的 discord.py 是哪个版本?您的代码看起来像是为 v0.16 或更早版本编写的。
在 v1.0.0 之后您将使用 Message.edit()
await msg.edit(embed=em2)
您是否也尝试过使用“u”的颜色,例如:color=0xFF0000