2021-02-06 11:10:52 -06:00
|
|
|
module.exports = {
|
|
|
|
name: 'reload',
|
|
|
|
description: 'Reloads a command',
|
|
|
|
args: true,
|
2022-03-26 03:58:15 -05:00
|
|
|
async execute(client, message, args, footer) {
|
2022-03-26 03:33:18 -05:00
|
|
|
if (message.author.id == 309427567004483586 || message.author.id == 475558313376088064) {
|
|
|
|
const commandName = args[0].toLowerCase();
|
|
|
|
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 03:33:18 -05:00
|
|
|
if (!command) {
|
|
|
|
await message.channel.send(`There is no command with name or alias \`${commandName}\`, ${message.author}!`);
|
|
|
|
} else {
|
|
|
|
delete require.cache[require.resolve(`./${command.name}.js`)];
|
2021-02-06 11:10:52 -06:00
|
|
|
|
2022-03-26 03:33:18 -05:00
|
|
|
try {
|
|
|
|
const newCommand = require(`./${command.name}.js`);
|
|
|
|
client.commands.set(newCommand.name, newCommand);
|
|
|
|
await message.channel.send(`<:NyabotSuccess:697211376740859914> **Reloaded \`${command.name}\` successfully!**`);
|
|
|
|
console.log(`User reloaded ${command.name}.`)
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
await message.channel.send(`<:AnitroxError:809651936563429416> There was an error while reloading \`${command.name}\`:\n\`${error.message}\``);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2022-03-26 11:02:17 -05:00
|
|
|
message.channel.send({embed: {
|
2022-03-26 03:33:18 -05:00
|
|
|
"title": "<:NyabotDenied:697145462565896194> **Access is denied**",
|
|
|
|
"color": 13632027,
|
2022-03-26 03:58:15 -05:00
|
|
|
"footer": footer,
|
2022-03-26 03:33:18 -05:00
|
|
|
"fields": [
|
|
|
|
{
|
|
|
|
"name": "**What Happened?**",
|
|
|
|
"value": "You don't have the appropriate permissions to run this command!"
|
|
|
|
}
|
|
|
|
]
|
2022-03-26 11:02:17 -05:00
|
|
|
}});
|
2022-03-26 03:33:18 -05:00
|
|
|
}
|
|
|
|
}
|
2021-01-19 14:02:09 -06:00
|
|
|
};
|