Skip to content

Commit c016edc

Browse files
committed
all: use custom language definition for YAGDPB templates
1 parent 7642e28 commit c016edc

18 files changed

+321
-163
lines changed

content/docs/custom-commands/commands.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ a page to edit it.
2525

2626
A new custom command has the default response:
2727

28-
```go
28+
```yag
2929
Edit this to change the output of the custom command {{.CCID}}!
3030
```
3131

@@ -195,7 +195,7 @@ need to write that code yourself in the response.
195195

196196
Example:
197197

198-
```go
198+
```yag
199199
{{ if eq .Reaction.Emoji.APIName "😀" "⭐️" }}
200200
This is an allowed reaction!
201201
{{ else if eq .Reaction.Emoji.APIName "🦆" }}

content/docs/moderation/moderation-tools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ based on warning count, you can take advantage of the template scripting within
284284

285285
Example:
286286

287-
```go
287+
```yag
288288
{{/* Number of warnings at which action is to be taken (eg: for action to take place at 4 warnings set threshold to 4) */}}
289289
{{ $threshold := 4 }}
290290
{{ define "punish_check" }}

content/docs/reference/custom-command-examples.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ YAGPDB has a built-in random response system for custom commands, but sometimes
3030
certain responses to occur. You can do this by creating a singular response and creating a variable with randInt. Then
3131
use an if else if statement like this to print out your desired output. 
3232

33-
```go
33+
```yag
3434
{{$var := randInt 100}}
3535
3636
{{if lt $var 10}}
@@ -52,7 +52,7 @@ following:
5252

5353
Trigger type: `Join message in server channel`
5454

55-
```go
55+
```yag
5656
{{if .UsernameHasInvite}}
5757
{{$silent := execAdmin "ban" .User.ID "ad blocked"}}
5858
{{else}}
@@ -69,7 +69,7 @@ This particular command loops over a cslice and a sdict.
6969

7070
Trigger type: `Command` Trigger: `range`
7171

72-
```go
72+
```yag
7373
{{/* range can iterate over many things, let's start with slice */}}
7474
{{ $slice := cslice "YAGPDB " "is " "cool!" }}
7575
{{/* Here, we range over with 1 argument, meaning the dot will be set to current iteration value */}}
@@ -89,7 +89,7 @@ your input that you are on. 
8989
Range will work on any kind of slice/array. for example. If we wanted to look for all the entries in our database we can
9090
use range and index through them all in the following. 
9191

92-
```go
92+
```yag
9393
{{$lb := dbTopEntries "%" 100 0}}
9494
{{range $lb}}
9595
{{.UserID}} **:** {{.Key}} **:** {{.Value}}
@@ -106,7 +106,7 @@ will have to use `dict`.
106106

107107
Trigger type: `Command` Trigger: `dict`
108108

109-
```go
109+
```yag
110110
{{ $dict := dict 0 "foobar" "hello" "world" }}
111111
{{/* Retrieve value with integer key with index */}}
112112
0 - {{ index $dict 0 -}}
@@ -131,7 +131,7 @@ are:
131131

132132
Trigger type: `Command` Trigger: `send` 
133133

134-
```go
134+
```yag
135135
{{$args := parseArgs 2 "Syntax is <channel> <text>"
136136
(carg "channel" "channel to send to")
137137
(carg "string" "text to send")}}
@@ -145,7 +145,7 @@ This example consists of two custom commands, and after copy/paste `REPLACE-WITH
145145
actual custom command ID's in your system. This custom command is very complex, uses very many advanced functions, all
146146
it does, constructs a 10 second countdown timer command-system for given starting time.
147147

148-
```go
148+
```yag
149149
{{$args := parseArgs 2 ""
150150
(carg "duration" "countdown-duration")
151151
(carg "string" "countdown-message")}}
@@ -159,7 +159,7 @@ Second part of the custom commands, here we see, how `data`-part of exeCC was ma
159159
`sdict`and now we are calling those keys with `.ExecData` - for example `.ExecData.MessageID` sets new variable the same
160160
as stated in previous code.
161161

162-
```go
162+
```yag
163163
{{$timeLeft := .ExecData.T.Sub currentTime}}
164164
{{$cntDownMessageHeader := print "Countdown Timer: " .ExecData.Message}}
165165
{{$formattedTimeLeft := humanizeDurationSeconds $timeLeft}}
@@ -190,7 +190,7 @@ inserted to database begins with "notes\_".
190190

191191
#### Save note
192192

193-
```go
193+
```yag
194194
{{$args := parseArgs 2 ""
195195
(carg "string" "key")
196196
(carg "string" "value")}}
@@ -201,7 +201,7 @@ Saved `{{$args.Get 0}}` as `{{$args.Get 1}}`
201201

202202
#### Get note
203203

204-
```go
204+
```yag
205205
{{$key := print "notes_" .StrippedMsg}}
206206
{{$note := dbGet .User.ID $key}}
207207
{{if $note}}
@@ -215,7 +215,7 @@ Note: `{{$strippedKey}}` Created {{humanizeTimeSinceDays $note.CreatedAt}} ago:
215215

216216
#### List user's notes
217217

218-
```go
218+
```yag
219219
{{$notes := dbGetPattern .User.ID "notes_%" 100 0}}
220220
{{range $notes}}
221221
{{- $strippedKey := slice .Key 6 (len .Key)}}
@@ -230,7 +230,7 @@ You don't have any notes :(
230230
With YAGPDB's database system, you can now add cooldowns to you custom commands. You can either make them global
231231
cooldowns or a per user cooldown.
232232

233-
```go
233+
```yag
234234
{{/* CONFIGURATION HERE CHANGE VALUES AS NEEDED */}}
235235
236236
{{/* 0 for per user, 1 for global */}}
@@ -271,7 +271,7 @@ Trigger type: `Regex` Trigger: `\A`
271271

272272
`BE SURE TO RESTRICT THE COMMAND TO A SINGLE CHANNEL`&#x20;
273273

274-
```go
274+
```yag
275275
{{/* If you are not doing (no twice msg in a row) or (role assignment for latest user) you can remove counter_user and by extension everything to do with $lastUser*/}}
276276
277277
{{/* First time running command, set up initial values*/}}
@@ -339,7 +339,7 @@ command take away roles from someone instead of giving them by simply using the
339339

340340
Trigger type: `Command` Trigger: `giveRoleName`
341341

342-
```go
342+
```yag
343343
{{if eq (len .Args) 3}}
344344
{{$allowedRoles := (cslice "Patron" "Quality Patron" "Paypal Donors")}}
345345
{{$role := (index .CmdArgs 1)}}
@@ -365,7 +365,7 @@ only string keys), `sendMessage`, and `cembed`in action.
365365

366366
Trigger type: `Command` Trigger: `bc`
367367

368-
```go
368+
```yag
369369
{{if eq (len .Args) 3}}
370370
{{$channel := (index .CmdArgs 0)}}
371371
{{$msg:= (joinStr " " (slice .CmdArgs 1))}}
@@ -398,7 +398,7 @@ custom commands.&#x20;
398398

399399
Trigger type: `Command` Trigger: `avatar`
400400

401-
```go
401+
```yag
402402
{{$ln := (len .Args)}}
403403
{{$sizes := (cslice "16" "32" "64" "128" "256" "512" "1024" "2048" "4096")}}
404404
{{$err1 := "Wrong image size input format! Possible values: 16, 32, 64, 128, 256, 512, 1024, 2048, 4096."}}
@@ -456,7 +456,7 @@ This command is used to replace suggestion bots. You can adapt it to your needs.
456456

457457
Trigger type: `Command` Trigger: `suggest`
458458

459-
```go
459+
```yag
460460
{{ $channel := 476178740133494784 }} {{/* Replace this with your suggestion channel ID */}}
461461
462462
{{if gt (len .Args) 1}}
@@ -487,7 +487,7 @@ emote file directly from Discord's database.
487487

488488
Trigger type: `Command` Trigger: `bigemote`
489489

490-
```go
490+
```yag
491491
{{ $matches := reFindAllSubmatches `<(a)?:.*?:(\d+)>` .StrippedMsg }}
492492
{{ if $matches }}
493493
{{ $animated := index $matches 0 1 }}

content/docs/reference/custom-embeds.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Embeds in custom commands are a little more difficult. Also, there is no generat
9292

9393
To start off, we'll take a look at this example and break it down:
9494
95-
```go
95+
```yag
9696
{{ $embed := cembed "title" "This is my title" "description" "This is my description." }}
9797
{{ sendMessage nil $embed }}
9898
```
@@ -115,7 +115,7 @@ To make your code readable, especially for large embeds, **indents** may be used
115115

116116
{{< callout title="Custom Command \"embed\"" >}}
117117

118-
```go
118+
```yag
119119
{{ $advice := execAdmin "advice" }}
120120
{{ $topic := execAdmin "topic" }}
121121
{{ $catfact := execAdmin "catfact" }}
@@ -165,7 +165,7 @@ is given as integer and you can convert a hex color to it using
165165
Up next, I have added some fields. This is a bit more difficult, but doable if you have understood it once. Let's break
166166
it down in this example:
167167
168-
```go
168+
```yag
169169
"fields" (cslice
170170
(sdict "name" "Title of field 1" "value" "Description of field 1" "inline" false)
171171
(sdict "name" "Title of field 2" "value" "Description of field 2" "inline" false)
@@ -189,7 +189,7 @@ You can display an image by simply pasting the link to it in the response, or by
189189
190190
Trigger type: command trigger: `imageembed`
191191
192-
```go
192+
```yag
193193
{{ $embed := cembed "image" (sdict "url" "https://i.imgur.com/ttIwOmn.png") }}
194194
{{ sendMessage nil $embed }}
195195
```
@@ -227,7 +227,7 @@ Simple embeds work with switches, here is a list of them all:
227227

228228
The values for simple embeds need to bet placed within quotes:
229229

230-
```go
230+
```yag
231231
-se -title "This is my title" -desc "This is my description" -thumbnail "https://via.placeholder.com/300/"
232232
```
233233

0 commit comments

Comments
 (0)