Variables
tryLock
$tryLock — Takes a named lock and returns true, or returns false while another script holds it
Takes a named lock and returns `true`, or returns `false` while another script holds it. The lock expires by itself.
Syntax
$tryLock[name;(duration)]
Parameters
- name (text, required) — The lock name, per bot.
- duration (duration, optional) — Default 30s, at most 10m.
Return Value
truewhen the lock was taken,falsewhen it is held.
Usage
$tryLock[forge;10s] → "true"
Important Notes
- The lock lives in memory in the bot’s process: a restart releases it.
- Release it early with
$unlock.
Example
$onlyIf[$tryLock[forge;10s]==true;The forge is busy.]
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.