missing interface method params
This commit is contained in:
parent
65a9cf3476
commit
d58578c5ae
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "commandparser",
|
"name": "commandparser",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"description": "Parser meant to parse commands and their options for discord bots",
|
"description": "Parser meant to parse commands and their options for discord bots",
|
||||||
"main": "index.ts",
|
"main": "index.ts",
|
||||||
"author": "Navy.gif",
|
"author": "Navy.gif",
|
||||||
|
@ -17,7 +17,7 @@ type ParserOptions = {
|
|||||||
commands: Iterable<ICommand>,
|
commands: Iterable<ICommand>,
|
||||||
prefix?: string,
|
prefix?: string,
|
||||||
debug?: boolean,
|
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;
|
const flagReg = /(?:^| )(?<flag>(?:--[a-z0-9]{3,})|(?:-[a-z]{1,2}))(?:$| )/iu;
|
||||||
@ -30,7 +30,7 @@ class Parser extends EventEmitter {
|
|||||||
|
|
||||||
prefix: string;
|
prefix: string;
|
||||||
|
|
||||||
resolver: IResolver<unknown, unknown, unknown, unknown>;
|
resolver: IResolver<unknown, unknown, unknown, unknown, unknown>;
|
||||||
|
|
||||||
constructor({ commands, prefix, debug = false, resolver }: ParserOptions) {
|
constructor({ commands, prefix, debug = false, resolver }: ParserOptions) {
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class CommandOption implements ICommandOption {
|
|||||||
|
|
||||||
aliased = false;
|
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) {
|
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);
|
const opt = new CommandOption(this);
|
||||||
opt.rawValue = rawValue;
|
opt.rawValue = rawValue;
|
||||||
opt.resolver = resolver || undefined;
|
opt.resolver = resolver || undefined;
|
||||||
|
@ -125,7 +125,7 @@ interface ICommandOption {
|
|||||||
|
|
||||||
// private _options?: CommandOptionDefinition
|
// 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>
|
parse(): Promise<ParseResult>
|
||||||
|
|
||||||
|
@ -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
|
resolveTime(resolveable: string): number
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user