From d58578c5ae9153485926aeb61e93d6efc6a9f5eb Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Fri, 29 Jul 2022 15:05:40 +0300 Subject: [PATCH] missing interface method params --- package.json | 2 +- src/Parser.ts | 4 +-- src/classes/CommandOption.ts | 4 +-- src/interfaces/CommandOption.ts | 2 +- src/interfaces/Resolver.ts | 64 +++++++++++++++++++++++++++++---- 5 files changed, 64 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 50e28a2..988d7c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "commandparser", - "version": "1.0.3", + "version": "1.0.4", "description": "Parser meant to parse commands and their options for discord bots", "main": "index.ts", "author": "Navy.gif", diff --git a/src/Parser.ts b/src/Parser.ts index 1aa370e..14eddfd 100644 --- a/src/Parser.ts +++ b/src/Parser.ts @@ -17,7 +17,7 @@ type ParserOptions = { commands: Iterable, prefix?: string, debug?: boolean, - resolver: IResolver + resolver: IResolver } const flagReg = /(?:^| )(?(?:--[a-z0-9]{3,})|(?:-[a-z]{1,2}))(?:$| )/iu; @@ -30,7 +30,7 @@ class Parser extends EventEmitter { prefix: string; - resolver: IResolver; + resolver: IResolver; constructor({ commands, prefix, debug = false, resolver }: ParserOptions) { diff --git a/src/classes/CommandOption.ts b/src/classes/CommandOption.ts index f3d9bb9..b9dc5d6 100644 --- a/src/classes/CommandOption.ts +++ b/src/classes/CommandOption.ts @@ -40,7 +40,7 @@ class CommandOption implements ICommandOption { aliased = false; - private resolver?: IResolver|undefined = undefined; + private resolver?: IResolver|undefined = undefined; constructor(def: CommandOptionDefinition|ICommandOption) { @@ -64,7 +64,7 @@ class CommandOption implements ICommandOption { } - clone(rawValue?: string[], resolver?: IResolver): CommandOption { + clone(rawValue?: string[], resolver?: IResolver): CommandOption { const opt = new CommandOption(this); opt.rawValue = rawValue; opt.resolver = resolver || undefined; diff --git a/src/interfaces/CommandOption.ts b/src/interfaces/CommandOption.ts index 6cb1081..8867c71 100644 --- a/src/interfaces/CommandOption.ts +++ b/src/interfaces/CommandOption.ts @@ -125,7 +125,7 @@ interface ICommandOption { // private _options?: CommandOptionDefinition - clone(rawValue?: string[], resolver?: IResolver): CommandOption + clone(rawValue?: string[], resolver?: IResolver): CommandOption parse(): Promise diff --git a/src/interfaces/Resolver.ts b/src/interfaces/Resolver.ts index 87728c1..1a925dc 100644 --- a/src/interfaces/Resolver.ts +++ b/src/interfaces/Resolver.ts @@ -1,15 +1,67 @@ -interface IResolver { +interface IResolver { - resolveUser(resolveable: string): User + /** + * Should resolve to a user abstraction + * + * @param {string} resolveable + * @param {boolean} [strict] + * @return {User} {User} + * @memberof IResolver + */ + resolveUser(resolveable: string, strict?: boolean): User - resolveMember(resolveable: string): Member + /** + * Should resolve to a member abstraction + * + * @param {string} resolveable + * @param {boolean} [strict] Whether to strictly match the properties, e.g. a string must directly match a username & discriminator + * @param {Guild} guild The guild in which to look for the member + * @return {Member} {Member} + * @memberof IResolver + */ + resolveMember(resolveable: string, strict?: boolean, guild?: Guild): Member - resolveChannel(resolveable: string): Channel + /** + * Should resolve to a role abstraction + * + * @param {string} resolveable + * @param {boolean} [strict] Whether to strictly match the name, if strict is passed partial names should match + * @param {Guild} [guild] The guild in which to look for the channel + * @return {Channel} {Channel} + * @memberof IResolver + */ + resolveChannel(resolveable: string, strict?: boolean, guild?: Guild): Channel - resolveRole(resolveable: string): Role + /** + * Should resolve to a role abstraction + * + * @param {string} resolveable + * @param {boolean} [strict] Whether to strictly match the name, if strict is passed partial names should match + * @param {Guild} [guild] The guild in which to look for the role + * @return {Role} {Role} + * @memberof IResolver + */ + resolveRole(resolveable: string, strict?: boolean, guild?: Guild): Role - resolveBoolean(resolveable: string): boolean + /** + * Should resolve to true when a truthy resolveable is passed, i.e. yes, true, on etc + * and resolve to false when a falsy resolveable is given + * and to null when an incorrect resolveable is given + * + * @param {string} resolveable + * @return {boolean|null} {(boolean | null)} + * @memberof IResolver + */ + resolveBoolean(resolveable: string): boolean | null + /** + * Should resolve to a integer value from a string, e.g. 2w should resolve to 1209600 if seconds are user + * (the unit is arbitrary as far as the parser is concerned, this is the value you are given after parsing is done) + * + * @param {string} resolveable + * @return {number} {number} + * @memberof IResolver + */ resolveTime(resolveable: string): number }