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

ParameterTypeRequiredDescription
textsstring[]YesArray 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.