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

时间:2020-01-01 04:20:57

标签: python embed discord discord.py

我一直在研究一款discord bot,很有趣。我想知道如何使用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:命令引发了 异常:AttributeError:'Bot'对象没有属性 “ edit_message”

2 个答案:

答案 0 :(得分:0)

您使用的是哪个版本的discord.py?您的代码看起来像是为v0.16或更早版本编写的。

在v1.0.0之后,您将使用Message.edit()

await msg.edit(embed=em2)

答案 1 :(得分:-1)

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