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?

7 Answers

You could also use RGB codes by doing

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

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.

1

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:

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

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)

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()) 

This is not necessary. You do not need to implement your own colour codes as discord.py already does that for you.
The discord.Color class has many built-in colour codes for you to use.
The discord.Color class also provides great methods for you to use such as:
from_hsv, from_rgb, from_str, and to_rgb which allow great customisation for your colors.

docs:
discord.Color discord

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like