missing interface method params

This commit is contained in:
Erik 2022-07-29 15:05:40 +03:00
parent 65a9cf3476
commit d58578c5ae
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
5 changed files with 64 additions and 12 deletions

View File

@ -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",

View File

@ -17,7 +17,7 @@ type ParserOptions = {
commands: Iterable<ICommand>,
prefix?: string,
debug?: boolean,
resolver: IResolver<unknown, unknown, unknown, unknown>
resolver: IResolver<unknown, unknown, unknown, unknown, unknown>
}
const flagReg = /(?:^| )(?<flag>(?:--[a-z0-9]{3,})|(?:-[a-z]{1,2}))(?:$| )/iu;
@ -30,7 +30,7 @@ class Parser extends EventEmitter {
prefix: string;
resolver: IResolver<unknown, unknown, unknown, unknown>;
resolver: IResolver<unknown, unknown, unknown, unknown, unknown>;
constructor({ commands, prefix, debug = false, resolver }: ParserOptions) {

View File

@ -40,7 +40,7 @@ class CommandOption implements ICommandOption {
aliased = false;
private resolver?: IResolver<unknown, unknown, unknown, unknown>|undefined = undefined;
private resolver?: IResolver<unknown, unknown, unknown, unknown, unknown>|undefined = undefined;
constructor(def: CommandOptionDefinition|ICommandOption) {
@ -64,7 +64,7 @@ class CommandOption implements ICommandOption {
}
clone(rawValue?: string[], resolver?: IResolver<unknown, unknown, unknown, unknown>): CommandOption {
clone(rawValue?: string[], resolver?: IResolver<unknown, unknown, unknown, unknown, unknown>): CommandOption {
const opt = new CommandOption(this);
opt.rawValue = rawValue;
opt.resolver = resolver || undefined;

View File

@ -125,7 +125,7 @@ interface ICommandOption {
// private _options?: CommandOptionDefinition
clone(rawValue?: string[], resolver?: IResolver<unknown, unknown, unknown, unknown>): CommandOption
clone(rawValue?: string[], resolver?: IResolver<unknown, unknown, unknown, unknown, unknown>): CommandOption
parse(): Promise<ParseResult>

View File

@ -1,15 +1,67 @@
interface IResolver <User, Member, Channel, Role> {
interface IResolver <User, Member, Channel, Role, Guild> {
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
}