Plugin
MemberCount
Shows the number of online members, total members, and users in voice channels on the server — in the member list and tooltip.
1
import "./style.css";2
3
import { definePluginSettings } from "@api/Settings";4
import ErrorBoundary from "@components/ErrorBoundary";5
import { Devs } from "@utils/constants";6
import { classNameFactory } from "@utils/css";7
import definePlugin, { OptionType } from "@utils/types";8
import { FluxStore } from "@vencord/discord-types";9
import { findStoreLazy } from "@webpack";10
11
import { MemberCount } from "./MemberCount";12
13
export const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & {14
getProps(guildId?: string, channelId?: string): { groups: { count: number; id: string; }[]; };15
};16
export const ThreadMemberListStore = findStoreLazy("ThreadMemberListStore") as FluxStore & {17
getMemberListSections(channelId?: string): { [sectionId: string]: { sectionId: string; userIds: string[]; }; };18
};19
20
export const settings = definePluginSettings({21
toolTip: {22
type: OptionType.BOOLEAN,23
description: "Show member count on the server tooltip",24
default: true,25
restartNeeded: true26
},27
memberList: {28
type: OptionType.BOOLEAN,29
description: "Show member count in the member list",30
default: true,31
restartNeeded: true32
},33
voiceActivity: {34
type: OptionType.BOOLEAN,35
description: "Show voice activity with member count in the member list",36
default: true37
}38
});39
40
const sharedIntlNumberFormat = new Intl.NumberFormat();41
export const numberFormat = (value: number) => sharedIntlNumberFormat.format(value);42
export const cl = classNameFactory("vc-membercount-");43
44
export 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;members039;)?$self.render():null,$1",58
},59
],60
predicate: () => settings.store.memberList61
},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.toolTip69
}70
],71
render: ErrorBoundary.wrap(() => <MemberCount />, { noop: true }),72
renderTooltip: ErrorBoundary.wrap(guild => <MemberCount isTooltip tooltipGuildId={guild.id} />, { noop: true })73
});74