-
Notifications
You must be signed in to change notification settings - Fork 31
/
index.js
57 lines (54 loc) · 1.65 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
require("./bot/utilities/module-alias.js")();
const config = require("@config");
const { ShardingManager } = require("discord.js");
const logger = require("./bot/utilities/logger.js");
const manager = new ShardingManager("./bot/handlers/index.js", {
totalShards: "auto",
token: config.token,
});
// const Statcord = require("statcord.js").ShardingClient;
// const stat = config.statcordKey && config.statcordKey !== "optional, leave empty if you don't want" ? new Statcord({
// key: config.statcordKey,
// manager: manager,
// postCpuStatistics: true,
// postMemStatistics: true,
// postNetworkStatistics: true,
// autopost: true
// }) : null;
manager.on("shardCreate", (shard) => {
logger.shard(`[Shard ${shard.id}] Shard Launched!`);
shard.on("ready", () => {
logger.shard(`[Shard ${shard.id}] Shard Ready!`);
});
shard.on("message", (message) => {
if (message === "kill") return shard.kill();
});
shard.on("disconnect", (a, b) => {
logger.shard(`[Shard ${shard.id}] Shard disconnected.`);
logger.shard(a);
logger.shard(b);
});
shard.on("reconnecting", (a, b) => {
logger.shard(`[Shard ${shard.id}] Reconnecting.`);
logger.shard(a);
logger.shard(b);
});
shard.on("death", (a, b) => {
logger.shard(`[Shard ${shard.id}] Shard died.`);
a ? logger.shard(a) : null;
b ? logger.shard(b) : null;
});
});
manager.spawn();
process.on("unhandledRejection", (error) => {
logger.error(error);
});
// if (stat) {
// stat.on("autopost-start", () => {
// logger.info("[Statcord] Autopost started!");
// });
// stat.on("post", status => {
// if (!status) logger.info("[Statcord] Autopost successful!");
// else logger.error(status);
// });
// };