2019-11-26 21:22:24 +00:00
|
|
|
exports.run = async (client, message, args, level) => {
|
2019-12-21 00:58:25 +00:00
|
|
|
message.delete();
|
2019-11-26 21:22:24 +00:00
|
|
|
|
2019-12-21 00:58:25 +00:00
|
|
|
if (!args || args.length < 1) return msg.edit("Why are you trying to reload a command without actually naming it?").then(msg => {
|
|
|
|
msg.delete(5000);
|
|
|
|
});
|
|
|
|
|
|
|
|
const commandName = args[0].toLowerCase();
|
|
|
|
const command = message.client.commands.get(commandName)
|
|
|
|
|| message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
|
2019-11-26 21:22:24 +00:00
|
|
|
|
2019-12-21 00:58:25 +00:00
|
|
|
if (!command) return msg.edit(`There is no command with name or alias \`${commandName}\`, ${message.author}.`).then(msg => {
|
|
|
|
msg.delete(5000);
|
|
|
|
});
|
|
|
|
let msg = await message.channel.send(`**Beginning reload process;** initiated by ${message.author.tag}. Finding and reloading command \`${args[0]}\`...`);
|
|
|
|
|
|
|
|
delete require.cache[require.resolve(`../${command.help.category}/${commandName}.js`)];
|
|
|
|
|
|
|
|
try {
|
|
|
|
const newCommand = require(`../${command.help.category}/${commandName}.js`);
|
|
|
|
message.client.commands.set(newCommand.help.name, newCommand);
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
msg.edit(`Hey ${message.author}, there was an error while reloading command \`${commandName}\`:\n\`${error.message}\``).then(msg => {
|
|
|
|
msg.delete(10000);
|
2019-12-21 16:05:46 +00:00
|
|
|
});
|
|
|
|
return;
|
2019-12-21 00:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
msg.edit(`**Command \`${command.help.name}\` has been reloaded successfully.**`).then(msg => {
|
|
|
|
msg.delete(5000);
|
|
|
|
});
|
2019-11-26 21:22:24 +00:00
|
|
|
};
|
|
|
|
|
2019-12-21 00:58:25 +00:00
|
|
|
|
2019-11-26 21:22:24 +00:00
|
|
|
exports.conf = {
|
2019-12-21 00:58:25 +00:00
|
|
|
enabled: true,
|
|
|
|
guildOnly: false,
|
|
|
|
aliases: [],
|
|
|
|
permLevel: "Bot Admin"
|
2019-11-26 21:22:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.help = {
|
2019-12-21 00:58:25 +00:00
|
|
|
name: "reload",
|
|
|
|
category: "System",
|
|
|
|
description: "Reloads a command that\'s been modified.",
|
|
|
|
usage: "reload [command]"
|
2019-11-26 21:22:24 +00:00
|
|
|
};
|