forked from Astrydax/SWEotE-Discord-Dice-Roller
-
Notifications
You must be signed in to change notification settings - Fork 42
/
start.js
30 lines (24 loc) · 1.17 KB
/
start.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
const path = require('path');
const { token } = require('./config');
const { version } = require('./package');
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager(path.join(__dirname, '/index.js'), { token });
console.info(new Date().toString());
manager.spawn().catch(console.error);
manager.on('shardCreate', (shard) => {
shard.on('death', (process) => {
console.error('Shard ' + shard.id + ' closed unexpectedly! PID: ' + process.pid + '; Exit code: ' + process.exitCode + '.');
if (process.exitCode === null) {
console.warn(
'WARNING: Shard ' + shard.id + ' exited with NULL error code. This may be a result of a lack of available system memory. Ensure that there is enough memory allocated to continue.');
}
});
shard.on('disconnect', (event) => {
console.warn('Shard ' + shard.id + ' disconnected. Dumping socket close event...');
console.log(event);
});
shard.on('ready', async () => {
const name = await shard.fetchClientValue('user.username');
console.info(`${name}. Shard ${shard.id}/${manager.totalShards - 1}. Version ${version}`);
});
});