'Color codes for discord.py

I found it a bit difficult and annoying to change colors in discord.py (embed color for instance). I made a class for the different color codes to use in discord.py which can be imported into the main file.

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

It is possible to use e.g. colors.red if red color is wanted. Is there any better way to do this?



Solution 1:[1]

You could also use RGB codes by doing

embed=discord.Embed(COLOR=discord.Color.from_rgb(RGB code)

Solution 2:[2]

You already have the discord.Colour class (or discord.Color) for this:

from discord import Color

teal = Color.teal()

You can even change Color to everything you want like so:

from discord import Color as c

teal = c.teal()

You can look at discord.py documentation for more informations.

Solution 3:[3]

If you want to make custom colors you can do that as well. It would be as simple as getting them from RGB or HEX Color codes. Getting them from RGB would be:

import discord
beige = discord.Color.from_rgb(225, 198, 153)

and then for HEX color codes, it would be even simpler (not even needing to import discord) and just:

dark_red = 0x992d22

as you have above. Although you may want to not spend the time searching up the RGB/HEX color codes so discord has a built-in color system. The way you'd use that is by:

import discord
blue = discord.Color.blue()

read more about the color documentation here:

Solution 4:[4]

Discord already give a Color library for it

emeb= discord.Embed(title = "title", description = "description", color = Color.red())

Or try "Color." And then press Ctrl+space for auto complete and it gives you all the available Colors and RGB RGBA formats

Solution 5:[5]

You can easily do it with

discord.Color.Red()

if you want colors from RGB format you can use

discord.Color.from_rgb(000,000,000)

Solution 6:[6]

You can check colors in the docs! Or here is a quick example for colors:

embed = discord.Embed(title="Embed's title", description="Description", color=discord.Color.blue())

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 twg poseidon
Solution 2 MrSpaar
Solution 3 earningjoker430
Solution 4 shreyasm-dev
Solution 5 Rovindu Thamuditha
Solution 6 Erwin