🎉 Tickety V3 has now been released! Read more →
PlaceholdersParsers

Math Parser

The Math Parser allows you to perform mathematical calculations and evaluate expressions with support for basic arithmetic operations, parentheses, and formatting options.

Usage

To use the parser, insert the following syntax in your text:

{math(parameter):expression}

The parameter is optional. If omitted, the result will be returned as a decimal number.

Operators

Arithmetic Operators

  • + - Addition
  • - - Subtraction (also supports unary minus for negative numbers)
  • * - Multiplication
  • / - Division
  • % - Modulo (remainder after division)
  • ^ - Exponentiation (power)

Operator Precedence

Operators are evaluated in the following order (highest to lowest):

  1. ^ (exponentiation, right-associative)
  2. *, /, % (multiplication, division, modulo, left-associative)
  3. +, - (addition, subtraction, left-associative)

Parameters

Fixed Decimal Places

  • fixed=N - Formats the result with N decimal places (0-10)
    • Example: {math(fixed=2):10/3} → 3.33

Integer Truncation

  • int - Returns the integer part of the result (truncates decimal portion)
    • Example: {math(int):10/3} → 3

Examples

Basic Arithmetic

  • {math:2+2} → 4
  • {math:10-5} → 5
  • {math:3*4} → 12
  • {math:15/3} → 5
  • {math:17%5} → 2
  • {math:2^3} → 8

Complex Expressions

  • {math:2+3*4} → 14 (multiplication before addition)
  • {math:(2+3)*4} → 20 (parentheses change order)
  • {math:10/3+5} → 8.333333333333334
  • {math:2^3^2} → 512 (right-associative: 2^(3^2))

Negative Numbers

  • {math:-5+3} → -2
  • {math:(-5)*2} → -10
  • {math:10+-3} → 7

With Parameters

  • {math(fixed=2):10/3} → 3.33
  • {math(fixed=0):10/3} → 3
  • {math(int):10/3} → 3
  • {math(fixed=4):2^8} → 256.0000

Nested Expressions

  • {math:(5+3)*(2+1)} → 24
  • {math:((10-2)/2)^2} → 16
  • {math:100/(5*2)} → 10

Variable Support

You can use variables within mathematical expressions:

  • {math:{currentTime}+604800000} → Adds 7 days to the current timestamp
  • {math:{guild.memberCount}/2} → Calculates half of guild member count

Note: The parser supports decimal numbers, parentheses for grouping, and follows standard mathematical operator precedence. Division by zero, invalid expressions, and results exceeding safety limits will return no output.

On this page