Math
Perform math operations like addition, subtraction, multiplication, division, or modulus on a list of numbers.
The Math counter takes a list of numbers and reduces it to one number with a single arithmetic operation. Each entry can be a number you type or a nested counter, so you can build values Discord does not give you directly, such as the percentage of members who are online.
Availability: every bot type. It makes no network requests, so it needs no API key and no environment variable when you self-host.

Options
Operation type
Picks the operation applied to the whole Number list.
Starts on Addition, so an untouched Math counter adds.
Number list
The operands, used from first to last in the order you list them.
Type a number in the Add number... row to append one, or pick a counter from the same box to nest it. Order matters for Subtraction, Division and Modulo (Remainder of a division).
Every row of Number list takes a nested counter, and that counter must return a number.
Operation type values
Addition
Adds every entry.
125
Subtraction
Subtracts each entry from the running result, from first to last.
75
Multiplication
Multiplies every entry.
10000
Division
Divides the running result by each entry, from first to last.
1
Modulo (Remainder of a division)
Keeps the remainder of dividing the running result by each entry, from first to last.
0
What it returns
A number.
Addition and Multiplication start from a seed, so an empty Number list gives
0and1.Subtraction, Division and Modulo (Remainder of a division) start from the first entry instead. A single entry comes back unchanged, and an empty list breaks the whole template.
Every entry is read as a number first. A nested counter that returns text the bot cannot read as a number makes the counter fail.
Dividing by
0is not an error. It returnsInfinity, shown as∞when compact notation is on.
Formatting
Math returns a number, so the Format settings apply to it. The bot reads them from the outermost counter of the chip and applies them once to the final value, and anything you leave unset falls back to the Server settings.
Refresh and caching
Math caches nothing. The bot works it out again on every channel update, every 10 minutes on the public bot and every 5 minutes on the other bot types. See How counters update.
Nested counters keep their own rules, so a value can still lag: Reddit, Twitch and YouTube serve a cached value, and HTTP caches only when you set a Lifetime (in seconds). Twitch and YouTube do not work on the public bot.
Examples
The most common use of Math: turn two member counts into one percentage.
Add a Math counter and set Operation type to Multiplication.
In its Number list, add a nested Math counter set to Division, then type
100into the Add number... row.Fill the nested division's Number list with two nested Members counters: first one with Filter by status set to Online + Idle + DND, then one with no filters. Division works from first to last, so the online count goes first.
Open Format settings on the outer counter and set Use compact notation to Yes, so the long decimal is shortened.
With 1 of 2 members online, the division returns 0.5, the multiplication turns that into 50, and the channel shows Online: 50%.

Online: 50%The public bot cannot read member presences, so the online count behaves differently there. Read Members before you build this one.
Subtract the bots from the total.
Operation type: Subtraction
Number list:
A nested Members counter with no filters.
A nested Members counter with Filter by account type set to Bot.
With 120 members of which 8 are bots, the counter returns 112.
Errors
The channel shows ERROR!
The template failed. Open the channel in the dashboard and read the error below.
Failed to generate a final string from the evaluation.
The evaluation took too long and timed out.
A counter took more than 60 seconds, usually a nested Game counter whose server does not answer, or a long chain of nested requests. Simplify the nesting.
The result for the channel name is less than 2 characters long.
A voice or category channel name needs at least 2 characters. Add text around the counter in the template, for example Online: before it.
If it still fails, Troubleshooting walks through the common causes, and you can ask on the support server.
Last updated