Skip to content

Commit

Permalink
Fix the /mute player parameter parsing
Browse files Browse the repository at this point in the history
Fixes #599
  • Loading branch information
RussellLVP committed May 19, 2020
1 parent 2f2c943 commit b2f3cdf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion javascript/base/string_parser.js
Expand Up @@ -177,7 +177,7 @@ class StringParser {
}

if (!parameter.optional)
return parameter.error ?? StringParser.ERROR_MISSING_PARAMETER;
return (string.length && parameter.error) ?? StringParser.ERROR_MISSING_PARAMETER;
}

return values;
Expand Down
12 changes: 12 additions & 0 deletions javascript/components/command_manager/command_builder.test.js
Expand Up @@ -458,4 +458,16 @@ describe('CommandBuilder', (it, beforeEach) => {
assert.isNull(parameterFoo);
});

it('should properly check parameter existence for multiple parameters', assert => {
let foo, bar = null;

builder('testcommand')
.parameters([
{ name: 'foo', type: CommandBuilder.PLAYER_PARAMETER },
{ name: 'bar', type: CommandBuilder.NUMBER_PARAMETER, optional: true }])
.build((_, inFoo, inBar) => [foo, bar] = [inFoo, inBar]);

listener(player, '');
assert.equal(Message.filter(lastMessage), 'Usage: /testcommand [foo] [bar]');
});
});

0 comments on commit b2f3cdf

Please sign in to comment.