@@ -17,7 +17,7 @@ documentation](https://discord.com/developers/docs/resources/channel#embed-objec
17
17
18
18
{{< callout context="note" title="Note: Custom Commands use Custom Syntax" icon="outline/info-circle" >}}
19
19
20
- Custom Embeds with the ` - customembed` command don't work in custom commands. If you want to know how you can use embeds
20
+ Custom Embeds with the ` customembed ` command don't work in custom commands. If you want to know how you can use embeds
21
21
in custom commands, scroll down to [ Embeds in Custom Commands] ( #embeds-in-custom-commands ) .
22
22
23
23
{{< /callout >}}
@@ -28,56 +28,84 @@ One method of sending an embed with YAGPDB is using the command `customembed` (o
28
28
29
29
### Create embeds by hand
30
30
31
- YAGPDB accepts embeds in JSON following the rules of Discord's [ Embed Object] structure.
31
+ YAGPDB accepts embeds in JSON or YAML following the rules of Discord's [ Embed Object] structure.
32
32
33
- [ Embed Object ] : https://discord.com/developers/docs/resources/message#embed-object.
33
+ [ Embed Object ] : https://discord.com/developers/docs/resources/message#embed-object
34
34
35
- ``` javascript
36
- { " title" : " This is my title" , " description" : " This is my description." }
35
+ ![ An Example of the Custom Embed Command] ( custom_embed_example.png )
36
+
37
+ #### Using YAML
38
+
39
+ ``` yaml
40
+ title : This is my title
41
+ footer :
42
+ text: This is my footer text.
37
43
```
38
44
39
- The output of this would look like the following:
45
+ YAML input is formatted as a list of names with associated values for each part of the embed. In this example I start
46
+ with a name (title) and the associated value (This is my title) after a semicolon. On a new line, we have another name
47
+ (footer), this time with another list of name-value pairs as the value. An indent indicates that the name-value pair
48
+ (text: This is ...) is part of the value of the footer.
40
49
41
- ![ An Example of the Custom Embed Command] ( custom_embed_example.png )
50
+ ##### The syntax of YAML
51
+
52
+ [ YAML] has an intuitive, lenient syntax. Most parts of the embed are simple name-value pairs (or nested name-value
53
+ maps like in the footer shown above). New lines separate each pair, unless the next line is indented to indicate that
54
+ that line is the value. Strings (text) can be included as-is without quotes, unless the text contains special characters
55
+ like ` : ` , in which case single quotes (` ' ` ) or double quotes (` " ` ) may be used. Double quotes allow backslash-escapes to
56
+ add newlines, double quotes, and more.
57
+
58
+ [ YAML ] : https://en.wikipedia.org/wiki/YAML#Syntax
59
+
60
+ #### Using JSON
61
+
62
+ ``` javascript
63
+ { " title" : " This is my title" , " footer" : { " text" : " This is my footer text." } }
64
+ ```
65
+
66
+ As shown in the example above, I start my object (the embed) with a curly brace. Like YAML, we then have a name (title)
67
+ and the value for that name (This is my title). We separate each name-value pair with a comma. Then we have something
68
+ similar, but with another object as the value. Within that object we have a name-value pair with the same format as the
69
+ title, this time for the footer text. In the end we close the objects (footer and embed) with more curly braces.
42
70
43
- Let's break this down: We start of with the customembed command ` -ce ` . After this, I start my object (the embed) with a
44
- curly brace. Then we have the name of the object (title) and the value of it (This is my title). We separate data with
45
- commas. After that we have the same thing again, but for the description. In the end we close the object (embed) with
46
- another curly brace.
71
+ ##### The syntax of JSON
47
72
48
- You can add the multiple objects to this, but keep in mind that Discord limits your message to 2000 characters.
73
+ [ JSON] 's syntax is also quite simple. Objects start with an opening curly brace (` { ` ) and end with a closing curly brace
74
+ (` } ` ). Between these, you can add names and their associated values. Each name-value pair is separated by a comma (` , ` ).
75
+ Around strings (text) you wrap two quotation marks (` "" ` ), but nothing around integers (whole numbers) or booleans
76
+ (` true ` or ` false ` values). You can play around with this a bit.
49
77
50
- #### The syntax of JSON
78
+ Some special characters need to be prefixed with a backslash in strings to indicate that they aren't part of the JSON
79
+ syntax:
51
80
52
- The syntax of json is pretty easy. You start off with a curly brace (` { ` ) and end with a curly brace (` } ` ). Between
53
- this, you can add names and their according values. Data (a name and a value) get separated by commas (` , ` ) . Around
54
- strings (text) you wrap two quotation marks (` "" ` ), but nothing around integers (whole numbers) or booleans (true or
55
- false statements). You can play around with this a bit.
81
+ | Special character | Escaped input |
82
+ | ------------------ | ------------- |
83
+ | Quotation mark (") | \\ " |
84
+ | Backslash (\\ ) | \\\\ |
85
+ | Slash (/) | \\ / |
86
+ | Backspace | \b |
87
+ | Form feed | \f |
88
+ | New line | \n |
89
+ | Carriage return | \r |
90
+ | Horizontal tab | \t |
91
+ | [ Unicode character] | \uXXXX |
56
92
57
- | Special character | Escaped output |
58
- | ------------------ | -------------- |
59
- | Quotation mark (") | \\ " |
60
- | Backslash (\\ ) | \\\\ |
61
- | Slash (/) | \\ / |
62
- | Backspace | \b |
63
- | Form feed | \f |
64
- | New line | \n |
65
- | Carriage return | \r |
66
- | Horizontal tab | \t |
93
+ [ JSON ] : https://en.wikipedia.org/wiki/JSON#Syntax
94
+ [ Unicode character ] : https://en.wikipedia.org/wiki/List_of_Unicode_characters
67
95
68
96
### Create embeds with a generator
69
97
70
98
Creating embeds with a generator can be more difficult if you don't need any difficult features. If you want your embed
71
- to be super shiny, you can use [ this embed generator] ( https://leovoel.github.io/embed-visualizer/ ) . YAGPDB does not use
72
- the first part of its code , so you have to remove the following :
99
+ to be super shiny, you can use [ an embed generator] ( https://leovoel.github.io/embed-visualizer/ ) . The customembed
100
+ command only sends an embed , so you'll need to remove everything around it :
73
101
74
102
```` javascript
75
103
{
76
- " content" : " this `supports` __a__ **subset** *of* ~~markdown~~ 😃 ```js \n function foo(bar) { \n console.log(bar); \n } \n\n foo(1);``` " ,
104
+ " content" : " ... " ,
77
105
" embed" :
78
106
` ` ` `
79
107
80
- and the last curly brace (` }` ). After this you can just copy and paste it into Discord :
108
+ and the last curly brace (` }` ). After this you can copy and paste it after the ` ce ` command :
81
109
82
110
! [Result of the Embed Generator ](embed_generator_result .png )
83
111
0 commit comments