Setup DataService

This commit is contained in:
2026-08-22 18:44:24 -04:00
parent a744a95307
commit 1c24a19be1
2 changed files with 26 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
export default class DataService {
private static file: Bun.BunFile | undefined;
private static _data: Record<string, unknown> = {};
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<string, unknown>) {
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
}
}
+4
View File
@@ -93,6 +93,10 @@ export default abstract class RoleService {
} }
} }
static async setLimboMode(mode: boolean) {
}
static getRoleByName(guild: Guild, roleName?: string) { static getRoleByName(guild: Guild, roleName?: string) {
return guild.roles.cache.find(role => role.name === roleName); return guild.roles.cache.find(role => role.name === roleName);
} }