blob: ea34aec0b864095507c7f8f2ad188bba94c95e8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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;
// I cba to do this
//// public declare members: GuildMemberManager;
public constructor(client: BushClient, data: unknown) {
super(client, data);
}
public async getSetting<K extends keyof GuildModel>(setting: K): Promise<GuildModel[K]> {
return ((await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id })).get(setting);
}
public async setSetting<K extends keyof GuildModel>(setting: K, value: GuildDB[K]): Promise<GuildDB> {
const row = (await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id });
row[setting] = value;
return await row.save();
}
}
|