Control Flow
stop
$stop — Stop the Script
$stop ends the current script immediately. Nothing after it runs.
Syntax
$stop
$stop takes no argument ($stop[x] is refused: Invalid argument count).
Behavior
- The rest of the script is skipped, even inside
$ifor a loop: in a$forloop, the loop ends at once. - What was written before
$stop(text, embeds, components) is still sent as the response.$stopdoes not discard it. (To discard it and replace it with a message, use$onlyIf[condition;message].) - Messages already sent with
$sendMessagestay sent. $stopis not an error: inside$try, the$catchblock does not run, and the script ends.- Inside code run by
$eval,$stoponly ends the evaluated code; the script that called$evalgoes on.
$stop vs $skipActions
| Feature | $stop | $skipActions[n] |
|---|---|---|
| Effect | Ends the current script | Skips the next n actions of the current block |
| Resumes afterwards | No | Yes, after the skipped actions |
| In loops | Ends the loop and the script | Skips actions of the current iteration only |
Common Pitfalls
- Placing important code after
$stop: it will never run. - Using
$stopinside$tryand expecting$catchto run.
Examples
Halting for a condition
$if[$message==]
Please provide an argument.
$stop
$endif
You wrote: $message
Leaving a loop and the script
$for[5]
Step $loopCount
$if[$i==2]
$stop
$endif
$endFor
Done
Try it
Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.