-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
67 lines (59 loc) · 1.62 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
65
66
67
require("dotenv").config();
const Sharder = require("eris-sharder").Master;
const cluster = require("cluster");
const init = async () => {
if(cluster.isMaster) {
try {
require("./auth.json");
throw new Error("outdated");
} catch(e) {
if(e.message == "outdated") throw new Error("auth.json is outdated, please use the .env file instead! See the github page for more info");
}
await require("./modules/db").init();
}
let sharder = new Sharder("Bot " + process.env.DISCORD_TOKEN,"/bot.js",{
clientOptions: {
disableEvents: {
GUILD_BAN_ADD: true,
GUILD_BAN_REMOVE: true,
MESSAGE_DELETE: true,
MESSAGE_DELETE_BULK: true,
TYPING_START: true,
VOICE_STATE_UPDATE: true
},
messageLimit: 0,
guildSubscriptions: false,
allowedMentions: { roles: false },
restMode: true,
ratelimiterOffset: 5,
intents: [
"guilds",
"guildMessages",
"guildMessageReactions",
"directMessages",
"directMessageReactions"
],
maxConcurrency: "auto"
},
stats: true,
debug: true,
shards: +process.env.SHARDS,
clusters: +process.env.CLUSTERS || process.env.DEV? 1 : undefined,
name: "silver memory",
clusterTimeout: 0.1
});
sharder.eris.on("debug",console.log);
if(cluster.isMaster) {
let events = require("./modules/ipc.js");
cluster.on("message",(worker,message) => {
if(message.name == "reloadIPC") {
delete require.cache[require.resolve("./modules/ipc.js")];
events = require("./modules/ipc.js");
console.log("Reloaded IPC plugin!");
} else if(events[message.name]) {
events[message.name](worker,message,sharder);
}
});
}
};
init();