From c7e036062f09b6df282001505eb5089e9552c80c Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 2 Nov 2019 00:32:58 +0000 Subject: [PATCH] Hopefully stop memory leak --- src/class/Util.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/class/Util.ts b/src/class/Util.ts index 279f6a9..b1b9b99 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -66,10 +66,14 @@ export default class Util { parentLabel += `${resolvedCommand.name} `; resolvedCommand = resolvedCommand.subcommands.get(args[0]); args.shift(); } else { - for (const subCmd of resolvedCommand.subcommands.toArray()) { + const subcommandArray = resolvedCommand.subcommands.toArray(); + for (const subCmd of subcommandArray) { if (subCmd.aliases.includes(args[0])) { parentLabel += `${resolvedCommand.name} `; resolvedCommand = subCmd; args.shift(); break; } + if (subcommandArray.findIndex((v) => v === subCmd) === subcommandArray.length - 1) { + hasSubCommands = false; break; + } } } }