This repository has been archived on 2024-01-30. You can view files and clone it, but cannot push or open issues or pull requests.
anitrox/commands/choose.js

31 lines
935 B
JavaScript

module.exports = {
name: require('path').parse(__filename).name,
description: 'Give some lines of input, and get one back at random',
options: [],
async execute (client, message, _, config) {
const avatarURL = message.author.displayAvatarURL();
let [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!', avatarURL));
} else {
const answer = options[Math.floor(Math.random() * options.length)];
await message.channel.send({
embeds: [{
title: 'I have made my decision:',
description: answer,
color: 8311585,
footer: {
icon_url: avatarURL,
text: config.footerTxt
}
}]
});
}
}
};