【问题标题】:discord.py custom embed command not respondingdiscord.py 自定义嵌入命令没有响应
【发布时间】:2021-06-07 16:35:49
【问题描述】:

我有这个命令,当我说p!customembed [colorID] [title] [description] 时,我不想让它进行自定义嵌入,但它没有响应。有人可以帮忙吗?谢谢。

@client.command()
async def customembed(ctx, color, title, description):
  embed=discord.Embed(title=title, description=description, color=str(color))
  await ctx.channel.send(embed=embed)

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    颜色必须是整数或discord.Colour 的实例,而不是字符串。我不确定您实际上是如何调用命令的,但您可以简单地使用 `ColourConverter

    async def customembed(ctx, color: discord.Colour, title, description):
    

    感谢 typehint,discord.py 已经将颜色转换为 discord.Colour 实例(如果可能),有几种调用命令的方法

    • p!customembed #123321 ... - 十六进制
    • p!customembed 0x123123 ... - 也是十六进制
    • p!customembed rgb(123, 123, 123) ... - RGB
    • p!customembed blue - 颜色名称,注意这应该是discord.Colour的类方法

    【讨论】:

      【解决方案2】:

      您应该从终端发布回溯错误日志。
      但我的猜测是您的 colorID 不适用于嵌入的颜色参数。

      Embed documentation 可以解决您的问题

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-10-15
        • 1970-01-01
        • 2021-02-28
        • 1970-01-01
        • 2021-06-04
        • 1970-01-01
        • 2019-10-23
        相关资源
        最近更新 更多