Miscellaneous
All functions without special classification are here
Function
Description
adjective
Returns a random adjective.
noun
Returns a random noun.
index
Returns the result of indexing its first argument by the following arguments. Each indexed item must be a map, slice or array.
Example: {{index .Args 1}}
returns first argument after trigger which is always at position 0.
range slice/array
dict key1 value1 key2 value2 ...
Creates an unordered collection of key-value pairs, a dictionary so to say. The number of parameters to form key-value pairs must be even. Keys and values can be of any type. Key is not restricted to string only as in case with sdict
.
cembed "list of embed values"
in list value
Returns bool true/false whether case-sensitive value is in list/slice. {{ in (cslice "YAGPDB" "is cool") "yagpdb" }}
returns false
.
inFold
Same as in
, but is case-insensitive. {{inFold (cslice "YAGPDB" "is cool") "yagpdb"}}
returns true
.
seq start stop
Creates a new slice of type int, beginning from start number, increasing in sequence and ending at stop (not included). {{seq -4 2}}
returns a slice [ -4 -3 -2 0 1 ]
. Sequence's max length is 10 000.
shuffle list
Returns a shuffled, randomized version of a list/slice.
exec "command" "args" "args" "args" ...
Executes a YAGPDB command (e.g. roll, kick etc) in a custom command. Exec can be run max 5 times per command. If real command returns an embed - exec
will return raw data of type embed, so you can use embed fields for better formatting - e.g. {{$resp := exec "whois"}} {{$resp.Title}} Joined at > {{(index $resp.Fields 4).Value}}
will return the title (username#discriminator) and "Joined at" field's value from whois
command. NB! This will not work for un/nn commands!
exec syntax is exec "command" arguments
- this means you format it the same way as you would type the command regularly, just without the prefix, e.g. if you want to clear 2 messages and avoiding the pinned message > {{exec "clear 2 -nopin"}}
, where "command"
part is whole "clear 2 -nopin"
. If you change that number inside CC somewhere then you have to use arguments
part of exec formatting > {{$x := 2}} {{exec "clear" $x "-nopin"}}
Here "clear"
is the "command"
and it is followed by arguments
, one variable $x
and one string "-nopin"
. Last example is the same as {{exec (joinStr " " "clear" $x "-nopin")}}
(also notice the space in joinStr
separator).
execAdmin "command" "args" "args" "args" ...
Functions same way as exec
but will override any permission requirement (such as the kick permission to use kick command etc.).
parseArgs required_args error_message ...carg
carg "type" "name"
sleep seconds
cslice, sdict
humanizeThousands arg
This function places comma to separate groups of thousands of a number. arg
can be int or string, has to be a whole number, e.g. {{humanizeThousands "1234567890"}}
will return 1,234,567,890
sendTemplate channel name data
Function sends a formulated template to another channel. Channel is like always either name, number or nil. Also returns messageID.
Example:
{{define "logsTemplate"}}This text will output on different channel, you can also use functions like {{currentTime}}. {{.TemplateArgs}} would be additional data sent out. {{end}}
Now we call that "logs" in the same custom command.{{sendTemplate "logs" "logsTemplate" "YAG rules!"}}
sendTemplateDM name data
Works the same way as function above. Only channel's name is missing from arguments. YAG will only DM triggering user.
Last updated
Was this helpful?