From bc5f14ebdec0a9023545a32b0600891d2d02da4a Mon Sep 17 00:00:00 2001 From: Ali Movahedi Date: Tue, 12 Sep 2017 18:39:09 +0430 Subject: [PATCH] fix: move optional argument to end --- src/index.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/index.js b/src/index.js index d469ed3..719766f 100644 --- a/src/index.js +++ b/src/index.js @@ -117,12 +117,7 @@ export default class Bot extends EventEmitter { * gets the update * @return {object} returns the bot object */ - command(command, customMessage, listener) { - if (!listener) { - listener = customMessage; - customMessage = {}; - } - + command(command, listener, customMessage = {}) { const regex = /[^\s]+/; const cmd = command.match(regex)[0].trim(); @@ -130,8 +125,8 @@ export default class Bot extends EventEmitter { this._userEvents.push({ pattern: new RegExp(`^/${cmd}`), parse: argumentParser.bind(null, command), - customMessage, - listener + listener, + customMessage }); return this;