Advanced Custom Commands (AST)
See when a custom command calls for AST—counters, per-viewer state, conditionals, loops, and function calls—and jump to the syntax, functions, execution, and recipes guides.
AST is the scripting layer built into custom commands. Whenever a static reply falls short, AST lets a single command save values, branch on conditions, call Twitch or overlay functions, and trigger other commands.
Do you need AST?
Section titled “Do you need AST?”Every command reply starts as plain text. The moment you add an AST prefix—$(, %(, *(, ^(, %del(, or #(—the bot evaluates that piece as AST.
| Plain text is enough when… | Use AST when… |
|---|---|
| The message stays the same every time | The reply tracks changing numbers, such as a counter |
| You only want a link or a fixed blurb | The command needs to remember values across runs |
| You want if/else branching, random picks, or loops | |
| You want to call a bot function or chain another command |
Plain text (no AST):
Join our Discord: example.com/discordAST (a counter that ticks up every run):
*( ^(#wins) ? %(#wins *(%(#wins) + 1)) : %(#wins 1) ) $(user) has %(#wins) wins!Here is how that command runs:
- Checks if
#winsalready exists. - If it does, increments it by 1; otherwise, initializes it to
1. - Replies with the updated total—for example,
Carlos has 3 wins!.
Important: variables are not built in
Section titled “Important: variables are not built in”DomDimaBot does not pre-populate AST variables for you.
- You define a variable by assigning it directly:
%(name value). - Built-in context comes from functions such as
$(user)and$(twitch.game), or from chat arguments like&p1.
%(#wins *(%(#wins) + 1)) $(user) now has %(#wins) wins!What AST is for
Section titled “What AST is for”- tracking counters and viewer progress
- crafting dynamic, personalized replies
- branching with if / else logic
- working with lists and loops
- running Twitch, moderation, availability, TTS, roulette, trigger, and EventSub functions
- scheduling delayed AST actions that persist across bot restarts
- chaining commands together
Start here
Section titled “Start here”The AST documentation is organized into four focused references:
-
- expression prefixes and how replies are parsed
- variables and storage tiers
- chat arguments and quoted strings
- escaping special characters
- lists, operators, conditionals, and loops
- deleting values, existence checks, command references, and timers
-
- user and Twitch data functions
- moderation, channel, availability, and roulette actions
- counters, clips, and followage
- polls, predictions, EventSub, TTS, triggers, and chat sending
-
AST Execution, Errors & Limits
- step-by-step parser execution
- delayed timer execution and restart recovery
- common error messages
- loop and recursion limits
- practical debugging tips
-
- copy-ready best practices
- initialize-or-increment counters
- existence guard checks
- per-viewer selectors
- timed actions and prediction/poll patterns
Quick mental model
Section titled “Quick mental model”Picture AST expressions as mini-scripts embedded inside a chat reply:
%(...)= read or write your own variables%del(...)= delete a variable or remove an item from a list$(...)= call a function*(...)= evaluate math, conditions, or a loop^(...)= check whether a variable or list slot exists#(...)= trigger another command after this one
Plan-aware features
Section titled “Plan-aware features”A few AST limits and storage options scale with the streamer’s plan:
| Feature | Free | Premium | Pro |
|---|---|---|---|
| Memory variables | Yes | Yes | Yes |
Cache variables (#, ##) | Yes | Yes | Yes |
Database variables (*, **) | Writes are ignored | Yes | Yes |
| Loops nested inside each other | 2 | 3 | 4 |
| Passes per loop | 25 | 50 | 100 |
Recommended workflow
Section titled “Recommended workflow”- Start with a plain text reply.
- Mix in viewer arguments such as
&p1. - Drop in functions like
$(user)or$(twitch.game). - Introduce variables only when the command actually needs state.
- Layer on conditionals and loops last.