Skip to content

Commit

Permalink
fix(*Collector): account for a max listener count of 0 (#3504)
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceEEC authored and iCrawl committed Nov 4, 2019
1 parent 3c634b2 commit 2e20e80
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/structures/MessageCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MessageCollector extends Collector {
for (const message of messages.values()) this.handleDispose(message);
}).bind(this);

this.client.setMaxListeners(this.client.getMaxListeners() + 1);
if (this.client.getMaxListeners() !== 0) 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);
Expand All @@ -48,7 +48,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);
if (this.client.getMaxListeners() !== 0) this.client.setMaxListeners(this.client.getMaxListeners() - 1);
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/structures/ReactionCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ReactionCollector extends Collector {

this.empty = this.empty.bind(this);

this.client.setMaxListeners(this.client.getMaxListeners() + 1);
if (this.client.getMaxListeners() !== 0) 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);
Expand All @@ -53,7 +53,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);
if (this.client.getMaxListeners() !== 0) this.client.setMaxListeners(this.client.getMaxListeners() - 1);
});

this.on('collect', (reaction, user) => {
Expand Down

0 comments on commit 2e20e80

Please sign in to comment.