add choose command

This commit is contained in:
Nathaniel Mason 2022-04-18 17:06:53 +01:00
parent fc0235a1ce
commit 0de4408797
1 changed files with 23 additions and 0 deletions

23
commands/choose.js Normal file
View File

@ -0,0 +1,23 @@
module.exports = {
name: 'choose',
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);
console.log(strarr);
const answer = strarr[Math.floor(Math.random() * strarr.length)];
if (answer === "") {
await message.channel.send(client.generateErrorMessage("You need to provide some input!", message.author.displayAvatarURL()));
} else {
await message.channel.send({embed: {
"title": "I have made my decision:",
"description": answer,
"color": 8311585,
"footer": {
"icon_url": message.author.displayAvatarURL(),
"text": config.footerTxt
},
}});
}
}
}