-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
77 lines (64 loc) · 2.13 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
68
69
70
71
72
73
74
75
76
77
const { ShardingManager } = require('kurasuta');
const { Partials , GatewayIntentBits, Util, ActivityType } = require('discord.js');
const { Guilds, GuildMessages, GuildVoiceStates, GuildMessageReactions, MessageContent, GuildMembers, GuildWebhooks } = GatewayIntentBits;
const { token} = require('./config');
const Client = require('./structures/Client.js');
const clientOptions = {
allowedMentions: { parse: ["roles"], repliedUser: false },
restRequestTimeout: 30000,
partials: [ Partials.Message, Partials.Channel, Partials.Reaction, Partials.User ],
intents: [ Guilds, GuildVoiceStates, GuildMessages, GuildMessageReactions, MessageContent, GuildMembers, GuildWebhooks ],
presence: {
activities: [{ type: ActivityType.Listening, name: ".play Infinity" }],
status: "idle",
}
}
const sharder = new ShardingManager(__dirname + '/app.js', {
token: token,
client: Client,
respawn: true,
retry: true,
ipcSocket: 9999,
clusterCount: 6,
guildsPerShard: 1000,
timeout: 30000,
clientOptions
});
sharder.spawn();
sharder.on('message', message => {
if (message.type === 'shutdown') {
if (message.shard === 'all')
return sharder.clusters.forEach(shard => {
console.warn('[Lyka] [Shutdown] Destroying shard ' + shard.id);
shard.kill();
process.exit();
});
console.warn('[Lyka] [Shutdown] Destroying shard ' + message.shard);
return sharder.clusters.get(message.shard).kill();
}
if (message.type === 'reboot') {
if (message.shard === 'all') {
console.warn('[Lyka] [Shutdown] Rebooting all shards.');
sharder.clusters.forEach(s => s.kill());
return sharder.spawn();
}
console.warn('[Lyka] [Shutdown] Rebooting shard ' + message.shard);
try {
sharder.clusters.get(message.shard).respawn();
} catch {
sharder.restartAll();
}
}
});
sharder.on('debug', message => console.log('[Lyka] [Debug] ' + message));
sharder.on('ready', () =>
console.info('[Lyka] [Cluster] Kronix Cluster ready!')
);
process.on('SIGINT', signal => {
sharder.clusters.forEach(shard => {
console.warn('[Lyka] [Shutdown] Destroying shard ' + shard.id);
shard.kill();
});
process.exit();
});
module.exports = sharder;