2022-11-28 19:29:46 +01:00
|
|
|
/*
|
|
|
|
* Vencord, a modification for Discord's desktop app
|
|
|
|
* Copyright (c) 2022 Vendicated and contributors
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2024-02-28 20:02:37 +01:00
|
|
|
import "./style.css";
|
|
|
|
|
|
|
|
import { classNameFactory } from "@api/Styles";
|
2022-11-28 19:29:46 +01:00
|
|
|
import ErrorBoundary from "@components/ErrorBoundary";
|
|
|
|
import { Devs } from "@utils/constants";
|
|
|
|
import definePlugin from "@utils/types";
|
2023-04-13 19:09:12 +02:00
|
|
|
import { findStoreLazy } from "@webpack";
|
2023-05-05 18:08:12 +02:00
|
|
|
import { FluxStore } from "@webpack/types";
|
2022-11-28 19:29:46 +01:00
|
|
|
|
2024-02-28 20:02:37 +01:00
|
|
|
import { MemberCount } from "./MemberCount";
|
|
|
|
|
|
|
|
export const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore") as FluxStore & { getMemberCount(guildId: string): number | null; };
|
|
|
|
export const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & {
|
2023-05-05 18:08:12 +02:00
|
|
|
getProps(guildId: string, channelId: string): { groups: { count: number; id: string; }[]; };
|
|
|
|
};
|
2023-04-13 19:09:12 +02:00
|
|
|
|
2023-09-06 01:46:33 +08:00
|
|
|
const sharedIntlNumberFormat = new Intl.NumberFormat();
|
2024-02-28 20:02:37 +01:00
|
|
|
export const numberFormat = (value: number) => sharedIntlNumberFormat.format(value);
|
|
|
|
export const cl = classNameFactory("vc-membercount-");
|
2022-11-28 19:29:46 +01:00
|
|
|
|
|
|
|
export default definePlugin({
|
|
|
|
name: "MemberCount",
|
2024-02-28 20:02:37 +01:00
|
|
|
description: "Shows the amount of online & total members in the server member list and tooltip",
|
2022-12-03 16:42:18 -06:00
|
|
|
authors: [Devs.Ven, Devs.Commandtechno],
|
2022-11-28 19:29:46 +01:00
|
|
|
|
2024-02-28 20:02:37 +01:00
|
|
|
patches: [
|
|
|
|
{
|
|
|
|
find: "{isSidebarVisible:",
|
|
|
|
replacement: {
|
|
|
|
match: /(?<=let\{className:(\i),.+?children):\[(\i\.useMemo[^}]+"aria-multiselectable")/,
|
|
|
|
replace: ":[$1?.startsWith('members')?$self.render():null,$2"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
find: ".invitesDisabledTooltip",
|
|
|
|
replacement: {
|
|
|
|
match: /(?<=\.VIEW_AS_ROLES_MENTIONS_WARNING.{0,100})]/,
|
|
|
|
replace: ",$self.renderTooltip(arguments[0].guild)]"
|
|
|
|
}
|
2022-11-28 19:29:46 +01:00
|
|
|
}
|
2024-02-28 20:02:37 +01:00
|
|
|
],
|
2022-11-28 19:29:46 +01:00
|
|
|
|
2024-02-28 20:02:37 +01:00
|
|
|
render: ErrorBoundary.wrap(MemberCount, { noop: true }),
|
|
|
|
renderTooltip: ErrorBoundary.wrap(guild => <MemberCount isTooltip tooltipGuildId={guild.id} />, { noop: true })
|
2022-11-28 19:29:46 +01:00
|
|
|
});
|