Skip to content
Control Flow loopIteration

$loopIteration

Alias of $loopIndex: the zero-based index of the current iteration of the innermost loop ($for, $loop, $while, $jsonForEach).

Syntax

$loopIteration

Parameters

None.

Return value

  • 0, 1, 2… for the successive iterations (not 1-based despite the name; use $loopCount for that).
  • Outside a loop, the error “Loop index outside a loop.” is raised.

Examples

$for[3]
Iteration $loopIteration
$endFor

Notes

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.