From 229eb2be2da11563c3c9978664e050044de720df Mon Sep 17 00:00:00 2001 From: Steven Date: Sun, 31 Dec 2017 13:21:29 -0600 Subject: [PATCH] Fix Collector bug where checkEnd is only called on a valid message (#2186) --- src/structures/interfaces/Collector.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/structures/interfaces/Collector.js b/src/structures/interfaces/Collector.js index 2c4fd158c..0e7f1f956 100644 --- a/src/structures/interfaces/Collector.js +++ b/src/structures/interfaces/Collector.js @@ -76,17 +76,18 @@ class Collector extends EventEmitter { */ handleCollect(...args) { const collect = this.collect(...args); - if (!collect || !this.filter(...args, this.collected)) return; - this.collected.set(collect.key, collect.value); + if (collect && this.filter(...args, this.collected)) { + this.collected.set(collect.key, collect.value); - /** - * Emitted whenever an element is collected. - * @event Collector#collect - * @param {*} element The element that got collected - * @param {...*} args The arguments emitted by the listener - */ - this.emit('collect', collect.value, ...args); + /** + * Emitted whenever an element is collected. + * @event Collector#collect + * @param {*} element The element that got collected + * @param {...*} args The arguments emitted by the listener + */ + this.emit('collect', collect.value, ...args); + } this.checkEnd(); }