Math & Text
isInteger
$isInteger
The function $isInteger[value] checks if a value is an integer (without decimals). It accepts positive integers, negative integers and zero.
Syntax
$isInteger[value]
Parameters
| Parameter | Description |
|---|---|
value |
The value to test. Required, exactly one argument. |
Return Value
- Type: Boolean
trueifvalueis an integer (e.g.42,-7,0)falseifvalueis a decimal, text, or empty.
Behavior
- Decimal numbers (
3.14,2.0) returnfalse. - Scientific notation (
1e3) returnsfalse. 0is a valid integer; a+or-sign is accepted (+5,-10).- Spaces around the number are ignored:
$isInteger[ 5 ]→true. - A hexadecimal integer with the
0xprefix is also accepted:$isInteger[0xFF]→true(0b11isfalse). - Integers beyond the 64-bit signed range (
99999999999999999999) returnfalse. - Unlike
$isNumber[], it does not check finiteness or decimal formats.
Examples
Parameter Validation
$if[$isInteger[$message[1]]==true]
$sendMessage[✅ $message[1] is a valid integer.]
$else
$sendMessage[❌ Please provide an integer.]
$endif
Pagination (Validation)
$var[page;$message[1]]
$if[$isInteger[$var[page]]==true]
$if[$var[page]>=1]
$sendMessage[📄 Displaying page $var[page]...]
$else
$sendMessage[❌ Page must be >= 1.]
$endif
$else
$sendMessage[❌ Invalid parameter. Usage: !page <number>]
$endif
Custom Counter
$var[number;$message[1]]
$if[$isInteger[$var[number]]==true]
$for[i=1;i<=$var[number];i++]
Counter: $i
$endfor
$else
$sendMessage[Please enter an integer.]
$endif
Notes
$isInteger[42]returnstrue.$isInteger[-10]returnstrue.$isInteger[3.14]returnsfalse.$isInteger[abc]returnsfalse.- To also accept decimals, use
$isNumber[].
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.