From 05ed4d9c5c3ad6d81c91c41cec096470d34c9c35 Mon Sep 17 00:00:00 2001 From: Nathaniel Mason Date: Mon, 18 Apr 2022 18:00:56 +0100 Subject: [PATCH] fix choose to optionally work with first line --- commands/choose.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/commands/choose.js b/commands/choose.js index 178ff5d..99e3aaf 100644 --- a/commands/choose.js +++ b/commands/choose.js @@ -4,13 +4,14 @@ module.exports = { description: "Give some lines of input, and get one back at random", async execute(client, message, _, config) { - var strarr = message.content.split(/\s*\n\s*/); - strarr[0] = strarr[0].slice(this.name.length + config.prefix.length); - const answer = strarr[Math.floor(Math.random() * strarr.length)]; - - if (answer === "") { + var [head, ...options] = message.content.split(/\s*\n\s*/); + head = head.slice(this.name.length + config.prefix.length); + if (head) options.push(head); + + if (!options.length) { await message.channel.send(client.generateErrorMessage("You need to provide some input!", message.author.displayAvatarURL())); } else { + const answer = options[Math.floor(Math.random() * options.length)]; await message.channel.send({embed: { "title": "I have made my decision:", "description": answer,