feat: internal sharding

This commit is contained in:
Isaac 2024-05-01 02:45:12 +01:00
parent dbd45da7ad
commit 7a131e7936
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
3 changed files with 14 additions and 3 deletions

View File

@ -34,6 +34,7 @@ module.exports = class Client extends FrameworkClient {
Partials.Message, Partials.Message,
Partials.Reaction, Partials.Reaction,
], ],
shards: 'auto',
}, },
{ baseDir: __dirname }, { baseDir: __dirname },
); );

View File

@ -31,7 +31,7 @@ module.exports = class extends Listener {
// process.title = `"[Discord Tickets] ${client.user.tag}"`; // too long and gets cut off // process.title = `"[Discord Tickets] ${client.user.tag}"`; // too long and gets cut off
process.title = 'tickets'; process.title = 'tickets';
client.log.success('Connected to Discord as "%s"', client.user.tag); client.log.success('Connected to Discord as "%s" over %d shards', client.user.tag, client.ws.shards.size);
// fill cache // fill cache
await sync(client); await sync(client);

View File

@ -1,6 +1,16 @@
module.exports.get = () => ({ module.exports.get = () => ({
handler: async (req, res) => { handler: async (req, res) => {
const { status } = req.routeOptions.config.client.ws; const { client } = req.routeOptions.config;
res.code(status === 0 ? 200 : 503).send(status); res
.code(client.ws.status === 0 ? 200 : 503)
.send({
ping: client.ws.ping,
shards: client.ws.shards.map(shard => ({
id: shard.id,
ping: shard.ping,
status: shard.status,
})),
status: client.ws.status,
});
}, },
}); });