import { BaseRepository } from "./BaseRepository"; export class BaseGuildRepository extends BaseRepository { private static guildInstances: Map; protected guildId: string; constructor(guildId: string) { super(); this.guildId = guildId; } /** * Returns a cached instance of the inheriting class for the specified guildId, * or creates a new instance if one doesn't exist yet */ public static getGuildInstance(this: T, guildId: string): InstanceType { if (!this.guildInstances) { this.guildInstances = new Map(); } if (!this.guildInstances.has(guildId)) { this.guildInstances.set(guildId, new this(guildId)); } return this.guildInstances.get(guildId) as InstanceType; } }