aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/memberCount.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/memberCount.tsx')
-rw-r--r--src/plugins/memberCount.tsx36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/plugins/memberCount.tsx b/src/plugins/memberCount.tsx
index 3a68126..0b5409c 100644
--- a/src/plugins/memberCount.tsx
+++ b/src/plugins/memberCount.tsx
@@ -23,7 +23,7 @@ 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";
+import { Tooltip } from "@webpack/common";
const counts = {} as Record<string, [number, number]>;
let forceUpdate: () => void;
@@ -107,27 +107,21 @@ export default definePlugin({
}
}],
- onGuildMemberListUpdate({ guildId, groups, memberCount, id }) {
- // eeeeeh - sometimes it has really wrong counts??? like 10 times less than actual
- // but if we only listen to everyone updates, sometimes we never get the count?
- // this seems to work but isn't optional
- if (id !== "everyone" && counts[guildId]) return;
-
- let count = 0;
- for (const group of groups) {
- if (group.id !== "offline")
- count += group.count;
+ flux: {
+ GUILD_MEMBER_LIST_UPDATE({ guildId, groups, memberCount, id }) {
+ // eeeeeh - sometimes it has really wrong counts??? like 10 times less than actual
+ // but if we only listen to everyone updates, sometimes we never get the count?
+ // this seems to work but isn't optional
+ if (id !== "everyone" && counts[guildId]) return;
+
+ let count = 0;
+ for (const group of groups) {
+ if (group.id !== "offline")
+ count += group.count;
+ }
+ counts[guildId] = [memberCount, count];
+ forceUpdate?.();
}
- counts[guildId] = [memberCount, count];
- forceUpdate?.();
- },
-
- start() {
- FluxDispatcher.subscribe("GUILD_MEMBER_LIST_UPDATE", this.onGuildMemberListUpdate);
- },
-
- stop() {
- FluxDispatcher.unsubscribe("GUILD_MEMBER_LIST_UPDATE", this.onGuildMemberListUpdate);
},
render: () => (