From d0463926c4c5f5677ed5dd13dc30b0b650481b2c Mon Sep 17 00:00:00 2001 From: Schuyler Cebulskie Date: Tue, 18 Oct 2016 21:23:35 -0400 Subject: [PATCH] Add maxMatches CollectorOption --- src/structures/MessageCollector.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/structures/MessageCollector.js b/src/structures/MessageCollector.js index 48234d4a4..375bc845a 100644 --- a/src/structures/MessageCollector.js +++ b/src/structures/MessageCollector.js @@ -24,6 +24,7 @@ class MessageCollector extends EventEmitter { * @typedef {Object} CollectorOptions * @property {number} [time] Duration for the collector in milliseconds * @property {number} [max] Maximum number of messages to handle + * @property {number} [maxMatches] Maximum number of successfully filtered messages to obtain */ /** @@ -86,7 +87,8 @@ class MessageCollector extends EventEmitter { * @event MessageCollector#message */ this.emit('message', message, this); - if (this.options.max && this.collected.size === this.options.max) this.stop('limit'); + if (this.collected.size >= this.options.maxMatches) this.stop('matchesLimit'); + else if (this.options.max && this.collected.size === this.options.max) this.stop('limit'); return true; } return false;