From 7a131e79360da3fc7985d27a5c7b515915420675 Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 1 May 2024 02:45:12 +0100 Subject: [PATCH] feat: internal sharding --- src/client.js | 1 + src/listeners/client/ready.js | 2 +- src/routes/status.js | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/client.js b/src/client.js index dadd73a..98f4f6d 100644 --- a/src/client.js +++ b/src/client.js @@ -34,6 +34,7 @@ module.exports = class Client extends FrameworkClient { Partials.Message, Partials.Reaction, ], + shards: 'auto', }, { baseDir: __dirname }, ); diff --git a/src/listeners/client/ready.js b/src/listeners/client/ready.js index 91c2abf..11aaec7 100644 --- a/src/listeners/client/ready.js +++ b/src/listeners/client/ready.js @@ -31,7 +31,7 @@ module.exports = class extends Listener { // process.title = `"[Discord Tickets] ${client.user.tag}"`; // too long and gets cut off 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 await sync(client); diff --git a/src/routes/status.js b/src/routes/status.js index e70dceb..f4ccb0a 100644 --- a/src/routes/status.js +++ b/src/routes/status.js @@ -1,6 +1,16 @@ module.exports.get = () => ({ handler: async (req, res) => { - const { status } = req.routeOptions.config.client.ws; - res.code(status === 0 ? 200 : 503).send(status); + const { client } = req.routeOptions.config; + 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, + }); }, });