-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
64 lines (57 loc) · 2.25 KB
/
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
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
const fs = require('fs');
// load environment variables, depending on if bot is running in docker, or locally
if (process.env.CLIENT_TOKEN && process.env.CLIENT_TOKEN.startsWith('/')) {
process.env.CLIENT_TOKEN = fs.readFileSync(process.env.CLIENT_TOKEN).toString().trim();
process.env.SQL_HOST = fs.readFileSync(process.env.SQL_HOST).toString().trim();
process.env.SQL_USER = fs.readFileSync(process.env.SQL_USER).toString().trim();
process.env.SQL_PASS = fs.readFileSync(process.env.SQL_PASS).toString().trim();
process.env.SQL_NAME = fs.readFileSync(process.env.SQL_NAME).toString().trim();
}
else {
require('dotenv').config();
}
// define directories globally
dirSplit = (process.platform === 'win32' ? '\\' : '/');
appRoot = __dirname + dirSplit;
appData = appRoot + 'app_data' + dirSplit;
appLogs = appData + 'logs' + dirSplit;
appSchedule = appData + 'schedule' + dirSplit;
// create necessary folders to prevent failed logging on database initialization
if (!fs.existsSync(appData)) {
fs.mkdirSync(appData);
}
if (!fs.existsSync(appLogs)) {
fs.mkdirSync(appLogs);
}
if (!fs.existsSync(appSchedule)) {
fs.mkdirSync(appSchedule);
}
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const { initialize, login } = require('./ClientHandlers/ClientHandler');
//const { LogApplication, LogLevel, LogStatus } = require('./Log/Logger');
// process.on('uncaughtException', async (error, source) => {
// LogApplication(source, error.message, LogStatus.Error, LogLevel.Error, error.stack);
// if (process.env.ENVIRONMENT == 'DEVELOPMENT') process.exit(1);
// });
// process.on('unhandledRejection', async (event) => {
// LogApplication('UnhandledRejection', event.reason.message, LogStatus.Error, LogLevel.Error, event.reason.stack);
// if (process.env.ENVIRONMENT == 'DEVELOPMENT') process.exit(15);
// });
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.MessageContent
],
partials: [
Partials.Message,
Partials.Channel,
Partials.User,
Partials.GuildMember,
Partials.Reaction
]
});
initialize(client).then(() => login());