2022-04-22 00:11:53 -05:00
|
|
|
const { Constants } = require('discord.js');
|
|
|
|
|
2022-04-18 11:06:53 -05:00
|
|
|
module.exports = {
|
2022-04-18 11:25:40 -05:00
|
|
|
|
|
|
|
name: require('path').parse(__filename).name,
|
2022-04-21 18:09:21 -05:00
|
|
|
description: 'Give some lines of input, and get one back at random',
|
2022-04-22 00:11:53 -05:00
|
|
|
options: [...Array(10).keys()].map(i => ({
|
|
|
|
name: `option${i + 1}`,
|
|
|
|
description: 'Another option',
|
|
|
|
required: false,
|
|
|
|
type: Constants.ApplicationCommandOptionTypes.STRING
|
|
|
|
})),
|
2022-04-18 11:25:40 -05:00
|
|
|
|
2022-04-21 23:44:02 -05:00
|
|
|
async parseMessage (client, config, message, args) {
|
2022-04-21 18:09:21 -05:00
|
|
|
let [head, ...options] = message.content.split(/\s*\n\s*/);
|
2022-04-18 12:00:56 -05:00
|
|
|
head = head.slice(this.name.length + config.prefix.length);
|
|
|
|
if (head) options.push(head);
|
2022-04-21 23:44:02 -05:00
|
|
|
await message.channel.send(this.handle(client, config, message.author, options));
|
|
|
|
},
|
2022-04-18 12:00:56 -05:00
|
|
|
|
2022-04-21 23:44:02 -05:00
|
|
|
async parseInteraction (client, config, interaction) {
|
2022-04-22 00:22:02 -05:00
|
|
|
console.log([...Array(10).keys()].map(i => interaction.options.getString(`option${i + 1}`)).filter(str => str));
|
|
|
|
await interaction.reply(this.handle(client, config, interaction.user, [...Array(10).keys()].map(i => interaction.options.getString(`option${i + 1}`)).filter(str => str)));
|
2022-04-21 23:44:02 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
handle (client, config, user, options) {
|
|
|
|
if (!options.length) return client.generateErrorMessage('You need to provide some input!', user.displayAvatarURL());
|
|
|
|
|
|
|
|
const answer = options[Math.floor(Math.random() * options.length)];
|
|
|
|
return {
|
|
|
|
embeds: [{
|
|
|
|
title: 'I have made my decision:',
|
|
|
|
description: answer,
|
|
|
|
color: 8311585,
|
|
|
|
footer: {
|
|
|
|
icon_url: user.displayAvatarURL(),
|
|
|
|
text: config.footerTxt
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
};
|
2022-04-18 11:06:53 -05:00
|
|
|
}
|
2022-04-21 18:09:21 -05:00
|
|
|
};
|