mirror of
https://github.com/danbulant/discord.js
synced 2026-06-09 01:31:29 +00:00
fix(Collector): increase and decrease max listeners dynamically
This commit is contained in:
parent
ed8ab91782
commit
60288d0704
2 changed files with 4 additions and 0 deletions
|
|
@ -33,6 +33,7 @@ class MessageCollector extends Collector {
|
||||||
*/
|
*/
|
||||||
this.received = 0;
|
this.received = 0;
|
||||||
|
|
||||||
|
this.client.setMaxListeners(this.client.getMaxListeners() + 1);
|
||||||
this.client.on('message', this.listener);
|
this.client.on('message', this.listener);
|
||||||
|
|
||||||
// For backwards compatibility (remove in v12)
|
// For backwards compatibility (remove in v12)
|
||||||
|
|
@ -92,6 +93,7 @@ class MessageCollector extends Collector {
|
||||||
cleanup() {
|
cleanup() {
|
||||||
this.removeListener('collect', this._reEmitter);
|
this.removeListener('collect', this._reEmitter);
|
||||||
this.client.removeListener('message', this.listener);
|
this.client.removeListener('message', this.listener);
|
||||||
|
this.client.setMaxListeners(this.client.getMaxListeners() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ class ReactionCollector extends Collector {
|
||||||
*/
|
*/
|
||||||
this.total = 0;
|
this.total = 0;
|
||||||
|
|
||||||
|
this.client.setMaxListeners(this.client.getMaxListeners() + 1);
|
||||||
this.client.on('messageReactionAdd', this.listener);
|
this.client.on('messageReactionAdd', this.listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,6 +78,7 @@ class ReactionCollector extends Collector {
|
||||||
*/
|
*/
|
||||||
cleanup() {
|
cleanup() {
|
||||||
this.client.removeListener('messageReactionAdd', this.listener);
|
this.client.removeListener('messageReactionAdd', this.listener);
|
||||||
|
this.client.setMaxListeners(this.client.getMaxListeners() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue