Functions Reference
All template functions in Nevi custom commands: text manipulation, random selection, math, and conditionals.
Text functions
Text functions let you transform and manipulate text within your custom command responses.
| Function | Description | Example |
|---|---|---|
{upper(text)} | Converts text to uppercase | {upper(hello)} → HELLO |
{lower(text)} | Converts text to lowercase | {lower(HELLO)} → hello |
{length(text)} | Returns the character count of the text | {length(hello)} → 5 |
{repeat(text,n)} | Repeats the text n times | {repeat(ha,3)} → hahaha |
Text functions with variables
{upper({user.name})} → converts the user's name to uppercase
{length({args})} → counts the characters in the user's message
{repeat({args.0},3)} → repeats the first word three times
Random functions
Random functions pick a random item from a list, making your commands unpredictable and fun.
| Function | Description | Example |
|---|---|---|
{random(a,b,c)} | Picks one random item from the comma-separated list | {random(yes,no,maybe)} → maybe |
{choose} | Picks a random item from the user's arguments | /pick pizza tacos sushi → tacos |
Example: 8-ball command
/customcmd create 8ball {user.name} asks: {args} | The 8-ball says: {random(Yes!,No.,Ask again later,Definitely,I doubt it,Without a doubt,Maybe,Signs point to yes,Very doubtful)}Example: Dice roller
/customcmd create dice {user.name} rolled a {random(1,2,3,4,5,6)}!Example: Random picker with {choose}
/customcmd create pick I choose: {choose}!Users run it as /pick pizza tacos burgers and Nevi picks one at random from their arguments.
Math function
The {math(expression)} function evaluates a mathematical expression and returns the result.
Supported operators
+ addition, - subtraction, * multiplication, / division, % modulo, ** exponent
Parentheses are supported for grouping.
Examples
{math(2 + 2)} → 4
{math(100 / 3)} → 33.33
{math(2 ** 10)} → 1024
{math((5 + 3) * 2)} → 16
Using variables in math
/customcmd create double The double of {args.0} is {math({args.0} * 2)}!Running /double 21 responds with "The double of 21 is 42!".
Conditional function
The {if(condition:then:else)} function lets you create branching logic in your commands. If the condition is true, the "then" branch is returned; otherwise, the "else" branch is returned.
Syntax
{if(left operator right:then:else)}The colon : separates the condition, the "then" branch, and the "else" branch.
Comparison operators
| Operator | Meaning |
|---|---|
= | Equal to |
!= | Not equal to |
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |
contains | Left text contains right text |
Practical examples
Check if arguments were provided:
{if({args.count} > 0:You said: {args}:You didn't say anything!)}Compare a value:
{roll = random(1,2,3,4,5,6)}{if({roll} >= 4:You rolled a {roll} - great roll!:You rolled a {roll} - better luck next time.)}Check for a keyword:
{if({args} contains hello:Hello to you too, {user.name}!:I didn't hear a hello...)}Exact match:
{if({args.0} = yes:Great, glad you agree!:Hmm, you didn't say yes.)}Combining functions
Functions can be nested inside each other to create complex behavior. Inner functions are evaluated first, and their results are passed to the outer function.
Random uppercase greeting
{upper({random(hello,hey,hi,howdy)})}, {user.name}!Picks a random greeting and converts it to uppercase, like "HOWDY, Blake!".
Conditional with math
{score = random(1,2,3,4,5,6,7,8,9,10)}{if({score} > 5:You scored {score}/10 - that's above average! ({math({score} * 10)}%):You scored {score}/10 - try harder! ({math({score} * 10)}%))}Generates a random score, checks if it's above 5, and shows a percentage using math.
Repeated random
{repeat({random(ha,he,ho)},5)}!Picks a random laugh sound and repeats it 5 times, like "hahahahaha!".
Related Commands
/customcmdmanagementRequires modCreate and manage custom commands with template support