fix choose to optionally work with first line
This commit is contained in:
parent
22821dbd55
commit
05ed4d9c5c
|
@ -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,
|
||||
|
|
Reference in New Issue