RELOAD FINALLY WORKS WITH SLASHCMDS

This commit is contained in:
Sophie Marie 2022-11-09 18:57:29 -06:00
parent d9206fe7fa
commit 5af776f4c2

View file

@ -3,25 +3,25 @@ const { Constants } = require('discord.js');
module.exports = {
name: require('path').parse(__filename).name,
description: 'Reloads a command',
options: [...Array(10).keys()].map(i => ({
name: `option${i + 0}`,
description: 'Another option',
required: i === 0,
description: 'Reload a commands code',
options: [{
name: 'command',
description: 'The command you want to reload',
required: true,
type: Constants.ApplicationCommandOptionTypes.STRING
})),
}],
async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user, [...Array(10).keys()].map(i => interaction.options.getString(`option${i + 1}`)).filter(str => str)));
await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getString('command')));
},
handle (client, config, user, args) {
handle (client, __, user, args) {
if (user.id === process.env.OWNERID) {
if (!args.length) return client.generateErrorMessage('You forgot to provide anything to reload, you pillock', user.displayAvatarURL());
let returnMessage = '';
args.forEach(async (arg) => {
const commandName = arg?.toLowerCase();
// args.forEach(async (arg) => {
const commandName = args.toLowerCase();
const command = client.commands.get(commandName);
if (!command) {
@ -39,7 +39,6 @@ module.exports = {
returnMessage += `There was an error while reloading \`${command.name}\`\n`;
}
}
});
return returnMessage;
} else {