fix choose to optionally work with first line

This commit is contained in:
Nathaniel Mason 2022-04-18 18:00:56 +01:00
parent 22821dbd55
commit 05ed4d9c5c
1 changed files with 6 additions and 5 deletions

View File

@ -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,