📚
YAGPDB
  • YAGPDB Coding System - Documentation
  • Getting Started
  • Useful Functions
  • Primary Level
    • The Dot and Variables
      • User
      • Guild / Server
      • Member
      • Channel
      • Message
      • Reaction
      • Time
    • Custom Types
    • Functions
      • Type Conversion
      • String Manipulation
      • Math Functions
      • Message Functions
      • Mentions
      • Role Functions
      • Current User
      • Miscellaneous
      • ExecCC
    • Conditional Branching
  • Intermediate Level
  • Database
  • Range Action
  • With Action
  • Custom Embeds
  • Advanced Level
    • Using RegEx
  • Custom Commands Examples
    • Texas Hold'em
Powered by GitBook
On this page

Was this helpful?

  1. Primary Level
  2. Functions

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.

To trim spaces, for example >{{- /* this is a multi-line comment with whitespace trimmed from preceding and following text */ -}} Using{{- ... -}} is also handy insiderange actions, because whitespaces and newlines are rendered there as output.

PreviousCurrent UserNextExecCC

Last updated 5 years ago

Was this helpful?

Iterates (loops) over the given slice or array and sets successive elements as active data (the dot) to be further handled inside the range action. Example usage. .

Function to generate embed inside custom command. .

Checks the arguments for a specific type. Has methods .Get and .IsSet. and example .

Defines type of argument for parseArgs. and an example .

Pauses execution of template's action-structure inside custom command for max 60 seconds combined. Argument seconds is an integer (whole number). Example .

These functions are covered in their own section .

More in-depth here
More in-depth here
here
here
More in depth here
here
More in depth here
here