nf
Number Formatter Tag by Asty'#8926 — Show-off post: https://discord.com/channels/314660900302749696/337040974415003649/900439162400948255
Privateunrated
Content
134 lines{=(COMMENT):Server's preferred prefix and this tag's name.}
{=(prefix):!}
{=(tagname):nf}
{=(COMMENT):Default amount of decimals to display to the user in the formatted number, when they didn't specify one as the second argument as well.}
{=(defaultDecimals):1}
{=(COMMENT):Stores our first and second argument. Empty if none.}
{=(jargs):{join(~):{args}}}
{=(arg1):{list(0):{jargs}}}
{=(arg2):{list(1):{jargs}}}
{=(COMMENT):Allowed decimals to be specified by the user as the second argument.}
{=(allowedDecimals):0 1 2 3}
{=(COMMENT):Checks if the second argument is an allowed decimal. Returns false even if there was only 1 argument.}
{=(isAllowedDecimal):{contains({arg2}):{allowedDecimals}}}
{=(COMMENT):Short alias of the replace block, as we will reuse it often.}
{=(r):replace}
{=(COMMENT):Amount of maximum decimals being outputted to the user. Conditionally takes the second argument if specified.}
{=(decimals):{{r}(false,{defaultDecimals}):{{r}(true,{arg2}):{isAllowedDecimal}}}}
{=(COMMENT):Returns true if the specified first argument is NOT a number (NaN).}
{=(isNaN):{in(false):{in({m:sgn({arg1})}):-1 0 1}}}
{=(COMMENT):Returns true if there was no argument given.}
{=(isNoArg):{contains($&%):{arg1}$&%}}
{=(COMMENT):Ensures it removes all leading/padding zeros to the input. So 0100000 will remove the 0 before 1.}
{=(nopad):{m:trunc({arg1})}}
{=(COMMENT):Adds a space between every character.}
{=(spaced):{{r}(, ):{nopad}}}
{=(COMMENT):Counts the amount of characters/digits in the inputted value.}
{=(digitCount):{index($&%):{spaced(2+)} $&%}}
{=(COMMENT):Each group has a variable name, an amount of digits and an abbreviation letter.}
{=(none):0~}
{=(thousand):3~k}
{=(million):6~M}
{=(billion):9~B}
{=(trillion):12~T}
{=(COMMENT):Using "!tip tax", we return the group name depending on the "range" of digits in the input. If between 0 and 2 (the right is not inclusive), return none, if between 3 and 5, thousand, 6 and 8, million, and so on. [inclusive - not inclusive]}
{=(lengths):3 6 9 12}
{=(groups):none thousand million billion trillion}
{=(groupCheck):-1 {{r}(0,1):{m:sgn({lengths(1)}-({digitCount}))} {m:sgn({lengths(2)}-({digitCount}))} {m:sgn({lengths(3)}-({digitCount}))} {m:sgn({lengths(4)}-({digitCount}))}} 1}
{=(COMMENT):Group name returned.}
{=(group):{groups({index(1):{groupCheck}})}}
{=(COMMENT):Amount of minimum digits of our returned group.}
{=(digits):{{group}(1):~}}
{=(COMMENT):Abbreviation from our returned group.}
{=(abbreviation):{{group}(2):~}}
{=(COMMENT):Converts the given number to a non-truncated (decimal) result.}
{=(rounded):{m:{nopad}/(10^{digits})}}
{=(COMMENT):Splits and stores the integer and decimal values.}
{=(resultInteger):{rounded(1):.}}
{=(resultDecimals):{rounded(2):.}}
{=(COMMENT):Adds a space between every character in the decimals.}
{=(spacedDecimals):{{r}(, ):{resultDecimals}}}
{=(spacedDecimals):{spacedDecimals(2+)}}
{=(spacedDecimals):{spacedDecimals(+-1)}}
{=(COMMENT):Parse the decimals up to the amount of decimals to return.}
{=(finalDecimals):{join():{spacedDecimals(+{decimals})}}}
{=(COMMENT):Formatted result, with the integer and conditional decimals, as well as its abbreviation from the returned group if any.}
{=(formatted):{{r}(Z,):{{r}(.Z,):{{r}(.0Z,):{resultInteger}.{finalDecimals}Z}}{abbreviation}}}
{=(COMMENT):Output Management}
{=(msg.noNum):<:RedTick:699124870352732251> {user(mention)}, the argument you specified is not a number. Try again.}
{=(msg.noArgs):Get a formatted amount or number from the one specified along with the command.
**Example**```css
{prefix}{tagname} 123456
```**Returns**```css
123.456k
```}
{=(msg.success):**Input**
`{arg1}`
**Formatted**
`{formatted}`
}
{=(COMMENT):Output variables names.}
{=(msg):noArgs noNum success}
{=(COMMENT):Embed fields variables.}
{=(em.title):Number Formatter}
{=(em.description):{msg.{msg({index(true):0 {isNoArg} {isNaN} true})}}}
{=(em.footer):{prefix}{tagname} [number] <decimals 0-3>}
{=(COMMENT):Conditional embed color. Orange if not a number, otherwise blue.}
{=(color.good):0076f5}
{=(color.error):f57738}
{=(color):good error good}
{=(em.color):{color.{color({index(true):0 {isNoArg} {isNaN} true})}}}
{embed(color):#{{r}(#,):{em.color}}}
{=(debug):__Debug:__
**Input Management**
input: {arg1}
defaultDecimals: `{defaultDecimals}`
nopad: {nopad}
digitCount: {digitCount}
group: {group}
digits: {digits}
**Checks**
isNaN: `{isNaN}`
isNoArg: `{isNoArg}`
isAllowedDecimal: `{isAllowedDecimal}`
**Calculation**
resultInteger: `{resultInteger}`
resultDecimals: `{resultDecimals}`
spacedDecimals: `{spacedDecimals}`
finalDecimals: {finalDecimals}
**Output**
Title: {em.title}
Description: {em.description}
Footer: `{em.footer}`
Embed Color: `{em.color}`
}Embed
1 line{"color": 5198940, "title": "{em.title}", "footer": {"text": "{em.footer}"}, "description": "{em.description}"}Raw JSON
{
"id": 1115762,
"created_at": "2021-10-20T14:21:27.000Z",
"tag_name": "nf",
"nsfw": false,
"owner_id": "149926720114262016",
"uses": 36,
"description": "Number Formatter Tag by Asty'#8926 — \n\nShow-off post: https://discord.com/channels/314660900302749696/337040974415003649/900439162400948255",
"restricted": false,
"shared": false,
"deleted": false,
"safe": "unrated",
"hidden": false,
"guild_id": "314660900302749696",
"sharer": "149926720114262016",
"content": "{=(COMMENT):Server's preferred prefix and this tag's name.}\n{=(prefix):!}\n{=(tagname):nf}\n\n{=(COMMENT):Default amount of decimals to display to the user in the formatted number, when they didn't specify one as the second argument as well.}\n{=(defaultDecimals):1}\n\n{=(COMMENT):Stores our first and second argument. Empty if none.}\n{=(jargs):{join(~):{args}}}\n{=(arg1):{list(0):{jargs}}}\n{=(arg2):{list(1):{jargs}}}\n\n{=(COMMENT):Allowed decimals to be specified by the user as the second argument.}\n{=(allowedDecimals):0 1 2 3}\n{=(COMMENT):Checks if the second argument is an allowed decimal. Returns false even if there was only 1 argument.}\n{=(isAllowedDecimal):{contains({arg2}):{allowedDecimals}}}\n\n{=(COMMENT):Short alias of the replace block, as we will reuse it often.}\n{=(r):replace}\n\n{=(COMMENT):Amount of maximum decimals being outputted to the user. Conditionally takes the second argument if specified.}\n{=(decimals):{{r}(false,{defaultDecimals}):{{r}(true,{arg2}):{isAllowedDecimal}}}}\n\n{=(COMMENT):Returns true if the specified first argument is NOT a number (NaN).}\n{=(isNaN):{in(false):{in({m:sgn({arg1})}):-1 0 1}}}\n\n{=(COMMENT):Returns true if there was no argument given.}\n{=(isNoArg):{contains($&%):{arg1}$&%}}\n\n{=(COMMENT):Ensures it removes all leading/padding zeros to the input. So 0100000 will remove the 0 before 1.}\n{=(nopad):{m:trunc({arg1})}}\n{=(COMMENT):Adds a space between every character.}\n{=(spaced):{{r}(, ):{nopad}}}\n{=(COMMENT):Counts the amount of characters/digits in the inputted value.}\n{=(digitCount):{index($&%):{spaced(2+)} $&%}}\n\n{=(COMMENT):Each group has a variable name, an amount of digits and an abbreviation letter.}\n{=(none):0~}\n{=(thousand):3~k}\n{=(million):6~M}\n{=(billion):9~B}\n{=(trillion):12~T}\n\n{=(COMMENT):Using \"!tip tax\", we return the group name depending on the \"range\" of digits in the input. If between 0 and 2 (the right is not inclusive), return none, if between 3 and 5, thousand, 6 and 8, million, and so on. [inclusive - not inclusive]}\n{=(lengths):3 6 9 12}\n{=(groups):none thousand million billion trillion}\n{=(groupCheck):-1 {{r}(0,1):{m:sgn({lengths(1)}-({digitCount}))} {m:sgn({lengths(2)}-({digitCount}))} {m:sgn({lengths(3)}-({digitCount}))} {m:sgn({lengths(4)}-({digitCount}))}} 1}\n{=(COMMENT):Group name returned.}\n{=(group):{groups({index(1):{groupCheck}})}}\n\n{=(COMMENT):Amount of minimum digits of our returned group.}\n{=(digits):{{group}(1):~}}\n{=(COMMENT):Abbreviation from our returned group.}\n{=(abbreviation):{{group}(2):~}}\n\n{=(COMMENT):Converts the given number to a non-truncated (decimal) result.}\n{=(rounded):{m:{nopad}/(10^{digits})}}\n\n{=(COMMENT):Splits and stores the integer and decimal values.}\n{=(resultInteger):{rounded(1):.}}\n{=(resultDecimals):{rounded(2):.}}\n\n{=(COMMENT):Adds a space between every character in the decimals.}\n{=(spacedDecimals):{{r}(, ):{resultDecimals}}}\n{=(spacedDecimals):{spacedDecimals(2+)}}\n{=(spacedDecimals):{spacedDecimals(+-1)}}\n\n{=(COMMENT):Parse the decimals up to the amount of decimals to return.}\n{=(finalDecimals):{join():{spacedDecimals(+{decimals})}}}\n\n{=(COMMENT):Formatted result, with the integer and conditional decimals, as well as its abbreviation from the returned group if any.}\n{=(formatted):{{r}(Z,):{{r}(.Z,):{{r}(.0Z,):{resultInteger}.{finalDecimals}Z}}{abbreviation}}}\n\n{=(COMMENT):Output Management}\n{=(msg.noNum):<:RedTick:699124870352732251> {user(mention)}, the argument you specified is not a number. Try again.}\n{=(msg.noArgs):Get a formatted amount or number from the one specified along with the command.\n\n**Example**```css\n{prefix}{tagname} 123456\n```**Returns**```css\n123.456k\n```}\n{=(msg.success):**Input**\n`{arg1}`\n**Formatted**\n`{formatted}`\n}\n\n{=(COMMENT):Output variables names.}\n{=(msg):noArgs noNum success}\n\n{=(COMMENT):Embed fields variables.}\n{=(em.title):Number Formatter}\n{=(em.description):{msg.{msg({index(true):0 {isNoArg} {isNaN} true})}}}\n{=(em.footer):{prefix}{tagname} [number] <decimals 0-3>}\n\n{=(COMMENT):Conditional embed color. Orange if not a number, otherwise blue.}\n{=(color.good):0076f5}\n{=(color.error):f57738}\n\n{=(color):good error good}\n{=(em.color):{color.{color({index(true):0 {isNoArg} {isNaN} true})}}}\n\n{embed(color):#{{r}(#,):{em.color}}}\n\n\n{=(debug):__Debug:__\n**Input Management**\ninput: {arg1}\ndefaultDecimals: `{defaultDecimals}`\nnopad: {nopad}\n\ndigitCount: {digitCount}\ngroup: {group}\ndigits: {digits}\n\n**Checks**\nisNaN: `{isNaN}`\nisNoArg: `{isNoArg}`\nisAllowedDecimal: `{isAllowedDecimal}`\n\n**Calculation**\nresultInteger: `{resultInteger}`\nresultDecimals: `{resultDecimals}`\n\nspacedDecimals: `{spacedDecimals}`\nfinalDecimals: {finalDecimals}\n\n**Output**\nTitle: {em.title}\nDescription: {em.description}\nFooter: `{em.footer}`\nEmbed Color: `{em.color}`\n}",
"embed": "{\"color\": 5198940, \"title\": \"{em.title}\", \"footer\": {\"text\": \"{em.footer}\"}, \"description\": \"{em.description}\"}",
"last_fetched": "2026-10-20T17:51:39.533Z"
}