diff --git a/package.json b/package.json index 7a9874e..3a824a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "commandparser", - "version": "1.0.21", + "version": "1.0.22", "description": "Parser meant to parse commands and their options for discord bots", "main": "build/index.js", "author": "Navy.gif", diff --git a/src/classes/CommandOption.ts b/src/classes/CommandOption.ts index b6c180f..18a9ce4 100644 --- a/src/classes/CommandOption.ts +++ b/src/classes/CommandOption.ts @@ -101,6 +101,20 @@ class CommandOption implements ICommandOption { 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 };