-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
35 lines (28 loc) · 940 Bytes
/
index.js
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
'use strict';
const logger = require('./src/logger');
const main = require('./src/main');
const ctx = require('./src/context');
const discordToken = process.env.DISCORD_TOKEN;
const discordGuildId = process.env.DISCORD_GUILD_ID;
const logsPath = process.env.LOGS_PATH || 'logs/hop.log';
const verifiedGroup = process.env.VERIFIED_GROUP;
verifyEnv('discordToken', discordToken);
verifyEnv('discordGuildId', discordGuildId);
verifyEnv('logsPath', logsPath);
verifyEnv('verifiedGroup', verifiedGroup)
ctx.DiscrodGuildId = discordGuildId;
ctx.DiscordToken = discordToken;
ctx.VerifiedGroup = verifiedGroup;
logger(logsPath);
main();
function verifyEnv(varName, envVar) {
if (!envVar) {
console.error(`unable to find '${varName}', ensure you have configured environment properly`);
process.exit(-1);
}
}
Object.assign(String.prototype, {
trimIndent() {
return this.replace(/(\n)\s+/g, '$1');
}
});