forked from GDColon/Polaris-Open
-
Notifications
You must be signed in to change notification settings - Fork 0
/
polaris.js
26 lines (22 loc) · 1.04 KB
/
polaris.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
const Discord = require("discord.js")
require('dotenv').config();
const token = process.env.DISCORD_TOKEN
if (!token) return console.log("No Discord token provided! Put one in your .env file")
const Shard = new Discord.ShardingManager('./index.js', { token } );
const guildsPerShard = 2000
Discord.fetchRecommendedShardCount(token, {guildsPerShard}).then(shards => {
let shardCount = Math.floor(shards)
console.info(shardCount == 1 ? "Starting up..." : `Preparing ${shardCount} shards...`)
Shard.spawn({amount: shardCount, timeout: 60000}).catch(console.error)
Shard.on('shardCreate', shard => {
shard.on("disconnect", (event) => {
console.warn(`Shard ${shard.id} disconnected!`); console.log(event);
});
shard.on("death", (event) => {
console.warn(`Shard ${shard.id} died!\nExit code: ${event.exitCode}`);
});
shard.on("reconnecting", () => {
console.info(`Shard ${shard.id} is reconnecting!`);
});
})
}).catch(e => {console.log(e.headers || e)})