Skip to content
Math & Text calculate

$calculate[]

The $calculate[] function is the most powerful mathematical function in BDFD. It allows you to evaluate complex mathematical expressions using an integrated math parser.

Syntax

bdfd
$calculate[expression]

Syntax

$calculate[expression]

Parameters

Parameter Type Required Description
expression string Yes The mathematical expression to evaluate.

Supported Operators

Operator Description Example
+ Addition 5 + 3 → 8
- Subtraction 10 - 4 → 6
* Multiplication 6 * 7 → 42
/ Division 15 / 3 → 5
% Modulo 17 % 5 → 2
^ Exponentiation 2 ^ 8 → 256

Supported Functions

sin, cos, tan, asin, acos, atan, abs, sqrt, log, log10, floor, ceil, round, min, max, exp

Comparisons

Comparisons return "true" or "false":

  • > strictly greater than
  • < strictly less than
  • >= greater than or equal to
  • <= less than or equal to
  • == equal to
  • != not equal to

Examples

Math Expression Evaluator

$var[result;$calculate[($message[1] + 10) * 2 / 4]]
$title[Math Calculator 🧮]
$description[Formula: `($message[1] + 10) * 2 / 4`\nResult: **$var[result]**]
$color[#5865F2]
$sendMessage[]

Notes

  • The expression is evaluated with a server-side math parser.
  • The result is always returned as a character string (even for numbers).
  • The function supports the use of BDFD variables like $getVar[] in the expression.
  • In case of an invalid expression, the behavior depends on the parser (usually a silent error or an empty result).