From 7dd1a8da08830525d292059ee3bd2c86d5f964f6 Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Sat, 3 Jul 2021 14:23:15 +0200 Subject: [PATCH] docs(Collector): properly document endReason (#6016) --- src/structures/MessageCollector.js | 5 +++++ .../MessageComponentInteractionCollector.js | 5 +++++ src/structures/ReactionCollector.js | 5 +++++ src/structures/interfaces/Collector.js | 15 ++++++++------- typings/index.d.ts | 2 +- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/structures/MessageCollector.js b/src/structures/MessageCollector.js index 09f4ffb7a..9eb13d8a9 100644 --- a/src/structures/MessageCollector.js +++ b/src/structures/MessageCollector.js @@ -89,6 +89,11 @@ class MessageCollector extends Collector { return message.channel.id === this.channel.id ? message.id : null; } + /** + * The reason this collector has ended with, or null if it hasn't ended yet + * @type {?string} + * @readonly + */ get endReason() { if (this.options.max && this.collected.size >= this.options.max) return 'limit'; if (this.options.maxProcessed && this.received === this.options.maxProcessed) return 'processedLimit'; diff --git a/src/structures/MessageComponentInteractionCollector.js b/src/structures/MessageComponentInteractionCollector.js index 2ca3561ac..2f31d3763 100644 --- a/src/structures/MessageComponentInteractionCollector.js +++ b/src/structures/MessageComponentInteractionCollector.js @@ -130,6 +130,11 @@ class MessageComponentInteractionCollector extends Collector { this.checkEnd(); } + /** + * The reason this collector has ended with, or null if it hasn't ended yet + * @type {?string} + * @readonly + */ get endReason() { if (this.options.max && this.total >= this.options.max) return 'limit'; if (this.options.maxComponents && this.collected.size >= this.options.maxComponents) return 'componentLimit'; diff --git a/src/structures/ReactionCollector.js b/src/structures/ReactionCollector.js index 500eecb06..ceb19ab54 100644 --- a/src/structures/ReactionCollector.js +++ b/src/structures/ReactionCollector.js @@ -145,6 +145,11 @@ class ReactionCollector extends Collector { this.checkEnd(); } + /** + * The reason this collector has ended with, or null if it hasn't ended yet + * @type {?string} + * @readonly + */ get endReason() { if (this.options.max && this.total >= this.options.max) return 'limit'; if (this.options.maxEmojis && this.collected.size >= this.options.maxEmojis) return 'emojiLimit'; diff --git a/src/structures/interfaces/Collector.js b/src/structures/interfaces/Collector.js index 31ad91902..64e8b0029 100644 --- a/src/structures/interfaces/Collector.js +++ b/src/structures/interfaces/Collector.js @@ -264,6 +264,14 @@ class Collector extends EventEmitter { } /* eslint-disable no-empty-function */ + /** + * The reason this collector has ended with, or null if it hasn't ended yet + * @type {?string} + * @readonly + * @abstract + */ + get endReason() {} + /** * Handles incoming events from the `handleCollect` function. Returns null if the event should not * be collected, or returns an object describing the data that should be stored. @@ -284,13 +292,6 @@ class Collector extends EventEmitter { */ dispose() {} /* eslint-enable no-empty-function */ - - /** - * The reason this collector has ended with, or null if it hasn't ended yet - * @name Collector#endReason - * @type {?string} - * @abstract - */ } module.exports = Collector; diff --git a/typings/index.d.ts b/typings/index.d.ts index 4d7ce8c28..70e10be03 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -540,7 +540,7 @@ declare module 'discord.js' { public readonly client: Client; public collected: Collection; public ended: boolean; - public abstract endReason: string | null; + public abstract readonly endReason: string | null; public filter: CollectorFilter<[V, ...F]>; public readonly next: Promise; public options: CollectorOptions<[V, ...F]>;