Plugin

MemberCount

Shows the number of online members, total members, and users in voice channels on the server — in the member list and tooltip.

Servers Utility
index.tsx
Download

Source

src/plugins/memberCount/index.tsx
1import "./style.css";
2
3import { definePluginSettings } from "@api/Settings";
4import ErrorBoundary from "@components/ErrorBoundary";
5import { Devs } from "@utils/constants";
6import { classNameFactory } from "@utils/css";
7import definePlugin, { OptionType } from "@utils/types";
8import { FluxStore } from "@vencord/discord-types";
9import { findStoreLazy } from "@webpack";
10
11import { MemberCount } from "./MemberCount";
12
13export const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & {
14 getProps(guildId?: string, channelId?: string): { groups: { count: number; id: string; }[]; };
15};
16export const ThreadMemberListStore = findStoreLazy("ThreadMemberListStore") as FluxStore & {
17 getMemberListSections(channelId?: string): { [sectionId: string]: { sectionId: string; userIds: string[]; }; };
18};
19
20export const settings = definePluginSettings({
21 toolTip: {
22 type: OptionType.BOOLEAN,
23 description: "Show member count on the server tooltip",
24 default: true,
25 restartNeeded: true
26 },
27 memberList: {
28 type: OptionType.BOOLEAN,
29 description: "Show member count in the member list",
30 default: true,
31 restartNeeded: true
32 },
33 voiceActivity: {
34 type: OptionType.BOOLEAN,
35 description: "Show voice activity with member count in the member list",
36 default: true
37 }
38});
39
40const sharedIntlNumberFormat = new Intl.NumberFormat();
41export const numberFormat = (value: number) => sharedIntlNumberFormat.format(value);
42export const cl = classNameFactory("vc-membercount-");
43
44export default definePlugin({
45 name: "MemberCount",
46 description: "Shows the number of online members, total members, and users in voice channels on the server — in the member list and tooltip.",
47 tags: ["Servers", "Utility"],
48 authors: [Devs.Ven, Devs.Commandtechno, Devs.Apexo],
49 settings,
50
51 patches: [
52 {
53 find: "{isSidebarVisible:",
54 replacement: [
55 {
56 match: /children:\[(\i\.useMemo[^}]+"aria-multiselectable")(?<=className:(\i),.+?)/,
57 replace: "children:[$2?.includes(&#039;members&#039;)?$self.render():null,$1",
58 },
59 ],
60 predicate: () => settings.store.memberList
61 },
62 {
63 find: "GuildTooltip - ",
64 replacement: {
65 match: /#{intl::VIEW_AS_ROLES_MENTIONS_WARNING}.{0,100}(?=])/,
66 replace: "$&,$self.renderTooltip(arguments[0].guild)"
67 },
68 predicate: () => settings.store.toolTip
69 }
70 ],
71 render: ErrorBoundary.wrap(() => <MemberCount />, { noop: true }),
72 renderTooltip: ErrorBoundary.wrap(guild => <MemberCount isTooltip tooltipGuildId={guild.id} />, { noop: true })
73});
74