include subcommands in cache removal

merge-requests/2/merge
Bsian 2019-12-30 16:47:14 +00:00
parent 0a2088977b
commit 6cbedfa04b
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
1 changed files with 2 additions and 0 deletions

View File

@ -31,6 +31,7 @@ export default class Load extends Command {
try {
delete require.cache[`${corepath}/commands/index.js`];
delete require.cache[`${corepath}/commands/${args[1]}.js`];
Object.keys(require.cache).filter((path) => path.includes(`${args[1]}_`)).forEach((path) => delete require.cache[path]);
const cmdIndex = require('../commands');
let Cmd = cmdIndex[args[1]];
if (!Cmd) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Could not find file***`);
@ -39,6 +40,7 @@ export default class Load extends Command {
this.client.loadCommand(Cmd);
delete require.cache[`${corepath}/commands/index.js`];
delete require.cache[`${corepath}/commands/${args[1]}.js`];
Object.keys(require.cache).filter((path) => path.includes(`${args[1]}_`)).forEach((path) => delete require.cache[path]);
} catch (error) {
if (error.message.includes('Cannot find module')) return message.channel.createMessage(`${this.client.stores.emojis} ***Cannot find file***`);
throw error;