Many changes, including: command registration works (now actually calls the command functions), fixed emoji embeds, started fixing some commands, database no longer uses proxy
diff --git a/src/utils/database.ts b/src/utils/database.ts
index 2c299d0..2ae6af9 100644
--- a/src/utils/database.ts
+++ b/src/utils/database.ts
@@ -1,30 +1,11 @@
import type Discord from "discord.js";
import { Collection, MongoClient } from "mongodb";
-// @ts-expect-error
-import structuredClone from "@ungap/structured-clone";
import config from "../config/main.json" assert { type: "json" };
const mongoClient = new MongoClient(config.mongoUrl);
await mongoClient.connect();
const database = mongoClient.db("Nucleus");
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export const Entry = (data: any) => {
- data = data ?? {};
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- data.getKey = (key: any) => data[key];
- return {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- get(target: Record<string, any>, prop: string, receiver: any) {
- let dataToReturn = data[prop];
- if (dataToReturn === null) return Reflect.get(target, prop, receiver);
- if (typeof dataToReturn === "object" && !Array.isArray(dataToReturn))
- dataToReturn = new Proxy(Reflect.get(target, prop, receiver), Entry(dataToReturn));
- return dataToReturn ?? Reflect.get(target, prop, receiver);
- }
- };
-};
-
export class Guilds {
guilds: Collection<GuildConfig>;
defaultData: GuildConfig | null;
@@ -42,7 +23,7 @@
async read(guild: string): Promise<GuildConfig> {
const entry = await this.guilds.findOne({ id: guild });
- return new Proxy(structuredClone(this.defaultData), Entry(entry)) as unknown as GuildConfig;
+ return Object.assign({}, this.defaultData, entry);
}
async write(guild: string, set: object | null, unset: string[] | string = []) {
@@ -263,6 +244,7 @@
};
};
verify: {
+ enabled: boolean;
role: string | null;
};
tickets: {