mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
Improve docs a bit
This commit is contained in:
@@ -4,14 +4,14 @@ const EventEmitter = require('events').EventEmitter;
|
||||
/**
|
||||
* Filter to be applied to the collector.
|
||||
* @typedef {Function} CollectorFilter
|
||||
* @param {...*} args Any arguments received by the listener.
|
||||
* @returns {boolean} To collect or not collect.
|
||||
* @param {...*} args Any arguments received by the listener
|
||||
* @returns {boolean} To collect or not collect
|
||||
*/
|
||||
|
||||
/**
|
||||
* Options to be applied to the collector.
|
||||
* @typedef {Object} CollectorOptions
|
||||
* @property {number} [time] How long to run the collector for.
|
||||
* @property {number} [time] How long to run the collector for
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -23,7 +23,7 @@ class Collector extends EventEmitter {
|
||||
super();
|
||||
|
||||
/**
|
||||
* The client.
|
||||
* The client
|
||||
* @name Collector#client
|
||||
* @type {Client}
|
||||
* @readonly
|
||||
@@ -31,39 +31,39 @@ class Collector extends EventEmitter {
|
||||
Object.defineProperty(this, 'client', { value: client });
|
||||
|
||||
/**
|
||||
* The filter applied to this collector.
|
||||
* The filter applied to this collector
|
||||
* @type {CollectorFilter}
|
||||
*/
|
||||
this.filter = filter;
|
||||
|
||||
/**
|
||||
* The options of this collector.
|
||||
* The options of this collector
|
||||
* @type {CollectorOptions}
|
||||
*/
|
||||
this.options = options;
|
||||
|
||||
/**
|
||||
* The items collected by this collector.
|
||||
* The items collected by this collector
|
||||
* @type {Collection}
|
||||
*/
|
||||
this.collected = new Collection();
|
||||
|
||||
/**
|
||||
* Whether this collector has finished collecting.
|
||||
* Whether this collector has finished collecting
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.ended = false;
|
||||
|
||||
/**
|
||||
* Timeout for cleanup.
|
||||
* Timeout for cleanup
|
||||
* @type {?Timeout}
|
||||
* @private
|
||||
*/
|
||||
this._timeout = null;
|
||||
|
||||
/**
|
||||
* Call this to handle an event as a collectable element.
|
||||
* Accepts any event data as parameters.
|
||||
* Call this to handle an event as a collectable element
|
||||
* Accepts any event data as parameters
|
||||
* @type {Function}
|
||||
* @private
|
||||
*/
|
||||
@@ -72,7 +72,7 @@ class Collector extends EventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {...*} args The arguments emitted by the listener.
|
||||
* @param {...*} args The arguments emitted by the listener
|
||||
* @emits Collector#collect
|
||||
* @private
|
||||
*/
|
||||
@@ -85,8 +85,8 @@ class Collector extends EventEmitter {
|
||||
/**
|
||||
* Emitted whenever an element is collected.
|
||||
* @event Collector#collect
|
||||
* @param {*} element The element that got collected.
|
||||
* @param {Collector} collector The collector.
|
||||
* @param {*} element The element that got collected
|
||||
* @param {Collector} collector The collector
|
||||
*/
|
||||
this.emit('collect', collect.value, this);
|
||||
|
||||
@@ -96,7 +96,7 @@ class Collector extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Return a promise that resolves with the next collected element;
|
||||
* rejects with collected elements if the collector finishes without receving a next element.
|
||||
* rejects with collected elements if the collector finishes without receving a next element
|
||||
* @type {Promise}
|
||||
* @readonly
|
||||
*/
|
||||
@@ -129,7 +129,7 @@ class Collector extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Stop this collector and emit the `end` event.
|
||||
* @param {string} [reason='user'] The reason this collector is ending.
|
||||
* @param {string} [reason='user'] The reason this collector is ending
|
||||
* @emits Collector#end
|
||||
*/
|
||||
stop(reason = 'user') {
|
||||
@@ -142,27 +142,27 @@ class Collector extends EventEmitter {
|
||||
/**
|
||||
* Emitted when the collector is finished collecting.
|
||||
* @event Collector#end
|
||||
* @param {Collection} collected The elements collected by the collector.
|
||||
* @param {string} reason The reason the collector ended.
|
||||
* @param {Collection} collected The elements collected by the collector
|
||||
* @param {string} reason The reason the collector ended
|
||||
*/
|
||||
this.emit('end', this.collected, reason);
|
||||
}
|
||||
|
||||
/* eslint-disable no-empty-function, valid-jsdoc */
|
||||
/**
|
||||
* Handles incoming events from the `listener` function. Returns null if the
|
||||
* event should not be collected, or returns an object describing the data that should be stored.
|
||||
* Handles incoming events from the `listener` function. Returns null if the event should not be collected,
|
||||
* or returns an object describing the data that should be stored.
|
||||
* @see Collector#listener
|
||||
* @param {...*} args Any args the event listener emits.
|
||||
* @returns {?{key: string, value}} Data to insert into collection, if any.
|
||||
* @param {...*} args Any args the event listener emits
|
||||
* @returns {?{key: string, value}} Data to insert into collection, if any
|
||||
* @abstract
|
||||
*/
|
||||
handle() {}
|
||||
|
||||
/**
|
||||
* This method runs after collection to see if the collector should finish.
|
||||
* @param {...*} args Any args the event listener emits.
|
||||
* @returns {?string} Reason to end the collector, if any.
|
||||
* @param {...*} args Any args the event listener emits
|
||||
* @returns {?string} Reason to end the collector, if any
|
||||
* @abstract
|
||||
*/
|
||||
postCheck() {}
|
||||
|
||||
Reference in New Issue
Block a user