remove unloaded commands from cache

This commit is contained in:
Emily 2020-10-18 12:41:55 +11:00
parent 41c3b51ed6
commit e0fb1c5ed7

View file

@ -60,17 +60,15 @@ class CommandHandler {
command = this.client.commands.get(this.client.aliases.get(name)); command = this.client.commands.get(this.client.aliases.get(name));
} }
if (!command) { if (!command) return `\`${name}\` does not exist as a command or an alias.`;
return `\`${name}\` does not exist as a command or an alias.`;
}
this.client.logger.debug(`Unloading command ${category}/${name}`); this.client.logger.debug(`Unloading command ${category}/${name}`);
if (command.shutdown) { for (const alias of command.conf.aliases) this.client.aliases.delete(alias);
await command.shutdown(this.client); this.client.commands.delete(command.help.name);
}
delete require.cache[require.resolve(path)]; delete require.cache[require.resolve(path)];
return false;
return;
} }
unloadAll () { unloadAll () {