reload command
This commit is contained in:
parent
5f117d348c
commit
03ce821527
2 changed files with 39 additions and 1 deletions
38
bot/commands/Developer/reload.js
Normal file
38
bot/commands/Developer/reload.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
const Command = require('../../base/Command.js');
|
||||
|
||||
class Reload extends Command {
|
||||
constructor (client) {
|
||||
super(client, {
|
||||
description: 'Latency and API response times.',
|
||||
usage: '`reload [command]` - Reloads the specified command.',
|
||||
examples: '`reload ping`',
|
||||
devOnly: true
|
||||
});
|
||||
}
|
||||
|
||||
async run (message, args, data) { // eslint-disable-line no-unused-vars
|
||||
if (!args[0]) return message.channel.send('You didnt tell me what command to reload!');
|
||||
|
||||
let command;
|
||||
|
||||
if (this.client.commands.has(args[0])) {
|
||||
command = this.client.commands.get(args[0]);
|
||||
} else if (this.client.aliases.has(args[0])) {
|
||||
command = this.client.commands.get(this.client.aliases.get(args[0]));
|
||||
}
|
||||
|
||||
if (!command) return message.channel.send(
|
||||
`\`${args[0]}\` does not exist as a command or an alias.`
|
||||
);
|
||||
|
||||
let res = await this.client.commandHandler.unload(command.help.name, command.help.category);
|
||||
if (res) return message.channel.send('Error unloading: '+ res);
|
||||
|
||||
res = await this.client.commandHandler.load(command.help.name, command.help.category);
|
||||
if (res) return message.channel.send('Error loading: ' + res);
|
||||
|
||||
return message.channel.send(`Reloaded \`${args[0]}\``);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Reload;
|
|
@ -79,7 +79,7 @@ class CommandHandler {
|
|||
commandFiles.filter((cmd) => cmd.split('.').pop() === 'js').forEach((cmd) => {
|
||||
cmd = cmd.substring(0, cmd.length - 3);
|
||||
const res = this.unload(cmd, dir);
|
||||
if (res) this.client.logger.error(res);
|
||||
if (res) this.client.logger.error('Command unload: ' + res);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue