-
Notifications
You must be signed in to change notification settings - Fork 0
/
envs.ts
58 lines (48 loc) · 1.56 KB
/
envs.ts
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
export interface Environment {
discordClientId: string;
discordClientPublicKey: string;
discordToken: string;
discordGuildId: string;
authorizedRoleIds: string[];
reviewChannelId: string;
}
let environment: Environment | null = null;
export function getEnvironment(): Environment {
if (environment) {
return environment;
}
if (!process.env.DISCORD_CLIENT_ID) {
throw new Error("DISCORD_CLIENT_ID env var not configured");
}
const discordClientId = process.env.DISCORD_CLIENT_ID;
if (!process.env.DISCORD_CLIENT_PUBLIC_KEY) {
throw new Error("DISCORD_CLIENT_PUBLIC_KEY env var not configured");
}
const discordClientPublicKey = process.env.DISCORD_CLIENT_PUBLIC_KEY;
if (!process.env.DISCORD_TOKEN) {
throw new Error(`DISCORD_TOKEN env var not configured`);
}
const discordToken = process.env.DISCORD_TOKEN;
if (!process.env.DISCORD_GUILD_ID) {
throw new Error("DISCORD_GUILD_ID env var not configured");
}
const discordGuildId = process.env.DISCORD_GUILD_ID;
if (!process.env.DISCORD_MODERATION_ACCESS_ROLES) {
throw new Error("DISCORD_MODERATION_ACCESS_ROLES env var not configured");
}
const authorizedRoleIds =
process.env.DISCORD_MODERATION_ACCESS_ROLES.split(",");
if (!process.env.REVIEW_CHANNEL_ID) {
throw new Error("REVIEW_CHANNEL_ID env var not configured");
}
const reviewChannelId = process.env.REVIEW_CHANNEL_ID;
environment = {
discordClientId,
discordClientPublicKey,
discordToken,
discordGuildId,
authorizedRoleIds,
reviewChannelId,
};
return environment;
}