import { Client, Collection, Guild } from "discord.js"; import { PrismaClient } from "@prisma/client"; import { BaseEntry, BaseGuildCache, iBaseGuildCache } from "../"; export type iBaseBotCache

, BC extends BaseBotCache> = new (GCClass: iBaseGuildCache, bot: Client, prisma: P) => BC; /** * A class that contains global information about the Discord Bot. * Contains all GuildCache of each guild. * * Only one instance of this class should exist. */ export default abstract class BaseBotCache

> { private readonly GCClass; /** * The Discord Client that is used to interact with the Discord API. */ readonly bot: Client; readonly prisma: P; /** * The collection that contains all GuildCaches. */ readonly caches: Collection; constructor(GCClass: iBaseGuildCache, /** * The Discord Client that is used to interact with the Discord API. */ bot: Client, prisma: P); /** * Get a Guild's cache. * * @param guild Guild class from Discord * @returns A promise that returns the GuildCache of the guild */ getGuildCache(guild: Guild): Promise; /** * A method that is called when the BotCache is constructed. */ onConstruct(): void; /** * A method that is called when a GuildCache is stored in the BotCache. * * @param cache The GuildCache that was just created. */ onSetGuildCache(cache: GC): void; /** * Setup the GuildCache and entry for a new guild * * @param guildId The ID of the guild that was created */ abstract registerGuildCache(guildId: string): void; /** * Destroy the GuildCache and entry for the deleted guild * * @param guildId The ID of the guild that was deleted */ abstract eraseGuildCache(guildId: string): void; }