Browse Source

Add support for optional command parameters

shorten
benji7425 4 years ago
parent
commit
e29283af1c
  1. 6
      discord-bot-core/Command.js

6
discord-bot-core/Command.js

@ -7,6 +7,10 @@ module.exports = class Command {
this.admin = admin;
this.invoke = invoke;
this.expectedParamCount = this.syntax.split(/ +/).length - 1;
const params = this.syntax.split(/ +/);
const optionalParams = params.filter(x => x.match(/^\[.+\]$/));
this.maxParamCount = params.length - 1;
this.expectedParamCount = this.maxParamCount - optionalParams.length;
}
};
Loading…
Cancel
Save