cmd.random.number
Returns a random integer between two numbers. The lower bound is inclusive and the upper bound is exclusive.
JavaScript
const { cmd } = require("syntx.js");
cmd.random.number(a, b);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
a | number | Yes | The lower bound (inclusive). |
b | number | Yes | The upper bound (exclusive). Must be greater than a. |
Returns
number : A random integer in the range [a, b).
Example
JavaScript
client.command({
name: "roll",
content: (message) => {
const result = cmd.random.number(1, 7);
message.reply(`You rolled a ${result}!`);
},
});Note
The upper bound b is not included in the possible results. To get a number between 1 and 6 inclusive, pass 1 and 7.
Warning
a must be strictly less than b. Passing equal or reversed values throws a SyntxError.