Template Syntax

Learn how Nevi's template language works: curly brace expressions, nesting, user variables, escaping, and execution order.

Basics

Everything in a custom command response is treated as plain text unless it's wrapped in curly braces {}. Anything inside curly braces is a template expression that Nevi evaluates before sending the response.

How it works

Input: Hello, {user.name}! You are member #{server.memberCount}.

Output: Hello, Blake! You are member #1,247.

Template expressions can be variables (like {user.name}), functions (like {random(a,b,c)}), actions (like {delete(10)}), or embeds (like {embed.title:"Hello"}).

Mixing text and variables

You can freely mix plain text with template expressions anywhere in the response. There is no limit to how many expressions you can use in a single response.

Examples

Simple greeting:

Hey {user.mention}, welcome to {server}!

Multiple expressions in a row:

{user.name} joined on {date} at {time}

Expressions inside sentences:

There are {server.memberCount} people in this server and {user.name} is one of them!

Nesting expressions

Functions can contain other expressions as arguments, including variables and other functions. This is called nesting and it lets you build complex, dynamic responses.

Examples

Variable inside a function:

{upper({user.name})}

Converts the user's name to uppercase (e.g., "BLAKE").

Function inside a function:

{upper({random(hello,goodbye,hey)})}

Picks a random word and converts it to uppercase.

Variables inside conditionals:

{if({args.count} > 0:You said {args}:You didn't say anything!)}

Checks if the user provided any arguments and responds accordingly.

User-defined variables

You can assign the result of an expression to a variable name using the = operator. This is useful when you need to use the same value multiple times or when you want to make your template more readable.

Syntax

{variableName = expression}

Example: Dice roller

{roll = random(1,2,3,4,5,6)}You rolled a {roll}! {if({roll} = 6:Critical hit!:Better luck next time.)}

The {roll = ...} part assigns the random result to a variable called roll. The assignment itself produces no output. Then {roll} is used twice, once to display the number and once in the conditional, and both references use the same value.

Example: Reuse a name

{name = upper({user.name})}Welcome, {name}! Everyone say hi to {name}!

Stores the uppercased name once and uses it in two places.

Escaping curly braces

If you need to include a literal curly brace in your response without it being treated as a template expression, you can escape it by doubling the braces.

Escaping syntax

{{ outputs a literal {

}} outputs a literal }

Example

Input: Use {{user.name}}to show your name

Output: Use {user.name} to show your name

Execution order

Understanding the order in which Nevi evaluates template expressions helps you write predictable commands. Expressions are processed in this order:

1

User-defined variables

Assignments like {roll = random(1,2,3,4,5,6)} are evaluated first. The result is stored for later use.

2

Variables and functions

Built-in variables (like {user.name}) and functions (like {upper(text)}) are resolved. Nested expressions are evaluated from the inside out.

3

Actions

Side effects like {delete(10)}, {react(emoji)}, and {edit(5,new text)} are scheduled after the message is sent.

This means you can safely define a variable at the start of your response and reference it in a conditional or action later. The variable will always be available.

Related Commands

/customcmdmanagementRequires mod

Create and manage custom commands with template support