Functions
Every function is written as name argument argument. The numbers in brackets are how many arguments it takes.
A text that holds a number (such as the arguments of a command) is accepted wherever a number is needed.
Logic and comparison
Section titled “Logic and comparison”| Function | What it does | Example |
|---|---|---|
eq a b ... (2+) |
True if a equals any of the others |
eq .User.Username "Liam" "Santi" |
ne a b |
Not equal | ne 1 2 |
lt a b, le a b, gt a b, ge a b |
Less, less or equal, greater, greater or equal. Two numbers or two texts | gt (len .Args) 2 |
not x |
The opposite of the truth of x |
not (hasRole "...") |
and a b ... |
The first false value, or the last one | and 1 "" gives "" |
or a b ... |
The first true value, or the last one | or .Member.Nick .User.Username |
and and or look at all their arguments before deciding.
Numbers
Section titled “Numbers”| Function | What it does |
|---|---|
add a b ..., sub a b ..., mult a b ... |
Add, subtract (from the first), multiply |
div a b |
Divide. Dividing by zero is a mistake. div 9 2 is 4.5 |
mod a b |
The remainder |
pow a b |
Power (the exponent is capped at 1000) |
floor x, ceil x, round x, abs x |
Rounding and absolute value |
min a ..., max a ... |
The smallest and the biggest |
toInt x |
A whole number from a text or number, 0 if it is not one. toInt "42abc" is 0 |
toFloat x |
A number from a text, 0 if it is not one |
randInt high / randInt low high |
A random whole number from low up to but not including high |
| Function | What it does |
|---|---|
str x |
Any value as text |
print a b ... |
Joins values as text, without spaces |
printf format values... |
Fills a format: %s text, %d whole number, %.2f decimals, %t true or false, %q quoted, %x hexadecimal, %5s and %-5s width, %% a percent sign. A missing value prints %!d(MISSING) |
lower x, upper x, title x, trim x |
Case and white space |
contains text part |
If the text has the part |
hasPrefix text start, hasSuffix text end |
Starts or ends with |
replace text from to |
Replaces every from with to |
split text separator |
A list of the parts |
join list separator |
One text from a list |
len x |
Characters of a text, items of a list, names of a map |
slice x from to |
Part of a text or of a list. to is optional |
Lists and maps
Section titled “Lists and maps”| Function | What it does |
|---|---|
cslice a b ... |
Makes a list |
dict "key" value ... / sdict ... |
Makes a map from pairs. Both work the same: the keys are always text |
index x position |
The item of a list (from 0) or the value of a map (nil if it does not exist). More keys go deeper: index .M "a" "b" |
append list value |
A new list with the value added |
in list value |
If the value is in the list |
keys map |
The names of a map, as a list |
seq from to |
The whole numbers from from up to but not including to (at most 1000) |
shuffle list |
A new list in random order |
Mentions, time and roles
Section titled “Mentions, time and roles”| Function | What it does |
|---|---|
mentionUser "id", mentionRole "id", mentionChannel "id" |
<@id>, <@&id> and <#id>. The ID must be text of 15 to 22 digits |
unix |
The seconds since 1970, now |
timestamp seconds style |
A Discord timestamp such as <t:1700000000:R>. Styles: t T d D f F R, f if left out |
humanizeDuration seconds |
90061 becomes 1d 1h 1m 1s |
hasRole "id" |
If the member who used the command has that role |
Stored data
Section titled “Stored data”dbSet, dbSetExpire, dbGet, dbDel, dbIncr, dbTop and dbKeys remember things between uses. See Stored data.
Embeds and messages
Section titled “Embeds and messages”cembed and complexMessage are in Embeds and messages.
Buttons and menus
Section titled “Buttons and menus”cbutton, cselect and crow are in Buttons and menus, with respond and updateMessage. ctext, cmodal and showModal, the forms that pop up, are in the same page.
Reactions
Section titled “Reactions”removeReaction, and the "reactions" of complexMessage, are in Reactions.
Actions
Section titled “Actions”sendMessage, sendDM, addRole, removeRole, addReaction, deleteTrigger, respond and updateMessage are in Actions.
