Files
discord-decomp/stores/GuildMemberCountStore.tsx
T
2026-11-01 12:12:55 +02:00

73 lines
2.1 KiB
TypeScript

// Metro module 4110 (f4111).
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c2368_0, c2368_1;
const handleInviteData = function handleInviteData({ invite }) {
const { guild, approximate_presence_count } = invite;
if (guild?.id != null && approximate_presence_count != null) {
c2368_1[guild.id] = approximate_presence_count;
return void 0;
}
return false;
};
c2368_0 = {};
c2368_1 = {};
class GuildMemberCountStore extends Module589.Store {
static displayName = "GuildMemberCountStore";
getMemberCounts() {
return c2368_0;
}
getMemberCount(a0) {
return a0 != null ? c2368_0[a0] : null;
}
getOnlineCount(a0) {
return a0 != null ? c2368_1[a0] : null;
}
}
const guildMemberCountStore = new GuildMemberCountStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen({ guilds }) {
c2368_0 = {};
guilds.forEach((guild) => {
c2368_0[guild.id] = guild.member_count;
});
},
OVERLAY_INITIALIZE: function handleOverlayInitialize(a0) {
c2368_0 = {
...a0.guildMemberCounts
};
},
GUILD_CREATE: function handleGuildCreate({ guild }) {
c2368_0[guild.id] = guild.member_count;
},
GUILD_DELETE: function handleGuildDelete({ guild }) {
if (c2368_0[guild.id] == null && c2368_1[guild.id] == null) {
return false;
}
delete c2368_0[guild.id];
delete c2368_1[guild.id];
},
GUILD_MEMBER_LIST_UPDATE: function handleGuildMemberListUpdate({ guildId, memberCount, onlineCount }) {
const r8 = c2368_0[guildId];
let r0 = false;
if (r8 !== memberCount) {
c2368_0[guildId] = memberCount;
r0 = true;
}
if (c2368_1[guildId] !== onlineCount) {
c2368_1[guildId] = onlineCount;
r0 = true;
}
return r0;
},
INVITE_ACCEPT_SUCCESS: handleInviteData,
INVITE_RESOLVE_SUCCESS: handleInviteData,
ONLINE_GUILD_MEMBER_COUNT_UPDATE: function handleOnlineCountUpdate({ guildId, count }) {
if (guildId != null && count != null) {
c2368_1[guildId] = count;
return void 0;
}
return false;
}
});
export default guildMemberCountStore;