Blocks
All available TagScript blocks for creating dynamic tags
=
🔗
Variables are useful for choosing a value and referencing it later in a tag.
Variables can be referenced using brackets as any other block.
{=(<name>):<value>}
Examples
{=(prefix):!}
The prefix here is `{prefix}`.
# The prefix here is `!`.
{assign(day):Monday}
{if({day}==Wednesday):It's Wednesday my dudes!|The day is {day}.}
# The day is Monday.
math
🔗
Perform mathematical calculations. Supports operators: +, -, *, /, ^, %
Functions: sin, cos, tan, sqrt, abs, round, log, ln
Functions: sin, cos, tan, sqrt, abs, round, log, ln
{math:<expression>}
Examples
{math:5+5}
# 10
{m:2^8}
# 256
{calc:sqrt(144)}
# 12
random
🔗
Pick a random item from a list of strings, split by either
~ or ,.
An optional seed can be provided to always choose the same item.
{random([seed]):<list>}
Examples
{random:Carl,Harold,Josh} attempts to pick the lock!
# Josh attempts to pick the lock!
# Carl attempts to pick the lock!
# Harold attempts to pick the lock!
range
🔗
Pick a random number from a range separated by
-. The range is inclusive.
Use rangef to get a decimal number.
{range([seed]):<lowest-highest>}
Examples
Your lucky number is {range:10-30}!
# Your lucky number is 14!
{=(height):{rangef:5-7}}
I am guessing your height is {height}ft.
# I am guessing your height is 5.3ft.
if
🔗
Returns a message based on the passed expression. Payload must be split by
Operators: ==, !=, >, <, >=, <=
|.
Operators: ==, !=, >, <, >=, <=
{if(<expression>):<true message>|<false message>}
Examples
{if({args}==63):You guessed it!|Too {if({args}<63):low|high}, try again.}
# if args is 63: You guessed it!
# if args is 73: Too low, try again.
# if args is 14: Too high, try again.
any
🔗
Checks if any of the passed expressions are true. Split expressions with
|.
{any(<expr|expr|...>):<true>|<false>}
Examples
{any({args}==hi|{args}==hello):Hello {user}!|How rude.}
# if args is "hi": Hello sravan#0001!
all
🔗
Checks if all of the passed expressions are true. Split expressions with
|.
{all(<expr|expr|...>):<true>|<false>}
Examples
{all({args}>=100|{args}<=1000):You picked {args}.|Number must be 100-1000.}
# if args is 282: You picked 282.
50
🔗
Has a 50% chance to return the payload, 50% chance to return nothing.
{50:<message>}
Examples
{50:You won!}
# 50% chance: You won!
# 50% chance: (nothing)
replace
🔗
Replace specific characters in a string. Parameter should split by comma.
{replace(<original,new>):<message>}
Examples
{replace(o,i):welcome to the server}
# welcime ti the server
in / contains / index
🔗
in: checks if parameter is anywhere in payload
contains: strictly checks if parameter is in payload (split by whitespace)
index: finds the location of parameter in payload, returns -1 if not found
contains: strictly checks if parameter is in payload (split by whitespace)
index: finds the location of parameter in payload, returns -1 if not found
{in(<string>):<payload>}
Examples
{in(mute):How does it feel to be muted?}
# true
{index(food):I love to eat food. everyone does.}
# 4
strf
🔗
Convert and format timestamps. Use
unix to get current Unix timestamp.
Supports ISO and epoch timestamps. See strftime.org for format codes.
{strf([timestamp]):<format>}
Examples
{strf:%Y-%m-%d}
# 2021-07-11
{unix}
# 1629182008
substr
🔗
Extract a substring from text using start and end positions.
{substr(<start,end>):<text>}
urlencode
🔗
URL encode a string to make it safe for use in URLs.
{urlencode:<text>}
Examples
{urlencode:hello world}
# hello%20world
upper / lower
🔗
Convert text to UPPERCASE or lowercase.
{upper:<text>} or {lower:<text>}
Examples
{upper:hello world}
# HELLO WORLD
break
🔗
Stop parsing the tag at this point. Useful in conditional logic.
{break}
stop
🔗
Silently stop all tag execution. The tag will not send any output.
{stop}