aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions/discord.js/BushGuild.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/extensions/discord.js/BushGuild.ts')
-rw-r--r--src/lib/extensions/discord.js/BushGuild.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/BushGuild.ts
new file mode 100644
index 0000000..95e07f9
--- /dev/null
+++ b/src/lib/extensions/discord.js/BushGuild.ts
@@ -0,0 +1,20 @@
+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<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();
+ }
+}