for range advanced_custom_loop(Args{loop_range: "1,3-5,7"}) {
send_text_message(Args{channel_id: trigger.channel_id, message_content: "Next item"})
}
Custom Loop
LoopUtilities
Loop over a customized range of numbers.
Iteration Number is the absolute iteration number (1-based); Custom Iteration uses your provided values.
- Loop block: the blocks placed inside it run once for each item, and can use the current item's outputs.
Inputs
Loop RangeRequired
Examples: 1-10 10-1 1,2,3,4,20-25
Example: 1,3-5,7
Loop Body
Blocks to run each iteration.
Holds blocks
Outputs
Iteration Number
Zero-based iteration index.
Example: 0
Custom Iteration
Value from your custom range.
Example: 5
Build a bot using blocks like Custom Loop
Use this block in our visual flow editor. Bots are hosted 24/7 for free on inventor.bot.
Advanced Documentation
This documentation can be useful when using code mode. View as Markdown
ID:
advanced_custom_loop- Loop block: write
for item := range advanced_custom_loop(Args{...}) { ... }and read the current item's outputs fromitem. See loops.
Inputs
| Field | InventScript name | Value |
|---|---|---|
| Loop Range | loop_range | e.g. "1,3-5,7" |
| Loop Body | body | blocks: func() { ... } |
Outputs
| Field | InventScript name | Value |
|---|---|---|
| Iteration Number | iteration_number | e.g. "0" |
| Custom Iteration | custom_iteration | e.g. "5" |
Example InventScript
More utilities blocks
Log ErrorLog an error to the errors dashboard.Get Error DetailsRetrieve details of a logged error.Discord API PingMeasure current patency to the Discord API.Change Bot StatusUpdate the bot's presence and status text.Get Server CountGet the number of servers the bot is in.Check PermissionCheck if a permission exists in a bitfield.Member/Role Has PermissionsCheck if a member or role has specific permissions.Redact SecretRedact a secret (e.g. example -> e*****e).Get Bot DetailsGet cached details of the current branch's bot user.Generate Snowflake IDGenerate a unique Snowflake-like ID.Update Local VariableSet a local variable to a new value.Append New Line to Local VariableAppend text to a local variable on a new line.CommentAdd a note or comment to your flow. This block does nothing when run.Increment or Decrement Local VariableIncrement or decrement a numeric local variable by a value.