percent

Privateunrated

Content

58 lines
{=(COMMENT):Sets the embed's side color to Discord's default embed's background.}
{embed(color):#2f3136}

{=(COMMENT):Emoji used as a "bullet point" for the instructions.}
{=(twr):<:twright:688074727167754320>}

{=(COMMENT):Prefix and tag name used. Will be shown in the instructions to fit the tag usage in your server.
Reminder: You can use "!tag alias per percent" to add an alias called "per" to the "percent" tag.}
{=(prefix):!}
{=(tagname):per}

{=(COMMENT):Instructions, with command usage examples and math formulas.}
{=(example):{twr} **What is x/y in p%?**
`{prefix}{tagname} 5/156` ─ `y = x * 100 / p`

{twr} **What is p% of x?**
`{prefix}{tagname} 5% of 5` ─ `y = x * p / 100`

{twr} **What is x increased/decreased by p%?**
`{prefix}{tagname} 5±2%` ─ `y = x * (100 + p / 100)`}

{=(COMMENT):Creates artificial named options depending on some conditions. Returns "fail" when none is met.}
{=(option):{if({in(/):{args}}==true):outof|{if({in(of):{args}}==true):perof|{if({in(+):{args}}==true):increase|{if({in(-):{args}}==true):decrease|fail}}}}}

{=(COMMENT):Sets the actual numbers to use in each of their corresponding formula later.}
{=(num.outof):{replace( ,):{args(1):/}} {replace( ,$&):{args(2):/}}}
{=(num.perof):{replace( ,):{args(1):%}} {replace( ,$&):{args(2): of }}}
{=(num.increase):{replace( ,):{args(1):+}} {replace( ,$&):{replace(%,):{args(2):+}}}}
{=(num.decrease):{replace( ,):{args(1):-}} {replace( ,$&):{replace(%,):{args(2):-}}}}

{=(COMMENT):Grabs the first and second item of the number variable above to actually be able to use them.}
{=(num1):{num.{option}(1)}}
{=(prenum2):{num.{option}(2)}}
{=(COMMENT):The "$&" part allows the user to type spaces and even text freely after their query for more versality.}
{=(num2):{prenum2(2):$&}}

{=(COMMENT):Math formula of each option.}
{=(form.outof):{m:{num1}*100/{num2}}Z%}
{=(form.perof):{m:{num2}*{num1}/100}}
{=(form.increase):{m:abs({num1}*(100+{num2})/100)}Z}
{=(form.decrease):{m:abs({num1}*(100-{num2})/100)}Z}

{=(COMMENT):Result, with .0 removed when the result should be truncated.}
{=(result):{replace(%,):{replace(Z,):{replace(.0Z,):{form.{option}}}}}}
{=(COMMENT):Rounded result, with a custom amount of decimals.}
{=(decimals):2}
{=(rresult):{m:round({result}*10^{decimals})/10^{decimals}}{if({option}==outof):%}}

{=(COMMENT):Conditional title depending on the option found.}
{=(title.outof):Percentage of {num1}/{num2}:}
{=(title.perof):{num1}% of {num2}:}
{=(title.increase):{num1} + {num2}%:}
{=(title.decrease):{num1} - {num2}%:}

{=(COMMENT):The *only* thing we call in the embed's field as the output. Returns the instructions if no argument or no available option is found, otherwise returns a custom title and the query's result.}
{=(title):{title.{option}}}
{=(output):{any({1}==|{option}==fail):{example}|**{title}**
{rresult}}}

Embed

1 line
{"color": 6317161, "description": "{output}"}
Raw JSON
{
  "id": 444624,
  "created_at": "2020-11-22T23:45:58.000Z",
  "tag_name": "percent",
  "nsfw": false,
  "owner_id": "717263605879406642",
  "uses": 11,
  "description": null,
  "restricted": false,
  "shared": false,
  "deleted": false,
  "safe": "unrated",
  "hidden": false,
  "guild_id": "733868402850004993",
  "sharer": "717263605879406642",
  "content": "{=(COMMENT):Sets the embed's side color to Discord's default embed's background.}\n{embed(color):#2f3136}\n\n{=(COMMENT):Emoji used as a \"bullet point\" for the instructions.}\n{=(twr):<:twright:688074727167754320>}\n\n{=(COMMENT):Prefix and tag name used. Will be shown in the instructions to fit the tag usage in your server.\nReminder: You can use \"!tag alias per percent\" to add an alias called \"per\" to the \"percent\" tag.}\n{=(prefix):!}\n{=(tagname):per}\n\n{=(COMMENT):Instructions, with command usage examples and math formulas.}\n{=(example):{twr} **What is x/y in p%?**\n`{prefix}{tagname} 5/156` ─ `y = x * 100 / p`\n\n{twr} **What is p% of x?**\n`{prefix}{tagname} 5% of 5` ─ `y = x * p / 100`\n\n{twr} **What is x increased/decreased by p%?**\n`{prefix}{tagname} 5±2%` ─ `y = x * (100 + p / 100)`}\n\n{=(COMMENT):Creates artificial named options depending on some conditions. Returns \"fail\" when none is met.}\n{=(option):{if({in(/):{args}}==true):outof|{if({in(of):{args}}==true):perof|{if({in(+):{args}}==true):increase|{if({in(-):{args}}==true):decrease|fail}}}}}\n\n{=(COMMENT):Sets the actual numbers to use in each of their corresponding formula later.}\n{=(num.outof):{replace( ,):{args(1):/}} {replace( ,$&):{args(2):/}}}\n{=(num.perof):{replace( ,):{args(1):%}} {replace( ,$&):{args(2): of }}}\n{=(num.increase):{replace( ,):{args(1):+}} {replace( ,$&):{replace(%,):{args(2):+}}}}\n{=(num.decrease):{replace( ,):{args(1):-}} {replace( ,$&):{replace(%,):{args(2):-}}}}\n\n{=(COMMENT):Grabs the first and second item of the number variable above to actually be able to use them.}\n{=(num1):{num.{option}(1)}}\n{=(prenum2):{num.{option}(2)}}\n{=(COMMENT):The \"$&\" part allows the user to type spaces and even text freely after their query for more versality.}\n{=(num2):{prenum2(2):$&}}\n\n{=(COMMENT):Math formula of each option.}\n{=(form.outof):{m:{num1}*100/{num2}}Z%}\n{=(form.perof):{m:{num2}*{num1}/100}}\n{=(form.increase):{m:abs({num1}*(100+{num2})/100)}Z}\n{=(form.decrease):{m:abs({num1}*(100-{num2})/100)}Z}\n\n{=(COMMENT):Result, with .0 removed when the result should be truncated.}\n{=(result):{replace(%,):{replace(Z,):{replace(.0Z,):{form.{option}}}}}}\n{=(COMMENT):Rounded result, with a custom amount of decimals.}\n{=(decimals):2}\n{=(rresult):{m:round({result}*10^{decimals})/10^{decimals}}{if({option}==outof):%}}\n\n{=(COMMENT):Conditional title depending on the option found.}\n{=(title.outof):Percentage of {num1}/{num2}:}\n{=(title.perof):{num1}% of {num2}:}\n{=(title.increase):{num1} + {num2}%:}\n{=(title.decrease):{num1} - {num2}%:}\n\n{=(COMMENT):The *only* thing we call in the embed's field as the output. Returns the instructions if no argument or no available option is found, otherwise returns a custom title and the query's result.}\n{=(title):{title.{option}}}\n{=(output):{any({1}==|{option}==fail):{example}|**{title}**\n{rresult}}}",
  "embed": "{\"color\": 6317161, \"description\": \"{output}\"}",
  "last_fetched": "2026-10-20T23:14:48.031Z"
}