diff --git a/package.json b/package.json index f21bb18..7a9874e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "commandparser", - "version": "1.0.20", + "version": "1.0.21", "description": "Parser meant to parse commands and their options for discord bots", "main": "build/index.js", "author": "Navy.gif", diff --git a/src/Parser.ts b/src/Parser.ts index 757d7f6..e0c915a 100644 --- a/src/Parser.ts +++ b/src/Parser.ts @@ -82,9 +82,16 @@ class Parser extends EventEmitter { const command = this.matchCommand(commandName); if (!command) return null; - if (commandFilter && typeof commandFilter === 'function' && await commandFilter(command)) return null; - this.debug(`Matched command ${command.name}`); + + if (commandFilter && typeof commandFilter === 'function') { + const result = await commandFilter(command); + if (result) { + this.debug(`Ignoring command ${command.name}`); + return null; + } + } + const { subcommands, subcommandGroups } = command; const args: ArgsResult = {}; const parseResult: ParseResult = { args, command, subcommand: null, subcommandGroup: null };