Math & Text
isBoolean
$isBoolean
The function $isBoolean[value] checks if a value is a boolean word. It returns true if the value is exactly one of true, false, yes, no, on, off, enable or disable, and false in all other cases (number, text, etc.).
Syntax
$isBoolean[value]
Parameters
| Parameter | Description |
|---|---|
value |
The value to test. Required, exactly one argument. |
Return Value
- Type: Boolean
trueifvalueis one oftrue,false,yes,no,on,off,enable,disable.falseotherwise (number, any other text, or empty).
Behavior
- The comparison is exact and case-sensitive:
TRUE,Noand ` true(with a space) returnfalse`. - The eight words above are all accepted, including
yes/noandon/off. 0and1are not booleans (use$isNumber[]for those cases).
Examples
Validation in a condition
$if[$isBoolean[$message[1]]==true]
$sendMessage[✅ $message[1] is a valid boolean.]
$else
$sendMessage[❌ $message[1] is not a boolean. Expected: true or false.]
$endif
Checking a variable
$var[actif;true]
$if[$isBoolean[$var[actif]]==true]
$sendMessage[The variable is a boolean.]
$endif
Advanced type checking
$var[val;$message[1]]
$if[$isBoolean[$var[val]]==true]
$sendMessage[📌 Boolean detected: $var[val]]
$elseif[$isInteger[$var[val]]==true]
$sendMessage[🔢 Integer detected: $var[val]]
$elseif[$isNumber[$var[val]]==true]
$sendMessage[🔣 Number detected: $var[val]]
$else
$sendMessage[📝 Text detected: $var[val]]
$endif
Notes
$isBoolean[true]returnstrue.$isBoolean[false]returnstrue.$isBoolean[yes]returnstrue.$isBoolean[TRUE]returnsfalse(case-sensitive).$isBoolean[0]returnsfalse(0 is a number).$isBoolean[](empty) returnsfalse.
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.