mirror of
https://github.com/danbulant/discord.js
synced 2026-05-25 04:52:22 +00:00
Add CollectorOptions.max
This commit is contained in:
parent
a638b6369a
commit
91b1fa8359
2 changed files with 7 additions and 2 deletions
File diff suppressed because one or more lines are too long
|
|
@ -22,6 +22,7 @@ const EventEmitter = require('events').EventEmitter;
|
|||
* {
|
||||
* time: null, // time in milliseconds. If specified, the collector ends after this amount of time.
|
||||
* allowSelf: false, // whether or not the filter should take messages from the logged in client.
|
||||
* max: null, // the maximum amount of messages to handle before ending.
|
||||
* }
|
||||
* ```
|
||||
* @typedef {Object} CollectorOptions
|
||||
|
|
@ -88,6 +89,9 @@ 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');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -109,7 +113,8 @@ class MessageCollector extends EventEmitter {
|
|||
* during the lifetime of the Collector.
|
||||
* Mapped by the ID of the Messages.
|
||||
* @param {String} reason The reason for the end of the collector. If it ended because it reached the specified time
|
||||
* limit, this would be `time`. If you invoke `.stop()` without specifying a reason, this would be `user`.
|
||||
* limit, this would be `time`. If you invoke `.stop()` without specifying a reason, this would be `user`. If it
|
||||
* ended because it reached its message limit, it will be `limit`.
|
||||
* @event MessageCollector#end
|
||||
*/
|
||||
this.emit('end', this.collected, reason);
|
||||
|
|
|
|||
Loading…
Reference in a new issue