Skip to content

Commit

Permalink
Fix command spread operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Vahelnir committed Apr 16, 2017
1 parent 19fe175 commit 6c058cd
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ commands.group().prefix("#").apply(_ => {
.command("lol <message>", (message, args) => message.reply('lol')).register()
.sub("test", (message, args) => message.reply('lol test')).register();
commands
.command("test2 <message>", (message, args) => message.reply(args.get('message'))).register()
.command("test2 <message...>", (message, args) => message.reply(args.get('message').join(' '))).register()
.sub("moche", (message, args) => message.reply('t es moche 2')).register();
});

Expand Down
2 changes: 1 addition & 1 deletion lib/Commands/Builders/CommandBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ let CommandBuilder = (_dec = _flowRuntime2.default.annotate(_flowRuntime2.defaul
if (arg.includes(':')) [arg, regex] = arg.split(':');
regex = new RegExp(regex, 'g');

if (arg.endsWith('...')) [list, arg] = [true, arg.replace('...')];
if (arg.endsWith('...')) [list, arg] = [true, arg.replace('...', '')];

this._args.push({
key: arg,
Expand Down
1 change: 0 additions & 1 deletion lib/Commands/Command.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ let Command = (_dec = _flowRuntime2.default.annotate(_flowRuntime2.default.class
let argument = args[i];

if (!_this._args[i].optional && !argument) return;

if (_this._args[i].list) {
argument = args.splice(i);
let match = true;
Expand Down
5 changes: 3 additions & 2 deletions lib/Commands/CommandManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ let CommandManager = (_dec = _flowRuntime2.default.annotate(_flowRuntime2.defaul
if (!message.content) return false;
const lines = splitWithQuotes(message.content);
if (lines.length == 0) return;
let called = false;
this._commands.forEach(cmd => {
if (cmd.command === lines[0]) {
cmd.call(this._config.parse, message, lines.splice(1));
return true;
called = true;
}
});
return false;
return called;
}

}) || _class);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "krobotjs",
"version": "1.0.2",
"version": "1.0.3",
"description": "A library that helps you create a discord bot with DiscordJS",
"main": "lib/Krobotjs.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Builders/CommandBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CommandBuilder {
regex = new RegExp(regex, 'g');

if (arg.endsWith('...'))
[list, arg] = [true, arg.replace('...')]
[list, arg] = [true, arg.replace('...', '')]

this._args.push({
key: arg,
Expand Down
1 change: 0 additions & 1 deletion src/Commands/Command.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Command {
let argument = args[i];

if (!this._args[i].optional && !argument) return;

if (this._args[i].list) {
argument = args.splice(i)
let match = true;
Expand Down

0 comments on commit 6c058cd

Please sign in to comment.