Skip to content

Commit d8c17c3

Browse files
authored
Merge pull request #691 from kkrypt0nn/discord-messages-colors-guide
Added Discord messages with colors guide
2 parents d25d4ed + 128fed6 commit d8c17c3

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: Discord Messages with Colors
3+
description: A guide on how to add colors to your codeblocks on Discord
4+
---
5+
6+
Discord is now slowly rolling out the ability to send colored text within code blocks. This is done using ANSI color codes which is also how you print colored text in your terminal.
7+
8+
To send colored text in a code block you need to first specify the `ansi` language and use the prefixes similar to the one below:
9+
```ansi
10+
\u001b[{format};{color}m
11+
```
12+
*`\u001b` is the unicode escape for ESCAPE/ESC, meant to be used in the source of your bot (see <http://www.unicode-symbol.com/u/001B.html>).* ***If you wish to send colored text without using your bot you need to copy the character from the website.***
13+
14+
After you've written this, you can now type the text you wish to color. If you want to reset the color back to normal, then you need to use the `\u001b[0m` prefix again.
15+
16+
Here is the list of values you can use to replace `{format}`:
17+
18+
* 0: Normal
19+
* 1: **Bold**
20+
* 4: <ins>Underline</ins>
21+
22+
Here is the list of values you can use to replace `{color}`:
23+
24+
*The following values will change the **text** color.*
25+
26+
* 30: Gray
27+
* 31: Red
28+
* 32: Green
29+
* 33: Yellow
30+
* 34: Blue
31+
* 35: Pink
32+
* 36: Cyan
33+
* 37: White
34+
35+
*The following values will change the **text background** color.*
36+
37+
* 40: Firefly dark blue
38+
* 41: Orange
39+
* 42: Marble blue
40+
* 43: Greyish turquoise
41+
* 44: Gray
42+
* 45: Indigo
43+
* 46: Light gray
44+
* 47: White
45+
46+
Let's take an example, I want a bold green colored text with the very dark blue background.
47+
I simply use `\u001b[0;40m` (background color) and `\u001b[1;32m` (text color) as prefix. Note that the order is **important**, first you give the background color and then the text color.
48+
49+
Alternatively you can also directly combine them into a single prefix like the following: `\u001b[1;40;32m` and you can also use multiple values. Something like `\u001b[1;40;4;32m` would underline the text, make it bold, make it green and have a dark blue background.
50+
51+
Raw message:
52+
````nohighlight
53+
```ansi
54+
\u001b[0;40m\u001b[1;32mThat's some cool formatted text right?
55+
or
56+
\u001b[1;40;32mThat's some cool formatted text right?
57+
```
58+
````
59+
60+
Result:
61+
62+
![Background and text color result](/static/images/content/discord_colored_messages/result.png)
63+
64+
The way the colors look like on Discord is shown in the image below:
65+
66+
![ANSI Colors](/static/images/content/discord_colored_messages/ansi-colors.png)
67+
68+
Note: If the change as not been brought to you yet, or other users, then you can use other code blocks in the meantime to get colored text. See **[this gist](https://gist.github.com/matthewzring/9f7bbfd102003963f9be7dbcf7d40e51)**.
42 KB
Loading
13.4 KB
Loading

0 commit comments

Comments
 (0)