forked from GDColon/Polaris-Open
-
Notifications
You must be signed in to change notification settings - Fork 1
/
stardust.js
34 lines (27 loc) · 1.19 KB
/
stardust.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
const { ShardingManager } = require("discord.js");
const { AutoPoster } = require("topgg-autoposter");
const { totalShards } = require("./config.json");
require('dotenv').config();
const token = process.env.DISCORD_TOKEN;
const topGGToken = process.env.TOPGG_TOKEN;
if (!token) return console.log("No Discord token provided! Put one in your .env file");
const manager = new ShardingManager('./index.js',
{
token,
totalShards // null = auto, any numbers will manually spawn shards
}
);
console.info(!totalShards ? "Starting up..." : `Preparing ${totalShards} shards...`);
manager.on("disconnect", (event) => { console.warn(`Shard ${shard.id} disconnected!`); console.log(event) });
manager.on("death", (event) => { console.warn(`Shard ${shard.id} died!\nExit code: ${event.exitCode}`) });
manager.on("reconnecting", () => { console.info(`Shard ${shard.id} is reconnecting!`) });
if (topGGToken) {
const poster = AutoPoster(String(topGGToken), manager);
poster.on("posted", (stats) => {
console.info("Updated top.gg stats!");
})
poster.on("error", (error) => {
console.error("Failed updating top.gg stats:", error);
})
}
manager.spawn({ timeout: 60000 });