Skip to content

Commit

Permalink
finished switch to hybrid sharding
Browse files Browse the repository at this point in the history
  • Loading branch information
NullDev committed Apr 30, 2024
1 parent e9bf616 commit 01d274d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/commands/user/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ export default {
let owner = "N/A";
if (guildOwner) owner = (await interaction.client.users.fetch(guildOwner)).tag;

const promises = [
interaction.client.shard?.fetchClientValues("guilds.cache.size"),
interaction.client.shard?.broadcastEval(c => c.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)),
const promises = [ // @ts-ignore
interaction.client.cluster?.fetchClientValues("guilds.cache.size"), // @ts-ignore
interaction.client.cluster?.broadcastEval(c => c.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)),
];
const shardCount = interaction.client.shard?.count || 0;

// @ts-ignore
const shardCount = interaction.client.cluster.info.TOTAL_SHARDS || 1;
const isBotVerified = interaction.client.user?.flags?.has("VerifiedBot") || false;

const [guilds, members] = await Promise.all(promises);
Expand Down
3 changes: 2 additions & 1 deletion src/service/dblHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class DblHandler {
async postBotStats(guildCount){
if (!this.isProd || this.dblToken === "") return;

const members = await this.client.shard?.broadcastEval(c => c.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0));
// @ts-ignore
const members = await this.client.cluster?.broadcastEval(c => c.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0));
const userCount = members?.reduce((acc, memberCount) => Number(acc) + Number(memberCount), 0);

fetch(`https://discordbotlist.com/api/v1/bots/${this.id}/stats`, {
Expand Down

0 comments on commit 01d274d

Please sign in to comment.