Skip to content

Commit

Permalink
feat: internal sharding
Browse files Browse the repository at this point in the history
  • Loading branch information
eartharoid committed May 1, 2024
1 parent dbd45da commit 7a131e7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/client.js
Expand Up @@ -34,6 +34,7 @@ module.exports = class Client extends FrameworkClient {
Partials.Message,
Partials.Reaction,
],
shards: 'auto',
},
{ baseDir: __dirname },
);
Expand Down
2 changes: 1 addition & 1 deletion src/listeners/client/ready.js
Expand Up @@ -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);
Expand Down
14 changes: 12 additions & 2 deletions 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,
});
},
});

0 comments on commit 7a131e7

Please sign in to comment.