aboutsummaryrefslogtreecommitdiff
path: root/src/lib/utils/Config.ts
blob: 65f43cb144be6376a2eafa3c8a29d40888580b21 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Snowflake } from 'discord.js';

export interface ConfigOptions {
	credentials: { token: string; betaToken: string; devToken: string; hypixelApiKey: string };
	environment: 'production' | 'beta' | 'development';
	owners: Snowflake[];
	prefix: string;
	channels: { log: Snowflake; error: Snowflake; dm: Snowflake };
	db: { host: string; port: number; username: string; password: string };
	logging: { db: boolean; verbose: boolean; info: boolean };
	supportGuild: {id: Snowflake, invite: string}
}

export class Config {
	public credentials: { token: string; betaToken: string; devToken: string; hypixelApiKey: string };
	public environment: 'production' | 'beta' | 'development';
	public owners: Snowflake[];
	public prefix: string;
	public channels: { log: Snowflake; error: Snowflake; dm: Snowflake };
	public db: { host: string; port: number; username: string; password: string };
	public logging: { db: boolean; verbose: boolean; info: boolean };
	public supportGuild: {id: Snowflake, invite: string}

	public constructor(options: ConfigOptions) {
		this.credentials = options.credentials;
		this.environment = options.environment;
		this.owners = options.owners;
		this.prefix = options.prefix;
		this.channels = options.channels;
		this.db = options.db;
		this.logging = options.logging;
		this.supportGuild = options.supportGuild
	}

	public get token(): string {
		return this.environment === 'production'
			? this.credentials.token
			: this.environment === 'beta'
			? this.credentials.betaToken
			: this.credentials.devToken;
	}

	public get isProduction(): boolean {
		return this.environment === 'production';
	}
	public get isBeta(): boolean {
		return this.environment === 'beta';
	}
	public get isDevelopment(): boolean {
		return this.environment === 'development';
	}
}