mirror of
https://github.com/danbulant/discord.js
synced 2026-05-31 13:21:56 +00:00
fix: prevent max listener problems with collectors (#2521)
This commit is contained in:
parent
9f918199d2
commit
32369f3bdd
2 changed files with 4 additions and 0 deletions
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue