fix: prevent max listener problems with collectors (#2521)

This commit is contained in:
Will Nelson
2018-05-04 00:11:52 -07:00
committed by Isabella
parent 9f918199d2
commit 32369f3bdd
2 changed files with 4 additions and 0 deletions

View File

@@ -37,6 +37,7 @@ class MessageCollector extends Collector {
for (const message of messages.values()) this.handleDispose(message);
}).bind(this);
this.client.setMaxListeners(this.client.getMaxListeners() + 1);
this.client.on(Events.MESSAGE_CREATE, this.handleCollect);
this.client.on(Events.MESSAGE_DELETE, this.handleDispose);
this.client.on(Events.MESSAGE_BULK_DELETE, bulkDeleteListener);
@@ -45,6 +46,7 @@ class MessageCollector extends Collector {
this.client.removeListener(Events.MESSAGE_CREATE, this.handleCollect);
this.client.removeListener(Events.MESSAGE_DELETE, this.handleDispose);
this.client.removeListener(Events.MESSAGE_BULK_DELETE, bulkDeleteListener);
this.client.setMaxListeners(this.client.getMaxListeners() - 1);
});
}

View File

@@ -42,6 +42,7 @@ class ReactionCollector extends Collector {
this.empty = this.empty.bind(this);
this.client.setMaxListeners(this.client.getMaxListeners() + 1);
this.client.on(Events.MESSAGE_REACTION_ADD, this.handleCollect);
this.client.on(Events.MESSAGE_REACTION_REMOVE, this.handleDispose);
this.client.on(Events.MESSAGE_REACTION_REMOVE_ALL, this.empty);
@@ -50,6 +51,7 @@ class ReactionCollector extends Collector {
this.client.removeListener(Events.MESSAGE_REACTION_ADD, this.handleCollect);
this.client.removeListener(Events.MESSAGE_REACTION_REMOVE, this.handleDispose);
this.client.removeListener(Events.MESSAGE_REACTION_REMOVE_ALL, this.empty);
this.client.setMaxListeners(this.client.getMaxListeners() - 1);
});
this.on('collect', (reaction, user) => {