From 694a693a8ec5a7a5ef6ca91ebc142e07f0fb6b61 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 13 Apr 2023 19:09:12 +0200 Subject: [PATCH] MemberCount: Fall back to approx member count if necessary --- src/plugins/memberCount.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/memberCount.tsx b/src/plugins/memberCount.tsx index 37626141a..3a68126dc 100644 --- a/src/plugins/memberCount.tsx +++ b/src/plugins/memberCount.tsx @@ -22,11 +22,14 @@ import { Devs } from "@utils/constants"; import { getCurrentChannel } from "@utils/discord"; import { useForceUpdater } from "@utils/misc"; import definePlugin from "@utils/types"; +import { findStoreLazy } from "@webpack"; import { FluxDispatcher, Tooltip } from "@webpack/common"; const counts = {} as Record; let forceUpdate: () => void; +const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore"); + function MemberCount() { const guildId = getCurrentChannel().guild_id; const c = counts[guildId]; @@ -37,7 +40,8 @@ function MemberCount() { let total = c[0].toLocaleString(); if (total === "0" && c[1] > 0) { - total = "Loading..."; + const approx = GuildMemberCountStore.getMemberCount(guildId); + total = approx ? approx.toLocaleString() : "Loading..."; } const online = c[1].toLocaleString();