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-21 20:53:03 -05:00
|
|
|
options: [],
|
2022-04-18 11:25:40 -05:00
|
|
|
|
2022-04-21 18:09:21 -05:00
|
|
|
async execute (client, message, args, config) {
|
2022-04-21 12:24:12 -05:00
|
|
|
const avatarURL = message.author.displayAvatarURL();
|
2022-04-21 18:09:21 -05:00
|
|
|
if (message.author.id === config.ownerID) {
|
2022-03-26 12:31:03 -05:00
|
|
|
if (!args.length) {
|
2022-04-21 18:09:21 -05:00
|
|
|
await message.channel.send(client.generateErrorMessage('You forgot to provide anything to reload, you pillock', avatarURL));
|
2022-03-26 12:31:03 -05:00
|
|
|
}
|
|
|
|
args.forEach(async (arg) => {
|
|
|
|
const commandName = arg.toLowerCase();
|
2022-04-21 18:09:21 -05:00
|
|
|
const command = message.client.commands.get(commandName) ||
|
|
|
|
message.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 12:24:12 -05:00
|
|
|
await message.channel.send(client.generateErrorMessage(`There is no command with name or alias \`${commandName}\`, ${message.author}!`, avatarURL));
|
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-03-28 13:05:34 -05:00
|
|
|
await message.channel.send(`<:AnitroxSuccess:809651936819019796> **Reloaded \`${command.name}\` successfully!**`);
|
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 12:24:12 -05:00
|
|
|
await message.channel.send(client.generateErrorMessage(`There was an error while reloading \`${command.name}\`:\n\`${error.message}\``, avatarURL));
|
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-03-26 03:33:18 -05:00
|
|
|
} else {
|
2022-04-21 18:09:21 -05:00
|
|
|
message.channel.send({
|
|
|
|
embeds: [{
|
|
|
|
title: '<:AnitroxDenied:809651936642203668> **403 Forbidden**',
|
|
|
|
color: 13632027,
|
|
|
|
footer: {
|
|
|
|
icon_url: avatarURL,
|
|
|
|
text: config.footerTxt
|
|
|
|
},
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
name: '**What Happened?**',
|
|
|
|
value: "You don't have the appropriate permissions to run this command!"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}]
|
|
|
|
});
|
2022-03-27 17:03:17 -05:00
|
|
|
}
|
|
|
|
}
|
2022-04-21 18:09:21 -05:00
|
|
|
};
|