mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
Stop multiple end events
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -49,6 +49,11 @@ class MessageCollector extends EventEmitter {
|
|||||||
* @type {CollectorOptions}
|
* @type {CollectorOptions}
|
||||||
*/
|
*/
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
/**
|
||||||
|
* Whether this collector has stopped collecting Messages.
|
||||||
|
* @type {Boolean}
|
||||||
|
*/
|
||||||
|
this.ended = false;
|
||||||
this.listener = (message => this.verify(message));
|
this.listener = (message => this.verify(message));
|
||||||
this.channel.client.on('message', this.listener);
|
this.channel.client.on('message', this.listener);
|
||||||
/**
|
/**
|
||||||
@@ -93,6 +98,10 @@ class MessageCollector extends EventEmitter {
|
|||||||
* @param {string} [reason='user'] an optional reason for stopping the collector.
|
* @param {string} [reason='user'] an optional reason for stopping the collector.
|
||||||
*/
|
*/
|
||||||
stop(reason = 'user') {
|
stop(reason = 'user') {
|
||||||
|
if (this.ended) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.ended = true;
|
||||||
this.channel.client.removeListener('message', this.listener);
|
this.channel.client.removeListener('message', this.listener);
|
||||||
/**
|
/**
|
||||||
* Emitted when the Collector stops collecting.
|
* Emitted when the Collector stops collecting.
|
||||||
|
|||||||
Reference in New Issue
Block a user