For the complete documentation index, see llms.txt. This page is also available as Markdown.

Number

Apply number formatting to the given number.

The Number counter turns a value into a number so that number formatting applies to it. On its own it changes nothing you can see. Its whole job is to make Use compact notation, Override default locale and Override default digits work on a value the bot would otherwise treat as text.

Availability: every bot type. It makes no network requests, so it needs no API key and no environment variable when you self-host.

Number options
The Number counter panel, with a nested HTTP counter in the Number field

Counters that return text even when the text looks like a number:

  • HTTP returns the value at your Data path. A quoted JSON field arrives as text; a bare JSON number already arrives as a number.

  • Reddit returns text when it is set to return the subreddit title; its member counts are already numbers.

  • Clock and Date return a formatted string.

  • Concat and Replace always return text.

Options

Option
What it does
Notes

Number

The value to convert to a number.

One value only. Type a number into the box, or pick a counter from the same box to nest it.

The Number field takes a nested counter, which is the normal way to use this counter. The nested counter has to return a valid number.

What it returns

The value read as a number.

Input
Result

1234

1234

12 (with spaces around it)

12

1e3

1000

0x10

16

an empty string

0

1,234

not a number, the counter fails

$99

not a number, the counter fails

99.4%

not a number, the counter fails

the Number field left empty

not a number, the counter fails

An empty string quietly becomes 0 instead of failing, so a nested counter that sometimes returns nothing shows 0 rather than an error.

Number does not round. 42.857142857142854 stays 42.857142857142854, and Use compact notation is the only way to shorten a value.

Formatting

This is the point of the counter, so all of the Format settings apply: Use compact notation, Override default locale, and Override default digits, where you give each digit from 0 to 9 the character or emoji it is drawn with.

Override default locale only changes anything when Use compact notation is on. It picks the language the shortened form is written in.

Custom digits only reach text and announcement channel topics, never voice or category channel names, because Discord channel names cannot show them.

Refresh and caching

Number 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.

Whatever you nest inside it keeps its own refresh behaviour, so an HTTP counter with a Lifetime (in seconds) of 300 still only refetches every five minutes.

Examples

The Bitcoin price comes back from the API as text, so on its own it can never be shortened. Nesting it in a Number counter fixes that.

  1. Add an HTTP counter with URL (GET) https://api.coinlore.net/api/ticker/?id=90, Data path [0].price_usd and Lifetime (in seconds) 300.

  2. Add a Number counter and put the HTTP counter into its Number field, so Number is the outer counter.

  3. Open Format settings on the Number counter and set Use compact notation to Yes.

The channel then shows the price shortened, such as 81K, instead of the full number. Leave compact notation off and you get the raw number exactly as it came in.

An HTTP price wrapped in a Number counter
HTTP fetches the price as text; the Number counter around it makes compact notation apply

Custom digits are part of the number formatting, so the bot skips them for any counter that returns text. Put a Number counter around it, then turn on Override default digits in the outer counter's Format settings and set the character for each digit.

Remember that custom digits only show up in text and announcement channel topics.

Math needs numbers. A value that arrives as text, such as an HTTP JSON string or a Reddit counter set to the subreddit title, has to go through a Number counter first.

Errors

What you see
What to do

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 value could not be read as a number. Refill the Number field, and clean commas, currency symbols or percent signs with a Replace counter nested inside it.

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 Members: before it.

If it still fails, Troubleshooting covers the common causes, and you can ask on the support server.

Technical details
  • Evaluator: packages/services/src/DataSource/DataSourceEvaluator/evaluators/number.ts, a single Number(options.number), so the accepted inputs are the JavaScript coercion rules.

  • NaN raises the known error FAILED_TO_RETURN_A_FINAL_STRING; the update job then writes jobs.updateChannels.computeError (ERROR! in en-US, translated in the other locales) into the name or topic.

  • Why the counter is needed: a string result is returned untouched, and only a value that is already a number gets formatted.

  • The format settings are taken once from the root counter's format, falling back to the guild's formatSettings, and forced onto every nested node, so a nested counter's own format is never read. The dashboard matches this and only ever writes the format of the outermost counter.

  • Order of operations: compact notation through Intl.NumberFormat(locale, { notation: "compact" }) first, then the custom-digit substitution, which runs only for GuildText and GuildAnnouncement channels.

  • The dashboard preview evaluates with the real channel's type and falls back to GuildText only when the channel is not in the bot's cache, so the preview matches the channel.

  • Global limits: 60 s per counter in the template, shared with everything nested inside it (EVALUATION_TIMEOUT), 50,000 tree-exploration iterations, and a final result that is trimmed and then cut to 1023 characters for a topic or 99 for a channel name, with the 2-character minimum (EVALUATION_RESULT_FOR_CHANNEL_NAME_IS_LESS_THAN_2_CHARACTERS) checked before the cut.

  • No network access, no cache entry and no environment variable when self-hosting.

Last updated