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

36 lines
1.2 KiB
JavaScript

const { Constants } = require('discord.js');
module.exports = {
name: require('path').parse(__filename).name,
description: 'Give some lines of input, and get one back at random',
options: [...Array(10).keys()].map(i => ({
name: `option${i + 1}`,
description: 'Another option',
required: i === 0,
type: Constants.ApplicationCommandOptionTypes.STRING
})),
async parseInteraction (client, config, interaction) {
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)));
},
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
}
}]
};
}
};