cmd.random.text
Picks and returns a random item from an array of strings.
JavaScript
const { cmd } = require("syntx.js");
cmd.random.text(texts);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
texts | string[] | Yes | Array of strings to pick from. Must not be empty. |
Returns
string : A randomly selected item from the array.
Example
JavaScript
client.command({
name: "quote",
content: (message) => {
const quote = cmd.random.text([
"Keep it simple.",
"Ship it.",
"Done is better than perfect.",
]);
message.reply(quote);
},
});Warning
Passing an empty array throws a SyntxError. Make sure the array has at least one item.