如何使用discord bot编辑嵌入颜色不和.py

2024-05-19 01:39:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在研究一个不和谐的机器人。我想知道如何使用edit_消息来更改消息的嵌入颜色。在

这是我的代码:

@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'


Tags: self消息messagetitlebot机器人msgembed
1条回答
网友
1楼 · 发布于 2024-05-19 01:39:52

哪个版本的不和.py你在用吗?你的代码看起来像是为v0.16或更高版本编写的。在

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

await msg.edit(embed=em2)

相关问题 更多 >

    热门问题