Fix command reloader being accessible by anyone
This commit is contained in:
parent
9e4e6347dc
commit
b71378da72
|
@ -1,26 +1,44 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'reload',
|
name: 'reload',
|
||||||
description: 'Reloads a command',
|
description: 'Reloads a command',
|
||||||
args: true,
|
args: true,
|
||||||
execute(client, message, args) {
|
execute(client, message, args) {
|
||||||
const commandName = args[0].toLowerCase();
|
if (message.author.id == 309427567004483586) {
|
||||||
const command = message.client.commands.get(commandName)
|
const commandName = args[0].toLowerCase();
|
||||||
|| message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
|
const command = message.client.commands.get(commandName)
|
||||||
|
|| message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
|
||||||
if (!command) {
|
|
||||||
return message.channel.send(`There is no command with name or alias \`${commandName}\`, ${message.author}!`);
|
if (!command) {
|
||||||
}
|
return message.channel.send(`There is no command with name or alias \`${commandName}\`, ${message.author}!`);
|
||||||
|
}
|
||||||
delete require.cache[require.resolve(`./${command.name}.js`)];
|
|
||||||
|
delete require.cache[require.resolve(`./${command.name}.js`)];
|
||||||
try {
|
|
||||||
const newCommand = require(`./${command.name}.js`);
|
try {
|
||||||
message.client.commands.set(newCommand.name, newCommand);
|
const newCommand = require(`./${command.name}.js`);
|
||||||
message.channel.send(`<:NyabotSuccess:697211376740859914> **Reloaded \`${command.name}\` successfully!**`);
|
message.client.commands.set(newCommand.name, newCommand);
|
||||||
console.log('User reloaded ${command.name}.')
|
message.channel.send(`<:NyabotSuccess:697211376740859914> **Reloaded \`${command.name}\` successfully!**`);
|
||||||
} catch (error) {
|
console.log('User reloaded ${command.name}.')
|
||||||
console.error(error);
|
} catch (error) {
|
||||||
message.channel.send(`There was an error while reloading \`${command.name}\`:\n\`${error.message}\``);
|
console.error(error);
|
||||||
}
|
message.channel.send(`There was an error while reloading \`${command.name}\`:\n\`${error.message}\``);
|
||||||
},
|
}
|
||||||
|
} else {
|
||||||
|
const embed = {
|
||||||
|
"title": "<:NyabotDenied:697145462565896194> **Access is denied**",
|
||||||
|
"color": 13632027,
|
||||||
|
"footer": {
|
||||||
|
"icon_url": "https://cdn.discordapp.com/attachments/549707869138714635/793524910172667964/Screenshot_26.png",
|
||||||
|
"text": "Anitrox © IDeletedSystem64 2018-2021 All Rights Reserved."
|
||||||
|
},
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "**What Happened?**",
|
||||||
|
"value": "You don't have the appropriate permissions to run this command!"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
message.channel.send({ embed });
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
Reference in New Issue