fix: move optional argument to end
This commit is contained in:
parent
88af10a8b4
commit
bc5f14ebde
11
src/index.js
11
src/index.js
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user