MemberCount: Fall back to approx member count if necessary

This commit is contained in:
Vendicated 2023-04-13 19:09:12 +02:00
parent ed827c2d81
commit 694a693a8e
No known key found for this signature in database
GPG Key ID: A1DC0CFB5615D905

View File

@ -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<string, [number, number]>;
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();