mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
fix(*Collector): always run postCheck, remove 'translatation' of message collector options (#3718)
* fix(*Collector): always run postCheck, correctly 'translate' message collector options * fix(MessageCollector): remove translation, fix postCheck conditions
This commit is contained in:
@@ -36,9 +36,6 @@ class MessageCollector extends Collector {
|
|||||||
if (this.client.getMaxListeners() !== 0) this.client.setMaxListeners(this.client.getMaxListeners() + 1);
|
if (this.client.getMaxListeners() !== 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)
|
|
||||||
if (this.options.max) this.options.maxProcessed = this.options.max;
|
|
||||||
if (this.options.maxMatches) this.options.max = this.options.maxMatches;
|
|
||||||
this._reEmitter = message => {
|
this._reEmitter = message => {
|
||||||
/**
|
/**
|
||||||
* Emitted when the collector receives a message.
|
* Emitted when the collector receives a message.
|
||||||
@@ -81,8 +78,8 @@ class MessageCollector extends Collector {
|
|||||||
*/
|
*/
|
||||||
postCheck() {
|
postCheck() {
|
||||||
// Consider changing the end reasons for v12
|
// Consider changing the end reasons for v12
|
||||||
if (this.options.maxMatches && this.collected.size >= this.options.max) return 'matchesLimit';
|
if (this.options.maxMatches && this.collected.size >= this.options.maxMatches) return 'matchesLimit';
|
||||||
if (this.options.max && this.received >= this.options.maxProcessed) return 'limit';
|
if (this.options.max && this.received >= this.options.max) return 'limit';
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,17 +79,17 @@ class Collector extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
_handle(...args) {
|
_handle(...args) {
|
||||||
const collect = this.handle(...args);
|
const collect = this.handle(...args);
|
||||||
if (!collect || !this.filter(...args, this.collected)) return;
|
if (collect && this.filter(...args, this.collected)) {
|
||||||
|
this.collected.set(collect.key, collect.value);
|
||||||
|
|
||||||
this.collected.set(collect.key, collect.value);
|
/**
|
||||||
|
* Emitted whenever an element is collected.
|
||||||
/**
|
* @event Collector#collect
|
||||||
* Emitted whenever an element is collected.
|
* @param {*} element The element that got collected
|
||||||
* @event Collector#collect
|
* @param {Collector} collector The collector
|
||||||
* @param {*} element The element that got collected
|
*/
|
||||||
* @param {Collector} collector The collector
|
this.emit('collect', collect.value, this);
|
||||||
*/
|
}
|
||||||
this.emit('collect', collect.value, this);
|
|
||||||
|
|
||||||
const post = this.postCheck(...args);
|
const post = this.postCheck(...args);
|
||||||
if (post) this.stop(post);
|
if (post) this.stop(post);
|
||||||
|
|||||||
Reference in New Issue
Block a user