diff --git a/packages/discord.js/src/structures/InteractionCollector.js b/packages/discord.js/src/structures/InteractionCollector.js index 36b0f6103..a9645af02 100644 --- a/packages/discord.js/src/structures/InteractionCollector.js +++ b/packages/discord.js/src/structures/InteractionCollector.js @@ -197,7 +197,7 @@ class InteractionCollector extends Collector { if (this.options.max && this.total >= this.options.max) return 'limit'; if (this.options.maxComponents && this.collected.size >= this.options.maxComponents) return 'componentLimit'; if (this.options.maxUsers && this.users.size >= this.options.maxUsers) return 'userLimit'; - return null; + return super.endReason; } /** diff --git a/packages/discord.js/src/structures/MessageCollector.js b/packages/discord.js/src/structures/MessageCollector.js index 736bd68de..710196541 100644 --- a/packages/discord.js/src/structures/MessageCollector.js +++ b/packages/discord.js/src/structures/MessageCollector.js @@ -103,7 +103,7 @@ class MessageCollector extends Collector { 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'; - return null; + return super.endReason; } /** diff --git a/packages/discord.js/src/structures/ReactionCollector.js b/packages/discord.js/src/structures/ReactionCollector.js index 0c0b9e0f3..924b33bf1 100644 --- a/packages/discord.js/src/structures/ReactionCollector.js +++ b/packages/discord.js/src/structures/ReactionCollector.js @@ -165,7 +165,7 @@ class ReactionCollector extends Collector { if (this.options.max && this.total >= this.options.max) return 'limit'; if (this.options.maxEmojis && this.collected.size >= this.options.maxEmojis) return 'emojiLimit'; if (this.options.maxUsers && this.users.size >= this.options.maxUsers) return 'userLimit'; - return null; + return super.endReason; } /** diff --git a/packages/discord.js/src/structures/interfaces/Collector.js b/packages/discord.js/src/structures/interfaces/Collector.js index 20cb71e4f..c700cf64e 100644 --- a/packages/discord.js/src/structures/interfaces/Collector.js +++ b/packages/discord.js/src/structures/interfaces/Collector.js @@ -78,6 +78,13 @@ class Collector extends EventEmitter { */ this._idletimeout = null; + /** + * The reason the collector ended + * @type {string|null} + * @private + */ + this._endReason = null; + if (typeof this.filter !== 'function') { throw new TypeError('INVALID_TYPE', 'options.filter', 'function'); } @@ -187,6 +194,8 @@ class Collector extends EventEmitter { clearTimeout(this._idletimeout); this._idletimeout = null; } + + this._endReason = reason; this.ended = true; /** @@ -270,9 +279,10 @@ class Collector extends EventEmitter { * The reason this collector has ended with, or null if it hasn't ended yet * @type {?string} * @readonly - * @abstract */ - get endReason() {} + get endReason() { + return this._endReason; + } /** * Handles incoming events from the `handleCollect` function. Returns null if the event should not diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index b5d95f152..9814c6d2e 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -875,11 +875,12 @@ export abstract class Collector extends EventEmi protected constructor(client: Client, options?: CollectorOptions<[V, ...F]>); private _timeout: NodeJS.Timeout | null; private _idletimeout: NodeJS.Timeout | null; + private _endReason: string | null; public readonly client: Client; public collected: Collection; public ended: boolean; - public abstract get endReason(): string | null; + public get endReason(): string | null; public filter: CollectorFilter<[V, ...F]>; public get next(): Promise; public options: CollectorOptions<[V, ...F]>; @@ -1552,7 +1553,6 @@ export class InteractionCollector extends Collector