diff --git a/package.json b/package.json index 490bae7..f21bb18 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "commandparser", - "version": "1.0.19", + "version": "1.0.20", "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 b0e2502..757d7f6 100644 --- a/src/Parser.ts +++ b/src/Parser.ts @@ -1,8 +1,8 @@ // eslint-disable-next-line max-classes-per-file import { EventEmitter } from 'events'; +import Command from './classes/Command'; import CommandOption from './classes/CommandOption'; -import ICommand from "./interfaces/Command"; import { OptionType } from "./interfaces/CommandOption"; import IResolver from './interfaces/Resolver'; import ExtendedMap from "./util/Map"; @@ -14,13 +14,13 @@ type ArgsResult = { type ParseResult = { args: ArgsResult, - command: ICommand, + command: Command, subcommand: string | null, subcommandGroup: string | null } type ParserOptions = { - commands: Iterable, + commands: Iterable, prefix?: string, debug?: boolean, resolver: IResolver @@ -32,7 +32,7 @@ const flagReg = /(?:^| )(?(?:--[a-z0-9]{3,})|(?:-[a-z]{1,2}))(?:$| )/iu; class Parser extends EventEmitter { - private commands: ExtendedMap; + private commands: ExtendedMap; private _debug = false; @@ -45,7 +45,7 @@ class Parser extends EventEmitter { super(); this._debug = debug; - this.commands = new ExtendedMap(); + this.commands = new ExtendedMap(); for (const command of commands) this.commands.set(command.name, command); this.resolver = resolver; @@ -53,7 +53,7 @@ class Parser extends EventEmitter { } - private matchCommand(name: string): ICommand | null { + private matchCommand(name: string): Command | null { let command = null; if (this.commands.has(name)) command = this.commands.get(name); else command = this.commands.find((c) => c.aliases.includes(name)); @@ -73,7 +73,7 @@ class Parser extends EventEmitter { */ // eslint-disable-next-line @typescript-eslint/ban-types async parseMessage(message: string, prefix = this.prefix, - guild?: unknown, commandFilter?: (command: ICommand) => boolean): Promise { + guild?: unknown, commandFilter?: (command: Command) => boolean): Promise { if (!message.startsWith(prefix) || !message.length) return null; let params: string[] = message.replace(prefix, '').split(' ').filter((str) => str.length); diff --git a/src/classes/CommandOption.ts b/src/classes/CommandOption.ts index 986b61c..b6c180f 100644 --- a/src/classes/CommandOption.ts +++ b/src/classes/CommandOption.ts @@ -44,7 +44,7 @@ class CommandOption implements ICommandOption { private resolver?: IResolver|undefined = undefined; - constructor(def: CommandOptionDefinition|ICommandOption) { + constructor(def: CommandOptionDefinition|CommandOption|ICommandOption) { this.name = def.name; this.aliases = def.aliases || [];