forked from ChristopherBThai/Discord-OwO-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
60 lines (54 loc) · 1.67 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
/*
* OwO Bot for Discord
* Copyright (C) 2019 Christopher Thai
* This software is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
* For more information, see README.md and LICENSE
*/
// Grab tokens and secret files
const debug = false;
if(!debug) var tracer = require('dd-trace').init()
if(debug) var auth = require('../tokens/scuttester-auth.json');
else var auth = require('../tokens/owo-auth.json');
// Config file
const config = require('./src/data/config.json');
const request = require('./utils/request.js');
// Eris-Sharder
const Sharder = require('eris-sharder').Master;
var result,shards,firstShardID,lastShardID;
// Helper files
if(require('cluster').isMaster){
const global = require('./utils/global.js');
const RamCheck = new (require('./utils/ramCheck.js'))(global);
}
(async () => {
try{
//determine how many shards we will need for this manager
if (!debug&&require('cluster').isMaster){
result = await request.fetchInit();
shards = result["shards"];
firstShardID = result["firstShardID"];
lastShardID = result["lastShardID"];
}
// How many clusters we will have
var clusters = Math.ceil(shards/5);
if(debug){
shards = 4;
firstShardID = 0;
lastShardID = shards-1;
clusters = 2
}
console.log("Creating shards "+firstShardID+"~"+lastShardID+" out of "+shards+" total shards!");
// Start sharder
const sharder = new Sharder("Bot "+auth.token, config.sharder.path, {
name: config.sharder.name,
clientOptions: config.eris.clientOptions,
debug:true,
shards,clusters,
firstShardID,
lastShardID,
});
}catch(e){
console.error("Failed to start eris sharder");
console.error(e);
}
})();