From 455aafa1f7ee12890618d0ba877cf60ed4e03eb9 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Fri, 29 Jul 2022 19:49:50 +0300 Subject: [PATCH] bugfix --- src/Parser.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Parser.ts b/src/Parser.ts index 7430e88..3b34fbe 100644 --- a/src/Parser.ts +++ b/src/Parser.ts @@ -9,6 +9,7 @@ import Util from "./util/Util"; type ParseResult = { args: object, + command: ICommand, subcommand: string | null, subcommandGroup: string | null } @@ -52,11 +53,11 @@ class Parser extends EventEmitter { return command || null; } - async parseMessage(message: string, prefix = this.prefix, guild?: unknown) { + async parseMessage(message: string, prefix = this.prefix, guild?: unknown): Promise { if (!message.startsWith(prefix) || !message.length) return null; let params: string[] = message.replace(prefix, '').split(' ').filter((str) => str.length); - const [commandName] = params.shift() || []; + const commandName = params.shift(); if (!commandName) return null; const command = this.matchCommand(commandName); @@ -65,7 +66,7 @@ class Parser extends EventEmitter { this.debug(`Matched command ${command.name}`); const { subcommands, subcommandGroups } = command; const args: {[key: string]: CommandOption} = {}; - const parseResult: ParseResult = { args, subcommand: null, subcommandGroup: null }; + const parseResult: ParseResult = { args, command, subcommand: null, subcommandGroup: null }; let group = null, subcommand = null; @@ -240,7 +241,7 @@ class Parser extends EventEmitter { if (strings.length) throw new Error(`Unrecognised option(s): "${strings.join('", "')}"`);//return { error: true, index: 'O_COMMANDHANDLER_UNRECOGNISED_OPTIONS', params: { opts: strings.join('`, `') } }; - return { options: args, verbose: true }; + return parseResult; }