$(user)
- Syntax
$(user [username])- Arguments
- Optional
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.
Use it
Section titled “Use it”!command add !watchtime $(user) has been watching the stream for $(user.time_online) and is rank $(user.time_online_rank) on the leaderboardTo 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 first username typed after the command, or the command sender if none was given - With argument:
$(user username)refers to the specified user
Every variable below accepts the same optional username argument, e.g. $(user.points ModUser).
Available variables
Section titled “Available variables”| Variable | Description | Notes |
|---|---|---|
$(user) |
User’s display name | |
$(user.name) |
User’s login name in lowercase letters | This is the account’s login name, not the display name |
$(user.twitchid) |
User’s platform user ID | |
$(user.points) |
User’s loyalty currency owned | |
$(user.points_rank) |
User’s rank on the loyalty currency leaderboard | Returned as rank/total, e.g. 5/283; <error> if the lookup fails |
$(user.points_alltime_rank) |
User’s rank on the all-time loyalty currency leaderboard | Returned as rank/total, e.g. 5/283; <error> if the lookup fails |
$(user.level) |
User’s access level as a number | See access levels below |
$(user.lastmessage) |
User’s last typed message in the chat | Outputs a single space if no message is stored |
$(user.lastseen) |
Time since the user was most recently seen in the viewer list or chat | Returned as a duration, e.g. 5 mins 30 secs; <not found> if never recorded |
$(user.lastactive) |
Time since the user most recently typed a message in the chat | Returned as a duration, e.g. 5 mins 30 secs; <not found> if never recorded |
$(user.time_online) |
The user’s total watchtime — time spent watching the stream | Returned as a duration, e.g. 2 hours 30 mins |
$(user.time_online_rank) |
User’s rank on the leaderboard for online time watched | Returned as rank/total, e.g. 5/283; <error> if the lookup fails |
$(user.time_offline) |
Total time the user has spent in chat while the stream is offline | Returned as a duration, e.g. 2 hours 30 mins |
$(user.time_offline_rank) |
User’s rank on the leaderboard for offline time watched | Returned as rank/total, e.g. 5/283; <error> if the lookup fails |
Durations are written out in full words: secs, mins, hours, days, months, and years — for example 1 day 4 hours or 27 mins 16 secs. Smaller units are dropped as larger ones appear.
Access levels
Section titled “Access levels”$(user.level) returns the user’s access level as a number:
| Level | Role |
|---|---|
100 |
Everyone |
250 |
Subscriber |
300 |
Regular |
400 |
VIP |
500 |
Moderator |
1000 |
Super Moderator |
1500 |
Broadcaster |
Examples
Section titled “Examples”Querying another user by name
$(user ModUser) was last seen $(user.lastseen ModUser) ago and last typed: $(user.lastmessage ModUser)A points command that lets viewers check anyone’s balance
!command add !points $(user) has $(user.points) points and is rank $(user.points_rank) on the leaderboardRelated Variables
Section titled “Related Variables”$(sender): Information specifically about the command sender.