-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildembed.tag
348 lines (281 loc) · 11.8 KB
/
buildembed.tag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
{=(COMMENT):User Settings}
{=(prefix):!}
{=(tagName):buildembed|be}
{=(offsetFromUTC):0}
{=(example):{prefix}{tagName} title:My title|desc:My description|thumb:https://i.imgur.com/0l0ZBCm.png|footer:My footer|color:blurple}
{=(defaultColor):2f3136}
{=(defaultFooter):{prefix}{tagName} title:My title|desc:My description|color:red}
{=(defaultFooter):{example}}
{=(COMMENT):Only the roles specified in there (separated by a comma) will be able to use that command. Leave empty if you don't mind.}
{=(requiredRoles):}
{=(COMMENT):The error message to output to the user when they don't have the required role. Leaving it empty will react to the user's message with the :warning: emoji, and leaving a space " " character won't return an error message at all}
{=(requiredRolesErrorMessage): }
{=(COMMENT):Adding or subtracting (depending on if the offset is positive or negative) the offset from UTC specified above to the current unix time.}
{=(unixTimezone):{m:trunc({unix}+({offsetFromUTC}*3600))}}
{=(defaultTime):{strf({unixTimezone}):%FT%T.000Z}}
{=(delimiter):|}
{=(r):replace}
{=(i):index}
{=(l):lower}
{=(j):join}
{=(ct):contains}
{=(fb):None}
{=(del):{delimiter}}
{=(pl):%&$}
{=(uav):{user(avatar)}}
{=(sic):{server(icon)}}
{=(COMMENT):Curly brace snippet}
{=( ):{ }}
{=(b):{ (1)}}
{=(d):{ (2)}}
{=(emojiPrefix):<emoji}
{=(isAChannelSpecified):{in(true true):{in(<#):{1}} {in(>):{1}}}}
{=(channelToSend):{{r}(false,{channel(id)}):{{r}(true,{1}):{isAChannelSpecified}}}}
{=(COMMENT):Separating arguments into their own list variables. Replaces the delimiter with ~ in the process.}
{=(sanitizedArgs):{{r}({emojiPrefix},<:emoji:):{{r}(",\"):{args}}}}
{=(argumentToParse):{{if({isAChannelSpecified}==true):sanitizedArgs(2+)|sanitizedArgs}}}
{=(jargs):{{r}({del},~):!~{argumentToParse}}}
{=(a1):{list(1):{jargs}}}
{=(a2):{list(2):{jargs}}}
{=(a3):{list(3):{jargs}}}
{=(a4):{list(4):{jargs}}}
{=(a5):{list(5):{jargs}}}
{=(a6):{list(6):{jargs}}}
{=(a7):{list(7):{jargs}}}
{=(a8):{list(8):{jargs}}}
{=(a9):{list(9):{jargs}}}
{=(a10):{list(10):{jargs}}}
{=(a11):{list(11):{jargs}}}
{=(a12):{list(12):{jargs}}}
{=(fieldsName):image title titleurl name nameicon nicon nameurl nurl color colour clr description thumbnail footer footericon ficon timestamp {fb} !}
{=(COMMENT):Processes a substring matching on the keyword/field name of every argument up to the 12th and returns it.}
{=(COMMENT):Raw argument word, substring matched word, and then word content}
{=(w1):{{l}:{a1(1)::}}}
{=(word1):{fieldsName({{i}({w1}):{{r}({w1},. {w1} .):{fieldsName}}})}}
{=(content1):{a1(2+)::}}
{=(w2):{{l}:{a2(1)::}}}
{=(word2):{fieldsName({{i}({w2}):{{r}({w2},. {w2} .):{fieldsName}}})}}
{=(content2):{a2(2+)::}}
{=(w3):{{l}:{a3(1)::}}}
{=(word3):{fieldsName({{i}({w3}):{{r}({w3},. {w3} .):{fieldsName}}})}}
{=(content3):{a3(2+)::}}
{=(w4):{{l}:{a4(1)::}}}
{=(word4):{fieldsName({{i}({w4}):{{r}({w4},. {w4} .):{fieldsName}}})}}
{=(content4):{a4(2+)::}}
{=(w5):{{l}:{a5(1)::}}}
{=(word5):{fieldsName({{i}({w5}):{{r}({w5},. {w5} .):{fieldsName}}})}}
{=(content5):{a5(2+)::}}
{=(w6):{{l}:{a6(1)::}}}
{=(word6):{fieldsName({{i}({w6}):{{r}({w6},. {w6} .):{fieldsName}}})}}
{=(content6):{a6(2+)::}}
{=(w7):{{l}:{a7(1)::}}}
{=(word7):{fieldsName({{i}({w7}):{{r}({w7},. {w7} .):{fieldsName}}})}}
{=(content7):{a7(2+)::}}
{=(w8):{{l}:{a8(1)::}}}
{=(word8):{fieldsName({{i}({w8}):{{r}({w8},. {w8} .):{fieldsName}}})}}
{=(content8):{a8(2+)::}}
{=(w9):{{l}:{a9(1)::}}}
{=(word9):{fieldsName({{i}({w9}):{{r}({w9},. {w9} .):{fieldsName}}})}}
{=(content9):{a9(2+)::}}
{=(w10):{{l}:{a10(1)::}}}
{=(word10):{fieldsName({{i}({w10}):{{r}({w10},. {w10} .):{fieldsName}}})}}
{=(content10):{a10(2+)::}}
{=(w11):{{l}:{a11(1)::}}}
{=(word11):{fieldsName({{i}({w11}):{{r}({w11},. {w11} .):{fieldsName}}})}}
{=(content11):{a11(2+)::}}
{=(w12):{{l}:{a12(1)::}}}
{=(word12):{fieldsName({{i}({w12}):{{r}({w12},. {w12} .):{fieldsName}}})}}
{=(content12):{a12(2+)::}}
{=(COMMENT):Fields variables from input. This is where we call our default values as their content if any.}
{=(COMMENT):Order of the variables assignments in the same order as the embed builder.}
{=(f.name):}
{=(f.nameicon):}
{=(f.nameurl):}
{=(f.title):}
{=(f.titleurl):}
{=(f.description):}
{=(f.image):}
{=(f.thumbnail):}
{=(f.footer):}
{=(f.footericon):}
{=(f.timestamp):}
{=(f.color):{defaultColor}}
{=(f.{word1}):{content1}}
{=(f.{word2}):{content2}}
{=(f.{word3}):{content3}}
{=(f.{word4}):{content4}}
{=(f.{word5}):{content5}}
{=(f.{word6}):{content6}}
{=(f.{word7}):{content7}}
{=(f.{word8}):{content8}}
{=(f.{word9}):{content9}}
{=(f.{word10}):{content10}}
{=(f.{word11}):{content11}}
{=(f.{word12}):{content12}}
{=(COMMENT):Allowing the word "now" to be used for the "timestamp" field.}
{=(f.timestamp):{if({{l}:{f.timestamp}}==now):{{r}(now,{defaultTime}):{{l}:{f.timestamp}}}}}
{=(COMMENT):Although I'm allowing "self" and other keywords for user color, this is allowing the custom user color TagScript block to work beforehand.}
{=(f.color):{{r}({b}user(color){d},{user(color)}):{{j}():{f.color}}}}
{=(COMMENT):Allowing custom blocks like user avatar and server icon to be used in image fields as arguments.}
{=(f.image):{{r}({b}icon{d},{sic}):{{r}({b}server(icon){d},{b}icon{d}):{{r}({b}avatar{d},{uav}):{{r}({b}user(avatar){d},{b}avatar{d}):{f.image}}}}}}
{=(f.nameicon):{{r}({b}icon{d},{sic}):{{r}({b}server(icon){d},{b}icon{d}):{{r}({b}avatar{d},{uav}):{{r}({b}user(avatar){d},{b}avatar{d}):{f.nameicon}}}}}}
{=(f.nicon):{{r}({b}icon{d},{sic}):{{r}({b}server(icon){d},{b}icon{d}):{{r}({b}avatar{d},{uav}):{{r}({b}user(avatar){d},{b}avatar{d}):{f.nico}}}}}}
{=(f.thumbnail):{{r}({b}icon{d},{sic}):{{r}({b}server(icon){d},{b}icon{d}):{{r}({b}avatar{d},{uav}):{{r}({b}user(avatar){d},{b}avatar{d}):{f.thumbnail}}}}}}
{=(f.footericon):{{r}({b}icon{d},{sic}):{{r}({b}server(icon){d},{b}icon{d}):{{r}({b}avatar{d},{uav}):{{r}({b}user(avatar){d},{b}avatar{d}):{f.footericon}}}}}}
{=(COMMENT):Allowing custom blocks in text fields.}
{=(f.title):{{r}({b}channel{d},{channel}):{{r}({b}server{d},{server}):{{r}({b}user{d},{user}):{f.title}}}}}
{=(f.name):{{r}({b}channel{d},{channel}):{{r}({b}server{d},{server}):{{r}({b}user{d},{user}):{f.name}}}}}
{=(f.footer):{{r}({b}channel{d},{channel}):{{r}({b}server{d},{server}):{{r}({b}user{d},{user}):{f.footer}}}}}
{=(f.description):{{r}({b}channel(mention){d},{channel(mention)}):{{r}({b}channel{d},{channel}):{{r}({b}server{d},{server}):{{r}({b}mention{d},{user(mention)}):{{r}({b}user(mention){d},{b}mention{d}):{{r}({b}user{d},{user}):{f.description}}}}}}}}
{=(COMMENT):Spaces out the color, then removes the first and last added space}
{=(sepColor):{{r}(, ):{f.color}}}
{=(sepColor):{sepColor(2+)}}
{=(sepColor):{sepColor(+-1)}}
{=(COMMENT):Sanitize our color to only keep our first 6 characters of it, remove the # sign if any and make every letter uppercase}
{=(sanitizedColor):{{r}(#,):{lower:{{j}():{sepColor}}}}}
{=(COMMENT):Dictionary of color names, returned as hex. https://htmlcolorcodes.com/color-names/}
{=(cl.{f.color}):{sanitizedColor(+6)}}
{=(cl.white):FFFFFF}
{=(cl.silver):C0C0C0}
{=(cl.gray):808080}
{=(cl.grey):{cl.gray}}
{=(cl.slategray):708090}
{=(cl.slategrey):{cl.slategray}}
{=(cl.black):000000}
{=(cl.red):FF0000}
{=(cl.yellow):FFFF00}
{=(cl.lime):00FF00}
{=(cl.green):008000}
{=(cl.cyan):00FFFF}
{=(cl.blue):0000FF}
{=(cl.navy):000080}
{=(cl.purple):800080}
{=(cl.salmon):FA8072}
{=(cl.pink):FFC0CB}
{=(cl.coral):FF7F50}
{=(cl.orange):FFA500}
{=(cl.gold):FFD700}
{=(cl.magenta):FF00FF}
{=(cl.violet):EE82EE}
{=(cl.indigo):4B0082}
{=(cl.slateblue):6A5ACD}
{=(cl.midnightblue):191970}
{=(cl.wheat):F5DEB3}
{=(cl.chocolate):F5DEB3}
{=(cl.discord):2F3136}
{=(cl.embed):{cl.discord}}
{=(cl.blurple):7289DA}
{=(cl.self):{user(color)}}
{=(cl.myself):{cl.self}}
{=(cl.me):{cl.self}}
{=(finalHexColor):{upper:{cl.{lower:{{j}():{f.color}}}}}}
{=(COMMENT):Spacing out our hexadecimal code}
{=(spacedHex):{{r}(F,15):{{r}(E,14):{{r}(D,13):{{r}(C,12):{{r}(B,11):{{r}(A,10):{{r}(, ):{finalHexColor}}}}}}}}}
{=(spacedHex):{spacedHex(2+)}}
{=(spacedHex):{{j}(~):{spacedHex(+-1)}}}
{=(COMMENT):Hex to decimal part}
{=(finalDecimalColor):{m:trunc({{j}():{spacedHex(0):~}*16^0 + {spacedHex(-1):~}*16^1 + {spacedHex(-2):~}*16^2 + {spacedHex(-3):~}*16^3 + {spacedHex(-4):~}*16^4 + {spacedHex(-5):~}*16^5)}}}
{=(finalJSON):{ "url":"{f.titleurl}",
"title": "{f.title}",
"description": "{f.description}",
"thumbnail": {
"url": "{f.thumbnail}"
},
"image": {
"url": "{f.image}"
},
"author": {
"name":"{f.name}",
"url": "{f.nameurl}",
"icon_url": "{f.nameicon}"
},
"color": {finalDecimalColor},
"footer": {
"icon_url": "{f.footericon}",
"text": "{f.footer}"
},
"timestamp": "{f.timestamp}"
}}
{=(allFields):{{j}():{{r}({fb},):{word1} {word2} {word3} {word4} {word5} {word6} {word7} {word8} {word9} {word10} {word11} {word12}}}}
{=(areAllFieldsEmpty):{{ct}({pl}):{allFields}{pl}}}
{=(isNoArg):{{ct}({pl}):{a1}{pl}}}
{=(errJSON):{ "description": "No field detected.\nExample:
`{example}`",
"color": {finalDecimalColor}
}
}
{=(errJSON):{ "fields": [
{ "name":
"Features","value":"• **Substring Matching** on each field name (`t` works for `title`, `desc` for `description`, etc.)\n• Fields names can all be filled and in **any order** of your choice!\n• Built-in **error messages**, to let you know what's wrong and when.\n• Ability to specify a color name, hexadecimal color, or even `self` for your own color.\n• **Custom-made blocks** to use in some fields, like user `{avatar}` and server `{icon}` in image fields, `{server}` and `{channel}` in text fields, and `{channel(mention)}` in the Description field.\n• Even for non-Nitro users, ability to use **custom emojis** **from other servers**, by using `<emoji` followed by the **emoji ID** and `>`. For example, `<emoji803680930841362442>` would display <:TagScript:803680930841362442>.\n","inline":false
},
{ "name":
"Usage",
"value":
"`!be fieldName:Content|fieldName:Content`\n```yaml\n!be t:My title|d:My description|thumb:https://i.imgur.com/0l0ZBCm.png|image:https://i.imgur.com/0l0ZBCm.png|f:My footer|color:blurple|time:now\n```",
"inline":
false
}],
"title":
"Build A Custom Embed",
"description":
"Forget about the built-in `!embed` and `!cembed` commands, that are not customizable nor very user friendly, as they require specific syntax, and the latter a minimum knowledge of what JSON even is, which is not the average person.",
"image":{
"url":
"https://cdn.discordapp.com/attachments/337040974415003649/912865596012630086/buildembed_graphics_by_Asty8926.png"
},
"color":3092790,
"footer": {
"text":"Custom command made with ♥ for TagScript by Asty'#8926"
}
}
}
{=(JSONs):errJSON finalJSON}
{=(shouldErr):{in(true):{areAllFieldsEmpty} {isNoArg}}}
{=(JSONIdx):{{i}(true):! {shouldErr} true}}
{=(JSONToSend):{{JSONs({JSONIdx})}}}
{=(debug):__Debug:__
jargs: {jargs}
1: {w1} `{word1}` {content1}
2: {w2} `{word2}` {content2}
3: {w3} `{word3}` {content3}
4: {w4} `{word4}` {content4}
5: {w5} `{word5}` {content5}
6: {w6} `{word6}` {content6}
7: {w7} `{word7}` {content7}
8: {w8} `{word8}` {content8}
9: {w9} `{word9}` {content9}
10: {w10} `{word10}` {content10}
11: {w11} `{word11}` {content11}
12: {w12} `{word12}` {content12}
f.image: {f.image}
f.title: {f.name}
f.titleurl: {f.name}
f.name: {f.name}
f.nameicon: {f.nameicon}
f.nameurl: {f.nameurl}
**Color**
f.color: {f.color} - sepColor: {sepColor} - sanitizedColor: {sanitizedColor}
spacedHex: `{spacedHex}`
finalHexColor: `{finalHexColor}`
finalDecimalColor: `{finalDecimalColor}`
f.description: {f.description}
f.thumbnail: {f.thumbnail}
f.footer: {f.footer}
f.footericon: {f.footericon}
f.timestamp: {f.timestamp}
}
{=(testing):Example:```css
{example}```
FINAL JSON:```json
{finalJSON}
```}
{=(debug2):__Debug 2:__
areAllFieldsEmpty: {areAllFieldsEmpty}
isNoArg: {isNoArg}
JSONToSend:```json
{JSONToSend}
```
}
{c:cembed {channelToSend} {JSONToSend}}
{override}
{require({requiredRolesErrorMessage} ):{requiredRoles}}