fix: move optional argument to end

This commit is contained in:
Ali Movahedi 2017-09-12 18:39:09 +04:30
parent 88af10a8b4
commit bc5f14ebde

View File

@ -117,12 +117,7 @@ export default class Bot extends EventEmitter {
* gets the update * gets the update
* @return {object} returns the bot object * @return {object} returns the bot object
*/ */
command(command, customMessage, listener) { command(command, listener, customMessage = {}) {
if (!listener) {
listener = customMessage;
customMessage = {};
}
const regex = /[^\s]+/; const regex = /[^\s]+/;
const cmd = command.match(regex)[0].trim(); const cmd = command.match(regex)[0].trim();
@ -130,8 +125,8 @@ export default class Bot extends EventEmitter {
this._userEvents.push({ this._userEvents.push({
pattern: new RegExp(`^/${cmd}`), pattern: new RegExp(`^/${cmd}`),
parse: argumentParser.bind(null, command), parse: argumentParser.bind(null, command),
customMessage, listener,
listener customMessage
}); });
return this; return this;