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",
|
description: "Give some lines of input, and get one back at random",
|
||||||
|
|
||||||
async execute(client, message, _, config) {
|
async execute(client, message, _, config) {
|
||||||
var strarr = message.content.split(/\s*\n\s*/);
|
var [head, ...options] = message.content.split(/\s*\n\s*/);
|
||||||
strarr[0] = strarr[0].slice(this.name.length + config.prefix.length);
|
head = head.slice(this.name.length + config.prefix.length);
|
||||||
const answer = strarr[Math.floor(Math.random() * strarr.length)];
|
if (head) options.push(head);
|
||||||
|
|
||||||
if (answer === "") {
|
if (!options.length) {
|
||||||
await message.channel.send(client.generateErrorMessage("You need to provide some input!", message.author.displayAvatarURL()));
|
await message.channel.send(client.generateErrorMessage("You need to provide some input!", message.author.displayAvatarURL()));
|
||||||
} else {
|
} else {
|
||||||
|
const answer = options[Math.floor(Math.random() * options.length)];
|
||||||
await message.channel.send({embed: {
|
await message.channel.send({embed: {
|
||||||
"title": "I have made my decision:",
|
"title": "I have made my decision:",
|
||||||
"description": answer,
|
"description": answer,
|
||||||
|
|
Reference in New Issue