diff --git a/src/index.js b/src/index.js index c448943a5..406d4f72e 100644 --- a/src/index.js +++ b/src/index.js @@ -17,7 +17,6 @@ module.exports = { Collection: require('./util/Collection'), Constants: require('./util/Constants'), DataResolver: require('./util/DataResolver'), - LimitedCollection: require('./util/LimitedCollection'), BaseManager: require('./managers/BaseManager'), DiscordAPIError: require('./rest/DiscordAPIError'), HTTPError: require('./rest/HTTPError'), diff --git a/src/managers/MessageManager.js b/src/managers/MessageManager.js index 321dc4550..2c0db3b7f 100644 --- a/src/managers/MessageManager.js +++ b/src/managers/MessageManager.js @@ -21,7 +21,7 @@ class MessageManager extends BaseManager { /** * The cache of Messages - * @type {LimitedCollection} + * @type {Collection} * @name MessageManager#cache */ diff --git a/src/util/LimitedCollection.js b/src/util/LimitedCollection.js index 5719a9fa6..caa49780f 100644 --- a/src/util/LimitedCollection.js +++ b/src/util/LimitedCollection.js @@ -8,6 +8,7 @@ const Collection = require('./Collection.js'); * @extends {Collection} * @param {number} [maxSize=0] The maximum size of the Collection * @param {Iterable} [iterable=null] Optional entries passed to the Map constructor. + * @private */ class LimitedCollection extends Collection { constructor(maxSize = 0, iterable = null) { @@ -24,6 +25,10 @@ class LimitedCollection extends Collection { if (this.size >= this.maxSize && !this.has(key)) this.delete(this.firstKey()); return super.set(key, value); } + + static get [Symbol.species]() { + return Collection; + } } module.exports = LimitedCollection; diff --git a/typings/index.d.ts b/typings/index.d.ts index 899211dc0..8ceee251b 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1914,11 +1914,6 @@ declare module 'discord.js' { public toJSON(): object; } - export class LimitedCollection extends Collection { - public constructor(maxSize: number, iterable: Iterable); - public maxSize: number; - } - //#endregion //#region Managers @@ -2016,7 +2011,7 @@ declare module 'discord.js' { export class MessageManager extends BaseManager { constructor(channel: TextChannel | DMChannel, iterable?: Iterable); public channel: TextBasedChannelFields; - public cache: LimitedCollection; + public cache: Collection; public fetch(message: Snowflake, cache?: boolean): Promise; public fetch(options?: ChannelLogsQueryOptions, cache?: boolean): Promise>; public fetchPinned(cache?: boolean): Promise>;