【问题标题】:How can I edit an embed color with my discord bot with discord.py如何使用 discord.py 使用我的不和谐机器人编辑嵌入颜色
【发布时间】:2020-04-20 07:54:35
【问题描述】:

我一直在开发一个不和谐的机器人来取乐。我想知道如何使用 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'

【问题讨论】:

    标签: python embed discord discord.py


    【解决方案1】:

    你也试过用“u”来着色,比如:color=0xFF0000

    【讨论】:

    • 这个问题已经有一年多了。所以你不能期待答案。此外,您发布的内容也不是问题的答案。
    【解决方案2】:

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

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

    await msg.edit(embed=em2)

    【讨论】:

    • 我正在使用 discord.py 重写。感谢您的帮助!现在可以了:)
    猜你喜欢
    • 2020-12-15
    • 1970-01-01
    • 2021-04-14
    • 2021-03-28
    • 2017-10-08
    • 2021-01-21
    • 1970-01-01
    • 2021-01-22
    • 2021-10-30
    相关资源
    最近更新 更多