Coloring
In discord, customization of colors and specific accents is allowed in a limited set of places: Embed accents and ANSI Blocks.
Coloring embeds
Discord requires us to pass a base 10 number when trying to modify any of these, but that’s pretty unintuitive given the RGB standard.
The proposal is instead to write the number in base 16 and prepend each number with a simple 0x
, as shown below.
Alternatively, you could write it out as a string codifying the RGB value you wish to pass.
Coloring messages
Coloring messages in discord can be achieved by using ANSI Code Blocks, for ease of use we recommend using a coloring library, but, if you want a complete tutorial on using ANSI code we cover this further down.
Using a library (Tasai)
There are multiple libraries to help with this process, the ones we recommend are either Tasai
or ansi-colors
, we will be using tasai on our examples.
Making your own helper
Writing your own ANSI helper is rather easy, but, for the sake of simplification we are only going to be going over ESC[n m
for SGR
mode, because its pretty much the only mode discord supports.
We will also be using the following SGR
codes:
30
through37
for foreground colors.40
through47
for background colors.39
and49
as reset codes for said colors.