blob: 691dc92d364a23522c0c213a75989b4bdedc43cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import { Guild } from 'discord.js';
import { BushClient, Guild as GuildDB, GuildModel } from '../..';
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();
}
}
|