summary refs log tree commit diff
path: root/src/util/Config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/Config.ts')
-rw-r--r--src/util/Config.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/util/Config.ts b/src/util/Config.ts
new file mode 100644
index 00000000..b22e88e0
--- /dev/null
+++ b/src/util/Config.ts
@@ -0,0 +1,30 @@
+import "missing-native-js-functions";
+import db from "./Database";
+import { ProviderCache } from "lambert-db";
+var Config: ProviderCache;
+
+export default {
+	init: async function init(opts: DefaultOptions = DefaultOptions) {
+		Config = db.data.config({}).cache();
+		await Config.init();
+		await Config.set(opts.merge(Config.cache || {}));
+	},
+	getAll: function get() {
+		return <DefaultOptions>Config.get();
+	},
+	setAll: function set(val: any) {
+		return Config.set(val);
+	},
+};
+
+export interface DefaultOptions {
+	api?: any;
+	gateway?: any;
+	voice?: any;
+}
+
+export const DefaultOptions: DefaultOptions = {
+	api: {},
+	gateway: {},
+	voice: {},
+};