From 1c24a19be1e453a2e7e5a332f899b96fda0a0af8 Mon Sep 17 00:00:00 2001 From: Dominic Ferrando Date: Sat, 22 Aug 2026 18:43:02 -0400 Subject: [PATCH] Setup DataService --- src/services/data.ts | 22 ++++++++++++++++++++++ src/services/role.ts | 4 ++++ 2 files changed, 26 insertions(+) create mode 100644 src/services/data.ts diff --git a/src/services/data.ts b/src/services/data.ts new file mode 100644 index 0000000..37b40b9 --- /dev/null +++ b/src/services/data.ts @@ -0,0 +1,22 @@ +export default class DataService { + private static file: Bun.BunFile | undefined; + private static _data: Record = {}; + + static async load() { + this.file = Bun.file("./data.json"); + if (!(await this.file.exists())) + await Bun.write(this.file, JSON.stringify({}, null, 2)); + this._data = await this.file.json(); + } + + static set data(data: Record) { + if (!this.file) throw new Error("DataService is not loaded. Please call DataService.load()"); + this._data = data; + void Bun.write(this.file, JSON.stringify(this._data, null, 2)); + } + + static get data() { + if (!this.file) throw new Error("DataService is not loaded. Please call DataService.load()"); + return this._data + } +} diff --git a/src/services/role.ts b/src/services/role.ts index d37ebc3..02b98b9 100644 --- a/src/services/role.ts +++ b/src/services/role.ts @@ -93,6 +93,10 @@ export default abstract class RoleService { } } + static async setLimboMode(mode: boolean) { + + } + static getRoleByName(guild: Guild, roleName?: string) { return guild.roles.cache.find(role => role.name === roleName); }