This repository was archived by the owner on Sep 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathshardingManager.js
More file actions
52 lines (39 loc) · 1.53 KB
/
Copy pathshardingManager.js
File metadata and controls
52 lines (39 loc) · 1.53 KB
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
require('dotenv').load();
const API = require('discord.js');
const SELF = require('./package.json');
const WEBHELPER = require('./http/app');
const PREPAREDB = require('./const/prepareDB');
const trueOrNot = process.env.webhelper === "true" ? true : false; // eslint-disable-line no-unneeded-ternary
process.title = `MonoxBot ${SELF['version']}`
/* eslint-disable no-console */
class MonoxSharding { // eslint-disable-line no-unused-vars
constructor() {
this.init();
}
init() {
const shardManager = new API.ShardingManager('./bot.js', { // eslint-disable-line no-unused-vars
token: process.env.TOKEN
});
console.log(`[SHARD M] [Module] discord.js ${API.version} loaded.`);
console.log(`[SHARD M] [MonoxBot Framework] MonoxBot ${SELF['version']} launching... `);
if (trueOrNot) {
new WEBHELPER();
console.log(`[SHARD M] [WEBHELPER] Initializing Webhelper API at port 3000`);
} else {
console.log(`[SHARD M] [WEBHELPER] [WARNING] Webhelper API is disabled.`);
}
shardManager.spawn();
console.log(`[SHARD M] [MANAGER] Initializing ${shardManager.totalShards.toString()} shards about ${(isNaN(shardManager.totalShards) ? 0 : shardManager.totalShards - 1) * 7.5}s`)
}
}
if (process.argv.includes('--prepare')) {
console.log('[Shard M] [Database] Preparing Database...');
PREPAREDB().then(() => {
console.log('[Shard M] [Database] Database prepared! Now you can run this bot.');
process.exit();
}).catch((err) => { // eslint-disable-line newline-per-chained-call
throw err;
})
} else {
new MonoxSharding();
}