Introduction to Variables in Chat Commands
Chat commands support variables in a dynamic way. Variables are placeholders that can be used in chat commands to represent a specific value or piece of information. When a command is triggered, these variables are replaced with the actual values they represent.
For example, in the command ${uptime shroud}
, shroud
is a variable representing a username. When this command is executed, the uptime
of the user shroud
is returned.
Variables make chat commands more flexible and powerful, allowing for a wide range of interactions and functionalities.
In addition to the ${}
syntax, we also support the $()
syntax for variables. Both of these syntaxes can be used interchangeably in chat commands. For instance, the command ${uptime shroud}
can also be written as $(uptime shroud)
.
$(7tvemotes)
Lists active 7TV emotes in the channel.
Parameters
This variable does not take any parameters.
Example Input
$(7tvemotes)
Example Output
LULW KEKW 5Head DinkDonk PogU
$(ai)
This variable is currently in beta. It may be subject to change.
Outputs a response from the StreamElements AI. The AI will attempt to generate a response based on the input query.
Ratelimits & Restrictions
The AI variable is ratelimited to prevent abuse. The following ratelimits apply:
Type | Amount | Reset Time |
---|---|---|
User | 1 | 60 seconds |
Affiliate | 5 | 60 seconds |
Partner | 15 | 60 seconds |
Parameters
This variable accepts a query as input. If no query is provided, the variable will error.
Example Input
${ai You are a wholesome helper. ${1:}}
Example Output
Shroud is a popular Twitch streamer known for his incredible skills in first-person shooter games like Call of Duty and Apex Legends He is also a former professional esports player PogChamp
$(args)
Outputs an argument from the command.
Parameters
This variable does not take any parameters.
Example Input
$(1)
Example Output
Hello
$(args.emote)
Outputs an argument only if it is an emote.
Parameters
This variable does not take any parameters.
Example Input
$(1.emote)
Example Output
Kappa
$(args.word)
Outputs an argument only if it does not contain symbols.
Parameters
This variable does not take any parameters.
Example Input
$(1.word)
Example Output
Hello
$(bttvemotes)
Lists the active BetterTTV emotes in the channel.
Parameters
This variable does not take any parameters.
Example Input
$(bttvemotes)
Example Output
LULW KEKW 5Head PogU
_____________________________________________________
$(channel)
To use a channel variable, include it in your chatbot command using the $() syntax. The variable will be automatically replaced with the corresponding value when the message is sent.
Available $(channel) Variables
$(channel)
Displays the name of the channel.
Example:
Welcome to $(channel)!
Output:
Welcome to coolstreamer123!
$(channel.viewers)
Shows the current viewer count. Returns "not live" if offline.
Example:
We currently have $(channel.viewers) viewers!
Output:
We currently have 1337 viewers!
$(channel.followers)
Displays the total follower count.
Example:
Thank you to our $(channel.followers) amazing followers!
Output:
Thank you to our 50000 amazing followers!
$(channel.subs)
Shows the total subscriber count.
Example:
We've reached $(channel.subs) subscribers!
Output:
We've reached 500 subscribers!
$(channel.subpoints)
Displays the total subscriber points.
Example:
Current sub points: $(channel.subpoints)
Output:
Current sub points: 1250
$(channel.display_name)
Shows the channel's display name, which may differ in capitalization.
Example:
You're watching $(channel.display_name)'s stream!
Output:
You're watching CoolStreamer123's stream!
$(channel.alias)
Displays the channel's alias.
Example:
Channel alias: $(channel.alias)
Output:
Channel alias: CS123
$(channel.provider)
Shows the channel's streaming provider (e.g., Twitch, YouTube).
Example:
We're live on $(channel.provider)!
Output:
We're live on Twitch!
$(channel.provider_id)
Displays the channel's Twitch or YouTube ID.
Example:
Channel ID: $(channel.provider_id)
Output:
Channel ID: 12345678
$(channel.id)
Shows the channel's internal StreamElements ID.
Example:
StreamElements ID: $(channel.id)
Output:
StreamElements ID: 5f7b1f9e8e1c3a0001f1e123
$(channel.title)
Displays the current stream title or status.
Example:
Current stream title: $(channel.title)
Output:
Current stream title: Speedrunning Mario 64 - Day 3!
$(channel.game)
Shows the current game being played. Returns "no game" if not set.
Example:
We're currently playing: $(channel.game)
Output:
We're currently playing: Super Mario 64
$(channel.chatters)
Displays the current number of chatters.
Example:
Active chatters: $(channel.chatters)
Output:
Active chatters: 850
$(channel.uptime)
Shows the current stream uptime. Returns "not live" if offline.
Example:
We've been live for: $(channel.uptime)
Output:
We've been live for: 3 hours 27 minutes
Best Practices
- Use channel variables to provide real-time information about your stream in chat commands.
- Combine multiple variables to create comprehensive stream status messages.
- Always provide clear examples and explanations when creating custom commands using these variables.
Troubleshooting
- If a variable returns unexpected results, ensure you're using the correct syntax.
- Remember that some variables may return specific values when the stream is offline or information is not available.
Related Commands
- $(user): Displays information about the user who triggered the command
- $(touser): Refers to the target user in commands that mention other users
FAQ
Q: How often are these variables updated?
A: Channel variables are updated in real-time, reflecting the most current information available from Twitch.
Q: What happens if a variable can't retrieve the information?
A: If there's an error retrieving the information, most variables will return "0" or "error". Specific cases include:
- $(channel.viewers) and $(channel.uptime) return "not live" if the channel is offline
- $(channel.game) returns "no game" if no game is set
$(count)
Displays the command name counter and increments by one.
Parameters
You may optionally specify the name of a counter to display. You may also optionally set the counters value or increment amount. To increment the counter, prefix the amount to increment by with +/-
Example Input
$(count example +1)
Example Output
420
$(customapi.url)
Makes a request to a specified URL and the response is returned.
Parameters
This variable does not take any parameters.
Example Input
$(customapi.https://decapi.me/youtube/latest_video?id=UCjerlCIbLPQwSnYlClkjDXg)
Example Output
STREAMELEMENTS PATCH NOTES - SEPTEMBER 10, 2023 #streamelements #updates #patchnotes - https://youtu.be/-q_q37PoaM8
$(ffzemotes)
Lists the active FrankerFaceZ emotes in the channel.
Parameters
This variable does not take any parameters.
Example Input
$(ffzemotes)
Example Output
LULW KEKW 5Head PogU
$(game)
Displays the current game
Parameters
-
username
(optional): The username of the account you want to check. If no username is provided, the command will check the game of the current channel.
Example Input
${game}
Example Output
Valorant
$(getcount)
Returns the current value of a counter without incrementing it.
Parameters
This variable takes the name of the counter to get as a parameter.
Example Input
$(getcount example)
Example Output
420
$(leagueoflegends)
Outputs the summoner rank and LP of a specified League of Legends player.
League of legends is transitioning to Riot IDs. This means that you will need to use your Riot ID instead of your summoner name.
During the transition period, you can use either your Riot ID or your summoner name. After the transition period, you will only be able to use your Riot ID.
Parameters
This variable takes two parameters:
- Region
- Riot ID/Summoner Name
Supported Regions:
br (Brazil)
eune (Europe Nordic & East)
euw (Europe West)
jp (Japan)
kr (Republic of Korea)
lan (Latin America North)
las (Latin America South)
na (North America)
oce (Oceania)
pbe (Public Beta Environment)
ph (Philippines)
ru (Russia)
sg (Singapore)
th (Thailand)
tw (Taiwan)
tr (Turkey)
vn (Vietnam)
Example Input
$(leagueoflegends styler#euw euw)
Example Output
Current Rank: Challenger I (1229 LP)
$(math)
Outputs the result of a math.js expression.
Parameters
This variable takes a math.js expression as a parameter. You can also use math.js functions like round()
, floor()
, log()
, random()
, etc.
Example Input
${math 2 + 2}
${math round(10/3)}
${math random(1,10)}
Example Output
4
3
7.525986609745358
$(msgid)
Outputs the message ID of the message that triggered the command.
Parameters
This variable does not take any parameters.
Example Input
$(msgid)
Example Output
bcc9b4bc-566d-4f14-a57d-a86c1c3196f8
$(pathescape)
Escapes a string for use in a URL path
Parameters
This variable accepts a string as input. If no string is provided the variable will error.
Example Input
api.com/${pathescape ${1}}
Example Output
api.com/%F0%9F%85%B1
$(pointsname)
Displays the loyalty currency name.
Parameters
This variable does not take any parameters.
Example Input
$(pointsname)
Example Output
memecoins
$(queryescape)
Outputs the query string escaped for use in a URL.
Parameters
This variable takes the string to query escape as a parameter.
Example Input
google.com/search?q=${queryescape ${1:}}
Example Output
google.com/search?q=dank+memes
$(quote)
Displays a randomly saved quote.
Parameters
Takes an optional quote ID to display.
Example Input
$(quote 3)
Example Output
#3 some dank quote
$(random)
Allows you to generate random output from a list of options.
$(random) or $(random.number)
Displays a random number generated from X to Y.
Parameters
This variable accepts two numbers as input. If no numbers are provided the variable will error.
Example Input
${random 1-10}
${random.number 1-10}
Example Output
7
$(random.emote)
Displays a random emote from a list of emotes.
Parameters
This variable accepts no arguments.
Example Input
${random.emote}
Example Output
Kappa
$(random.chatter)
Displays a random chatter from a list of chatters.
Parameters
This variable accepts no arguments.
Example Input
${random.chatter}
Example Output
XDBot
$(random.pick)
Displays a random item from a list of items.
Parameters
This variable accepts a list of items as input. If no items are provided the variable will error.
Example Input
${random.pick '1' '2' 'rare pepe'}
Example Output
rare pepe
$(repeat)
Repeats a phrase x times
Parameters
This variable accepts a number and a phrase as input. If no number is provided the variable will error.
Example Input
${repeat 3 ${1}}
Example Output
Kappa Kappa Kappa
$(sender)
The $(sender)
variable in StreamElements Chatbot always refers to the user who triggered the command or message. It provides access to various user-related information such as username, loyalty points, ranks, and activity timestamps.
KEY POINT:$(sender)
always refers to the command trigger and doesn't accept arguments. If you need to query information about other users, use the $(user)
variable instead.
Aliases:$(source)
can also be used as an alias for $(sender)
.
Usage
To use the $(sender)
variable, include it in your chat message or command response using the $(...)
syntax. For example, $(sender)
will display the command trigger's display name.
Available $(sender)
Variables
$(sender)
Displays the message sender's display name.
Example:
Current user: $(sender)
Output:
Current user: Styler
$(sender.name)
Displays the sender's display name in lowercase letters.
Example:
Current user: $(sender.name)
Output:
Current user: styler
$(sender.points)
Displays the sender's loyalty currency owned.
Example:
$(sender) has $(sender.points) points
Output:
Styler has 100 points
$(sender.points_rank)
Displays the sender's rank on the loyalty currency leaderboard.
Example:
$(sender) is rank $(sender.points_rank) on the leaderboard
Output:
Styler is rank 5/283 on the leaderboard
$(sender.points_alltime_rank)
Displays the sender's rank on the all-time loyalty currency leaderboard.
Example:
$(sender) is rank $(sender.points_alltime_rank) on the all-time leaderboard
Output:
Styler is rank 5/283 on the all-time leaderboard
$(sender.level)
Displays the sender's access level.
Example:
$(sender) is level $(sender.level)
Output:
Styler is level 2000
$(sender.lastmessage)
Displays the sender's last typed message in the chat.
Example:
$(sender) last typed: $(sender.lastmessage)
Output:
Styler last typed: !points
$(sender.lastseen)
Displays the time that the sender was most recently seen in the viewer list or chat.
Example:
$(sender) was last seen $(sender.lastseen) ago
Output:
Styler was last seen 13m 15s ago
$(sender.lastactive)
Displays the time that the sender most recently typed a message in the chat.
Example:
$(sender) was last active $(sender.lastactive) ago
Output:
Styler was last active 13m 15s ago
$(sender.time_online)
Displays the total time the sender has spent watching the stream.
Example:
$(sender) has been watching the stream for $(sender.time_online)
Output:
Styler has been watching the stream for 27m 16s
$(sender.time_online_rank)
Displays the sender's rank on the leaderboard for online time watched.
Example:
$(sender) is rank $(sender.time_online_rank) on the online leaderboard
Output:
Styler is rank 5/283 on the online leaderboard
$(sender.time_offline_rank)
Displays the sender's rank on the leaderboard for offline time watched.
Example:
$(sender) is rank $(sender.time_offline_rank) on the offline leaderboard
Output:
Styler is rank 5/283 on the offline leaderboard
Best Practices
- Use
$(sender)
when you only need information about the command trigger. - If you need to reference other users or allow flexible user queries, use the
$(user)
variable instead.
Troubleshooting
- If a variable returns unexpected results, ensure you're using the correct syntax and that the user exists in your channel's database.
- Remember that
$(sender)
variables don't accept arguments. If you need to query other users, use$(user)
instead.
$(setgame)
Changes the stream game.
Parameters
This variable accepts a game name as input. If no game name is provided the variable will error.
Example Input
${setgame "world of warcraft"}
Example Output
world of warcraft
Example Error
something went wrong
$(settitle)
Changes the stream title.
Parameters
This variable accepts a title as input. Quotation marks are required if the title contains spaces.
Example Input
${settitle "ELECTRIC BODYBUILDER FROM RUSSIA"}
Example Output
ELECTRIC BODYBUILDER FROM RUSSIA
Example Error
something went wrong
$(stockprice)
Displays the current stock price of a given stock symbol.
Parameters
You must specify the stock symbol to display the price of.
Example Input
${stockprice AAPL}
Example Output
173.93
$(teamfighttactics)
The $(teamfighttactics) variable allows you to retrieve and display the current rank and LP (League Points) of a specified Teamfight Tatics player using the StreamElements Chatbot.
Usage:
To use this variable, you need to provide two parameters: the region and the player's Riot ID.
$(teamfighttactics <region> <Riot ID>)
Example Input
$(teamfighttactics euw styler#euw)
$(teamfighttactics na Doublelift#na1)
Example Output
Current Rank: Gold IV (32 LP)
$(time)
$(time.timezone)
Displays the time in the given timezone. A list can be found here Timezones.
Parameters
This variable accepts a timezone as input. If no timezone is provided the variable will error.
Example Input
${time.CET}
Example Output
15:04
Example Error
unknown time zone lol
$(time.until)
Displays a countdown until an inputted UTC timestamp.
Parameters
This variable accepts a timezone as input. If no timezone is provided the variable will error.
Example Input
next stream in ${time.until 19:00}
Example Output
next stream in 7 hours 59 mins
$(title)
Displays the channel’s title
Parameters
-
username
(optional): The username of the account you want to check. If no username is provided, the command will return the title of the current channel.
Example Input
${title}
Example Output
Playing Spyro!
$(touser)
Displays either the first word after the command $[1], or the sender’s name. This is an alias for $(1|sender)
Parameters
This variable accepts a word as input. If no word is provided, the variable will default to the user who triggered the command.
Example Input
${touser}
Example Output
styler
$(twitchemotes)
Outputs all available Twitch subscriber emotes
Parameters
This variable does not take any parameters.
Example Input
Subscriber emotes: ${twitchemotes}
Example Output
Subscriber emotes: stylerXD, stylerRIP
$(uptime)
Displays the uptime of the current stream
Parameters
This variable accepts a username as input. If no username is provided, the variable will default to the user who triggered the command.
Example Input
${uptime shroud}
Example Output
1 hour 6 mins
$(user) Variable
The $(user)
variable in StreamElements Chatbot allows you to access and display various user-related information in your chat messages and commands. These variables provide data such as usernames, loyalty points, ranks, and activity timestamps.
KEY POINT:$(user)
can accept an optional username argument to retrieve information about any user, not just the command sender. When used without arguments, it behaves similarly to $(sender)
.
Usage
To use the $(user)
variable, include it in your chat message or command response using the $(...)
syntax. For example, $(user)
will display the user's display name.
-
Without argument:
$(user)
refers to the command sender. -
With argument:
$(user username)
refers to the specified user.
Available $(user)
Variables
$(user)
Displays the user's display name.
Example:
Current user: $(user)
Current user: $(user adeithe)
Output:
Current user: Styler
Current user: Adeithe
$(user.name)
Displays the user's display name in lowercase letters.
Example:
Current user: $(user.name)
Current user: $(user.name adeithe)
Output:
Current user: styler
Current user: adeithe
$(user.points)
Displays the user's loyalty currency owned.
Example:
$(user) has $(user.points) points
$(user adeithe) has $(user.points adeithe) points
Output:
Styler has 100 points
Adeithe has 150 points
$(user.points_rank)
Displays the user's rank on the loyalty currency leaderboard.
Example:
$(user) is rank $(user.points_rank) on the leaderboard
$(user adeithe) is rank $(user.points_rank adeithe) on the leaderboard
Output:
Styler is rank 5/283 on the leaderboard
Adeithe is rank 3/283 on the leaderboard
$(user.points_alltime_rank)
Displays the user's rank on the all-time loyalty currency leaderboard.
Example:
$(user) is rank $(user.points_alltime_rank) on the all-time leaderboard
$(user adeithe) is rank $(user.points_alltime_rank adeithe) on the all-time leaderboard
Output:
Styler is rank 5/283 on the all-time leaderboard
Adeithe is rank 3/283 on the all-time leaderboard
$(user.level)
Displays the user's access level.
Example:
$(user) is level $(user.level)
$(user adeithe) is level $(user.level adeithe)
Output:
Styler is level 2000
Adeithe is level 2500
$(user.lastmessage)
Displays the user's last typed message in the chat.
Example:
$(user) last typed: $(user.lastmessage)
$(user adeithe) last typed: $(user.lastmessage adeithe)
Output:
Styler last typed: !points
Adeithe last typed: Hello everyone!
$(user.lastseen)
Displays the time that a user was most recently seen in the viewer list or chat.
Example:
$(user) was last seen $(user.lastseen) ago
$(user adeithe) was last seen $(user.lastseen adeithe) ago
Output:
Styler was last seen 13m 15s ago
Adeithe was last seen 5m 30s ago
$(user.lastactive)
Displays the time that a user most recently typed a message in the chat.
Example:
$(user) was last active $(user.lastactive) ago
$(user adeithe) was last active $(user.lastactive adeithe) ago
Output:
Styler was last active 13m 15s ago
Adeithe was last active 5m 30s ago
$(user.time_online)
Displays the total time a user has spent watching the stream.
Example:
$(user) has been watching the stream for $(user.time_online)
$(user adeithe) has been watching the stream for $(user.time_online adeithe)
Output:
Styler has been watching the stream for 27m 16s
Adeithe has been watching the stream for 1h 15m 45s
$(user.time_online_rank)
Displays the user's rank on the leaderboard for online time watched.
Example:
$(user) is rank $(user.time_online_rank) on the online leaderboard
$(user adeithe) is rank $(user.time_online_rank adeithe) on the online leaderboard
Output:
Styler is rank 5/283 on the online leaderboard
Adeithe is rank 2/283 on the online leaderboard
$(user.time_offline_rank)
Displays the user's rank on the leaderboard for offline time watched.
Example:
$(user) is rank $(user.time_offline_rank) on the offline leaderboard
$(user adeithe) is rank $(user.time_offline_rank adeithe) on the offline leaderboard
Output:
Styler is rank 5/283 on the offline leaderboard
Adeithe is rank 2/283 on the offline leaderboard
Best Practices
- Use
$(user)
without arguments when you need information about the command trigger. - Use
$(user username)
when you need to reference other users or allow flexible user queries. - Always provide clear examples and explanations when creating custom commands using these variables.
Troubleshooting
- If a variable returns unexpected results, ensure you're using the correct syntax and that the user exists in your channel's database.
- Remember that
$(user)
variables can accept arguments. If you only need information about the command sender, consider using$(sender)
instead.
$(weather)
Displays the current weather conditions for a given location.
Parameters
-
location
: The location to get the weather for. (i.e. New York, NY)
Example Input
$(weather "New York, NY")
Example Output
New York, United States of America: 🌜 13.9 °C (57.0 °F). Feels like 12.6 °C (54.8 °F). Overcast. Wind is blowing from the Northeast at 3.6 km/h (2.2 mp/h). 81% humidity. Visibility: 16 km (9 miles). Air pressure: 1026 hPa.