2022-04-22 00:11:53 -05:00
|
|
|
const { Constants } = require('discord.js');
|
|
|
|
|
2021-02-06 11:10:52 -06:00
|
|
|
module.exports = {
|
2022-04-18 11:25:40 -05:00
|
|
|
|
2022-04-21 18:09:21 -05:00
|
|
|
name: require('path').parse(__filename).name,
|
|
|
|
description: 'Reloads a command',
|
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) {
|
|
|
|
await message.channel.send(this.handle(client, config, message.author, args.split(' ')));
|
|
|
|
},
|
|
|
|
|
|
|
|
async parseInteraction (client, config, interaction) {
|
2022-04-22 00:22:02 -05:00
|
|
|
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, args) {
|
|
|
|
if (user.id === config.ownerID) {
|
2022-04-22 15:02:05 -05:00
|
|
|
if (!args.length) return client.generateErrorMessage('You forgot to provide anything to reload, you pillock', user.displayAvatarURL());
|
2022-04-21 23:44:02 -05:00
|
|
|
let returnMessage = '';
|
|
|
|
|
2022-03-26 12:31:03 -05:00
|
|
|
args.forEach(async (arg) => {
|
2022-04-22 00:22:02 -05:00
|
|
|
const commandName = arg?.toLowerCase();
|
2022-04-21 23:44:02 -05:00
|
|
|
const command = client.commands.get(commandName) ||
|
|
|
|
client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
|
2021-02-06 11:10:52 -06:00
|
|
|
|
2022-03-26 12:31:03 -05:00
|
|
|
if (!command) {
|
2022-04-21 23:44:02 -05:00
|
|
|
returnMessage += `There is no command with name or alias \`${commandName}\`\n`;
|
2022-03-26 12:31:03 -05:00
|
|
|
} else {
|
|
|
|
delete require.cache[require.resolve(`./${command.name}.js`)];
|
2021-02-06 11:10:52 -06:00
|
|
|
|
2022-03-26 12:31:03 -05:00
|
|
|
try {
|
|
|
|
const newCommand = require(`./${command.name}.js`);
|
|
|
|
client.commands.set(newCommand.name, newCommand);
|
2022-04-21 23:44:02 -05:00
|
|
|
returnMessage += `Successfully reloaded \`${commandName}\`\n`;
|
2022-04-21 18:09:21 -05:00
|
|
|
console.log(`User reloaded ${command.name}.`);
|
2022-03-26 12:31:03 -05:00
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
2022-04-21 23:44:02 -05:00
|
|
|
returnMessage += `There was an error while reloading \`${command.name}\`\n`;
|
2022-03-26 12:31:03 -05:00
|
|
|
}
|
2022-03-26 03:33:18 -05:00
|
|
|
}
|
2022-03-26 12:31:03 -05:00
|
|
|
});
|
2022-04-21 23:44:02 -05:00
|
|
|
|
|
|
|
return returnMessage;
|
2022-03-26 03:33:18 -05:00
|
|
|
} else {
|
2022-04-21 23:44:02 -05:00
|
|
|
return {
|
2022-04-21 18:09:21 -05:00
|
|
|
embeds: [{
|
|
|
|
title: '<:AnitroxDenied:809651936642203668> **403 Forbidden**',
|
|
|
|
color: 13632027,
|
|
|
|
footer: {
|
2022-04-21 23:44:02 -05:00
|
|
|
icon_url: user.displayAvatarURL(),
|
2022-04-21 18:09:21 -05:00
|
|
|
text: config.footerTxt
|
|
|
|
},
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
name: '**What Happened?**',
|
|
|
|
value: "You don't have the appropriate permissions to run this command!"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}]
|
2022-04-21 23:44:02 -05:00
|
|
|
};
|
2022-03-27 17:03:17 -05:00
|
|
|
}
|
|
|
|
}
|
2022-04-21 18:09:21 -05:00
|
|
|
};
|