summary refs log tree commit diff
path: root/src/util/Config.ts
blob: 5886b2681a8b75dc979e8d2ff648d3c02a9ab173 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 = await 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: {},
};