diff --git a/package.json b/package.json index 5c86a37..b1abb5f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "commandparser", - "version": "1.0.23", + "version": "1.0.24", "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 c3c6222..d15f76c 100644 --- a/src/classes/CommandOption.ts +++ b/src/classes/CommandOption.ts @@ -103,16 +103,16 @@ class CommandOption implements ICommandOption { protected STRING() { if (!this.rawValue) return { error: true }; - if (this._aliased) return { value: this.rawValue.join(' '), removed: [] }; + if (this.aliased) return { value: this.rawValue.join(' '), removed: [] }; 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 }; + if (found) return { value: found, removed: this.rawValue }; return { error: true }; } - return { value: (this._rawValue as string[]).join(' '), removed: this._rawValue }; + return { value: this.rawValue.join(' '), removed: this.rawValue }; } } diff --git a/tests/CommandOption.test.js b/tests/CommandOption.test.js new file mode 100644 index 0000000..4247113 --- /dev/null +++ b/tests/CommandOption.test.js @@ -0,0 +1,24 @@ +const { Parser, Command, CommandOption, OptionType } = require('../build/index'); + +const opt = new CommandOption({ + name: 'text', + type: OptionType.STRING +}); +class TestCommand extends Command { + constructor() { + super({ + name: 'test', + options: [opt] + }) + } +}; + +const parser = new Parser({ + commands: [new TestCommand()], + resolver: null +}); + +(async () => { + const parsed = await parser.parseMessage('test message.author') + console.log(parsed) +})();