import { Guild } from 'discord.js'; import { Guild as GuildDB, GuildModel } from '../../models/Guild'; import { BushClient } from '../discord-akairo/BushClient'; export class BushGuild extends Guild { public declare readonly client: BushClient; public constructor(client: BushClient, data: unknown) { super(client, data); } public async getSetting(setting: K): Promise { return ((await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id })).get(setting); } public async setSetting(setting: K, value: GuildDB[K]): Promise { const row = (await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id }); row[setting] = value; return await row.save(); } }