Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
fix(ArgumentParser): fix multi-argument parsing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alexthemaster committed Jul 27, 2020
1 parent 0dfdf8f commit ca7f274
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/lib/util/ArgumentParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class ArgumentParser {
* @param text The text to parse
* @param delimiter The delimiter that specifies how to separate the text for checking
*/
constructor(args: string, text: string, delimiter: string | undefined = undefined, client: MoonlightClient, message: Message) {
constructor(args: string, text: string, delimiter: string | undefined, client: MoonlightClient, message: Message) {
this.args = args.split(/ +/g);
this.delimiter = delimiter;
// @ts-expect-error
Expand Down Expand Up @@ -56,11 +56,11 @@ export class ArgumentParser {
if (arg !== toParse) {
if (argumentObject.type !== 'optional') throw { arg, message: `The argument is supposed to be equal to \`${arg}\`!` };
else continue;
} else {
this.text.shift();
parsed[arg] = arg;
continue;
}

this.text.shift();
parsed[arg] = arg;
continue;
}

// If the argument type is not something present in the parsers, then thow a message
Expand All @@ -70,6 +70,7 @@ export class ArgumentParser {
try {
// @ts-expect-error
parsed[arg] = await Arguments[argumentObject.argumentType](toParse, this._client, this._message)
this.text.shift();
} catch (err) {
if (argumentObject.type === 'optional') return;
throw { arg, message: err };
Expand Down

0 comments on commit ca7f274

Please sign in to comment.