mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
fix: prevent max listener problems with collectors (#2521)
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user