mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix(ReactionCollector): only modify users and total on collect (#3905)
This commit is contained in:
@@ -41,6 +41,11 @@ class ReactionCollector extends Collector {
|
||||
|
||||
if (this.client.getMaxListeners() !== 0) this.client.setMaxListeners(this.client.getMaxListeners() + 1);
|
||||
this.client.on('messageReactionAdd', this.listener);
|
||||
|
||||
this.on('fullCollect', (reaction, user) => {
|
||||
this.users.set(user.id, user);
|
||||
this.total++;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,9 +69,8 @@ class ReactionCollector extends Collector {
|
||||
* @returns {?string} Reason to end the collector, if any
|
||||
* @private
|
||||
*/
|
||||
postCheck(reaction, user) {
|
||||
this.users.set(user.id, user);
|
||||
if (this.options.max && ++this.total >= this.options.max) return 'limit';
|
||||
postCheck() {
|
||||
if (this.options.max && this.total >= this.options.max) return 'limit';
|
||||
if (this.options.maxEmojis && this.collected.size >= this.options.maxEmojis) return 'emojiLimit';
|
||||
if (this.options.maxUsers && this.users.size >= this.options.maxUsers) return 'userLimit';
|
||||
return null;
|
||||
|
||||
@@ -99,6 +99,14 @@ class Collector extends EventEmitter {
|
||||
*/
|
||||
this.emit('collect', collect.value, this);
|
||||
|
||||
/**
|
||||
* Emitted whenever an element is collected.
|
||||
* @event Collector#fullCollect
|
||||
* @param {...*} args The arguments emitted by the listener
|
||||
* @private
|
||||
*/
|
||||
this.emit('fullCollect', ...args, this);
|
||||
|
||||
if (this._idletimeout) {
|
||||
this.client.clearTimeout(this._idletimeout);
|
||||
this._idletimeout = this.client.setTimeout(() => this.stop('idle'), this.options.idle);
|
||||
|
||||
Reference in New Issue
Block a user