// cooldown
cooldown2 := cooldown(Args{key: "[[ trigger.user_id ]]", duration: "1m"})
send_text_message(Args{
channel_id: trigger.channel_id,
message_content: "Seconds Left: " + cooldown2.seconds_left,
})
BlockLogic
Let the rest of the flow run once per key for a set time. While the key is on cooldown, the blocks inside run instead and the flow stops.
Use a key like the user's ID for a per-user cooldown. Duration is like 30s, 10m or 1d. "This Flow" keeps the cooldown to this flow, "Global" shares it with every flow using the same key. In a custom block, "This Flow" means the flow that called it.
Inputs
KeyRequired
What the cooldown is for, like a user ID.
Example: [[ trigger.user_id ]]
DurationRequired
How long the cooldown lasts (30s, 10m, 1d).
Example: 1m
Scope
Whether the cooldown is for this flow only, or shared by every flow.
OptionsThis FlowGlobal
While On Cooldown
While On Cooldown
Holds blocks
Outputs
Seconds Left
Seconds until the cooldown ends.
Example: 42
Ends At (Unix)
When the cooldown ends.
Example: 1700003600
Build a bot using blocks like Cooldown
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.
ID:
cooldownInputs
| Field | InventScript name | Value |
|---|---|---|
| Key | key | e.g. "[[ trigger.user_id ]]" |
| Duration | duration | e.g. "1m" |
| Scope | scope | "This Flow", "Global" |
| While On Cooldown | on_cooldown | blocks: func() { ... } |
Outputs
| Field | InventScript name | Value |
|---|---|---|
| Seconds Left | seconds_left | e.g. "42" |
| Ends At (Unix) | ends_at | e.g. "1700003600" |
Example InventScript
More logic blocks
Run LaterRun a custom block at a later time, like in 10 minutes or 3 days. Its inputs are saved when it's scheduled.Cancel Scheduled RunCancel a run scheduled with Run Later, by its key.Get Scheduled RunCheck whether a run is scheduled with a key, and when it runs.LoopRun the nested blocks a fixed number of times.While LoopRepeat blocks while a condition is true.If StatementCompare two values and run different blocks based on the result.Advanced ConditionalRun different blocks based on grouped comparisons.Conditional ValueCompare two values and output one of two values based on the result.FolderOrganize blocks into a folder. Creates a variable scope.BreakStop the current loop and continue with the blocks after it.ContinueSkip the rest of this loop iteration and move to the next one.Exit FlowStop the entire flow immediately. No further blocks will run.Call Custom BlockCall a custom block and use its returned outputs.ReturnReturn outputs from the current custom block and stop executing it.