From 6cbedfa04bc78450a9d22fa645c05c4e535e3eff Mon Sep 17 00:00:00 2001 From: Bsian Date: Mon, 30 Dec 2019 16:47:14 +0000 Subject: [PATCH] include subcommands in cache removal --- src/commands/load.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/commands/load.ts b/src/commands/load.ts index ec4130d..f76b4b9 100644 --- a/src/commands/load.ts +++ b/src/commands/load.ts @@ -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;