【问题标题】:discord bot set embed message color不和谐机器人设置嵌入消息颜色
【发布时间】:2021-04-14 23:32:22
【问题描述】:

所以我写了这个代码来发送嵌入消息,如果你写000000它会使嵌入变为黑色,但如果你写ff0000为红色,它就行不通了,你必须写0xff0000为了让它工作,有没有办法让ff0000在没有0x的情况下工作?这是我的代码:

async def embed(ctx, *, content: str):
    title, description, color = content.split('|')
    embed = discord.Embed(title=title, description=description, color=int(color, 0))
    await ctx.send(embed=embed)

任何帮助将不胜感激。

【问题讨论】:

    标签: discord discord.py embed discord.py-rewrite


    【解决方案1】:

    您可以简单地将颜色 (ff0000) 转换为基数为 16 的 int

    async def embed(ctx, *, content: str):
        title, description, color = content.split("|")
        embed = discord.Embed(title=title, description=description, colour=int(color, 16))
    

    【讨论】:

      猜你喜欢
      • 2018-11-19
      • 2020-12-06
      • 2020-04-21
      • 1970-01-01
      • 2021-12-03
      • 2018-05-02
      • 2020-12-25
      • 2021-05-09
      • 2021-02-19
      相关资源
      最近更新 更多