blob: 7504658cf6b495004c11a8422cc6a87ba0822309 (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
import type { Snowflake } from 'discord.js';
export class Config {
public credentials: Credentials;
public environment: Environment;
public owners: Snowflake[];
public prefix: string;
public channels: Channels;
public db: DataBase;
public logging: Logging;
public supportGuild: SupportGuild;
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;
}
/**
* The appropriate discord token for the environment.
*/
public get token(): string {
switch (this.environment) {
case 'production':
return this.credentials.token;
case 'beta':
return this.credentials.betaToken;
case 'development':
return this.credentials.devToken;
}
}
/**
* Whether this is the production instance of the bot.
*/
public get isProduction(): boolean {
return this.environment === 'production';
}
/**
* Whether this is the beta instance of the bot.
*/
public get isBeta(): boolean {
return this.environment === 'beta';
}
/**
* Whether this is the development instance of the bot.
*/
public get isDevelopment(): boolean {
return this.environment === 'development';
}
}
export interface ConfigOptions {
credentials: Credentials;
environment: Environment;
owners: Snowflake[];
prefix: string;
channels: Channels;
db: DataBase;
logging: Logging;
supportGuild: SupportGuild;
}
interface Credentials {
token: string;
betaToken: string;
devToken: string;
hypixelApiKey: string;
wolframAlphaAppId: string;
imgurClientId: string;
imgurClientSecret: string;
sentryDsn: string;
perspectiveApiKey: string;
}
type Environment = 'production' | 'beta' | 'development';
interface Channels {
log: Snowflake;
error: Snowflake;
dm: Snowflake;
servers: Snowflake;
}
interface DataBase {
host: string;
port: number;
username: string;
password: string;
}
interface Logging {
db: boolean;
verbose: boolean;
info: boolean;
}
interface SupportGuild {
id: Snowflake;
invite: string;
}
|