string type

This commit is contained in:
Erik 2022-07-29 22:19:24 +03:00
parent c6deb3764c
commit e2aac258a7
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
2 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "commandparser", "name": "commandparser",
"version": "1.0.21", "version": "1.0.22",
"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": "build/index.js", "main": "build/index.js",
"author": "Navy.gif", "author": "Navy.gif",

View File

@ -101,6 +101,20 @@ class CommandOption implements ICommandOption {
return { value: member, removed: this.rawValue }; return { value: member, removed: this.rawValue };
} }
protected STRING() {
if (this._aliased) return { value: this.rawValue?.join(' ') || '', removed: [] };
if(!this.rawValue) return { error: true };
if (this.choices.length) {
const found = this.choices.find((c) => {
const choice = c as string;
return choice.toLowerCase() === this.rawValue?.join(' ').toLowerCase();
});
if (found) return { value: found, removed: this._rawValue };
return { error: true };
}
return { value: this._rawValue, removed: this._rawValue };
}
} }
export { CommandOption }; export { CommandOption };