'user strict'
const Discord = require('discord.js')
const { BaseClass } = require('../Structures/BaseClass')
const { ErrorCodes } = require('../Errors/ErrorCodes')
const { MissingValue, InvalidValue } = require('../Errors/LME')
/**
* Base class for all the Managers.
*
* T is the class that the manager holds.
*
* @template T
* @extends {BaseClass}
*/
class BaseManager extends BaseClass {
/** @type {T} - The class that this manager holds. */
#holds
/** @type {Discord.Collection<String, T>} - The cache for the manager. */
#cache
/**
* @param {Discord.client} client - The Discord Client.
* @param {T} holds - The class that this manager holds.
*/
constructor (client, holds) {
super(client)
if (!holds) throw new MissingValue(ErrorCodes.MissingArgument, 'holds')
// If holds is not a constructor function, throw an error.
if (typeof holds !== 'function') throw new InvalidValue(ErrorCodes.InvalidValue, 'holds', 'a function')
this.#holds = holds
this.#cache = new Discord.Collection()
}
/**
* Class that this manager holds.
* @returns {T}
* @readonly
*/
get holds () {
return this.#holds
}
/**
* Cache of the manager
* @returns {Discord.Collection<String, T>}
*/
get cache () {
return this.#cache
}
}
module.exports = { BaseManager }