aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions/BushGuild.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/extensions/BushGuild.ts')
-rw-r--r--src/lib/extensions/BushGuild.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/extensions/BushGuild.ts b/src/lib/extensions/BushGuild.ts
new file mode 100644
index 0000000..470e93a
--- /dev/null
+++ b/src/lib/extensions/BushGuild.ts
@@ -0,0 +1,20 @@
+import { Guild } from 'discord.js';
+import { Guild as GuildDB, GuildModel } from '../models/Guild';
+import { BushClient } from './BushClient';
+
+export class BushGuild extends Guild {
+ public declare client: BushClient;
+ public constructor(client: BushClient, data: unknown) {
+ super(client, data);
+ }
+
+ public async getSetting(setting: keyof GuildModel) {
+ 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]) {
+ const row = (await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id });
+ row[setting] = value;
+ return await row.save();
+ }
+}