discord.py 的颜色代码

Rem*_*ias 6 python discord discord.py discord.py-rewrite

我发现在 discord.py 中改变颜色有点困难和烦人(例如嵌入颜色)。我为 discord.py 中使用的不同颜色代码创建了一个类,该类可以导入到主文件中。

class colors:
    default = 0
    teal = 0x1abc9c
    dark_teal = 0x11806a
    green = 0x2ecc71
    dark_green = 0x1f8b4c
    blue = 0x3498db
    dark_blue = 0x206694
    purple = 0x9b59b6
    dark_purple = 0x71368a
    magenta = 0xe91e63
    dark_magenta = 0xad1457
    gold = 0xf1c40f
    dark_gold = 0xc27c0e
    orange = 0xe67e22
    dark_orange = 0xa84300
    red = 0xe74c3c
    dark_red = 0x992d22
    lighter_grey = 0x95a5a6
    dark_grey = 0x607d8b
    light_grey = 0x979c9f
    darker_grey = 0x546e7a
    blurple = 0x7289da
    greyple = 0x99aab5
Run Code Online (Sandbox Code Playgroud)

例如,colors.red如果需要红色,则可以使用。有没有更好的方法来做到这一点?

小智 6

You could also use RGB codes by doing

embed=discord.Embed(COLOR=discord.Color.from_rgb(RGB code)
Run Code Online (Sandbox Code Playgroud)


MrS*_*aar 4

您已经拥有用于此目的的discord.Colour类(或discord.Color):

from discord import Color

teal = Color.teal()
Run Code Online (Sandbox Code Playgroud)

您甚至可以更改Color为您想要的一切,如下所示:

from discord import Color as c

teal = c.teal()
Run Code Online (Sandbox Code Playgroud)

您可以查看discord.py 文档以获取更多信息。