Skip to content

Command Arguments

Syntax
$(1), $(1:), $(1:3)
Arguments
None

Argument tokens let your custom commands use the words of the message that triggered them. This enables dynamic responses based on user input, enhancing the interactivity of your chatbot.

!command add !greet Hello, $(1)!
Example chat
ViewerName:!greet World
partner badgemoderator badgeStreamElements:Hello, World!

Words are numbered from the start of the message, and word 0 is the command trigger itself, so $(1) is the first argument after the command.

Token Output
$(N) The Nth word of the message
$(N:) Words N through the end of the message
$(N:M) Words N through M, inclusive
$(:M) Words 0 (the trigger) through M

Both bracket styles work everywhere and are fully interchangeable: $(1) and ${1} are identical, as are $(1:) and ${1:}. Argument tokens can also be nested freely inside other variables, e.g. $(weather ${1:}).

If the requested word doesn’t exist in the message, the output is blank.

Introducing a user

!cmd add !introduce $(1) is $(2) years old
Example chat
ViewerName:!introduce Alice 25
partner badgemoderator badgeStreamElements:Alice is 25 years old

Using everything after the command

!cmd add !announce Attention everyone: $(1:)
Example chat
ViewerName:!announce the stream starts in 10 minutes
partner badgemoderator badgeStreamElements:Attention everyone: the stream starts in 10 minutes

Use a pipe to provide a default value when an argument is missing:

!cmd add !hug $(sender) hugs $(1|everyone)!
Example chat
ViewerName:!hug
partner badgemoderator badgeStreamElements:StreamFan123 hugs everyone!

Wherever a variable takes space-separated inputs, quotes group several words into a single input. Single quotes '...', double quotes "...", and backticks `...` all behave identically.

A token can take an optional validator, which makes it output the word only if it passes a check:

$(1 username) (alias: $(1 word)) outputs the argument only if it looks like a username — letters, digits, and underscores, optionally prefixed with @, up to 30 characters.

!cmd add !so Check out $(1 username)'s channel!
Example chat
ViewerName:!so CoolStreamer
partner badgemoderator badgeStreamElements:Check out CoolStreamer's channel!

$(1 emote) outputs the argument only if it is an emote in the message.

!cmd add !emote $(1 emote)
Example chat
ViewerName:!emote Kappa
partner badgemoderator badgeStreamElements:Kappa

The dot form also works for validators, e.g. $(1.word) or $(1.emote).

  • $(touser): The first word after the command, falling back to the sender’s name
  • $(sender): The name of the user who triggered the command
  • $(user): Information about a user, such as points and rank

Q: What happens if I try to access an argument that wasn’t provided?

A: If you try to access an argument that wasn’t provided (e.g., $(2) when only one argument was given), the output will be blank. Use a pipe fallback like $(2|default) to output something else instead.

Q: Can I write a range backwards, like $(3:1)?

A: No. Reversed or negative ranges are not valid and will render as literal text.