From d4034cc167466865f0f709df479482415f28aa92 Mon Sep 17 00:00:00 2001 From: RyfterWasTaken <144800123+RyfterWasTaken@users.noreply.github.com> Date: Sat, 25 Jan 2025 01:30:43 +0100 Subject: [PATCH 1/9] Add files via upload --- src/plugins/viewMembersWithRole/README.md | 23 +++ .../componenents/ViewMembersModal.tsx | 181 ++++++++++++++++++ .../componenents/icons.tsx | 17 ++ src/plugins/viewMembersWithRole/index.tsx | 54 ++++++ src/plugins/viewMembersWithRole/styles.css | 93 +++++++++ src/plugins/viewMembersWithRole/utils.ts | 11 ++ 6 files changed, 379 insertions(+) create mode 100644 src/plugins/viewMembersWithRole/README.md create mode 100644 src/plugins/viewMembersWithRole/componenents/ViewMembersModal.tsx create mode 100644 src/plugins/viewMembersWithRole/componenents/icons.tsx create mode 100644 src/plugins/viewMembersWithRole/index.tsx create mode 100644 src/plugins/viewMembersWithRole/styles.css create mode 100644 src/plugins/viewMembersWithRole/utils.ts diff --git a/src/plugins/viewMembersWithRole/README.md b/src/plugins/viewMembersWithRole/README.md new file mode 100644 index 00000000000..9069a812f99 --- /dev/null +++ b/src/plugins/viewMembersWithRole/README.md @@ -0,0 +1,23 @@ +# viewMembersWithRole + +### Installation +Check [this](https://docs.vencord.dev/installing/custom-plugins/) to install + +### Usage +Open server context menu and select View members with role + +image + +Now select the role you want +![image](https://github.com/user-attachments/assets/4e800bb3-ab6c-4c5d-9017-e75824a9073b) + +### Limitations +It will only show the first hundred members per role, as well as the already cached members. + +### ToDo +Feel free to contribute if you want + - Better role overview + +![image](https://github.com/user-attachments/assets/bb647233-2829-47d4-8589-38cb381bbcfb) +- Limit width of role list +- Make members list more like role member view diff --git a/src/plugins/viewMembersWithRole/componenents/ViewMembersModal.tsx b/src/plugins/viewMembersWithRole/componenents/ViewMembersModal.tsx new file mode 100644 index 00000000000..e80cca70e97 --- /dev/null +++ b/src/plugins/viewMembersWithRole/componenents/ViewMembersModal.tsx @@ -0,0 +1,181 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; +import { findByCodeLazy } from "@webpack"; +import { Constants, GuildMemberStore, GuildStore, Parser, RestAPI, ScrollerThin, Text, useEffect, UserStore, useState } from "@webpack/common"; +import { UnicodeEmoji } from "@webpack/types"; +import type { Role } from "discord-types/general"; + +import { cl, GuildUtils } from "../utils"; + +type GetRoleIconData = (role: Role, size: number) => { customIconSrc?: string; unicodeEmoji?: UnicodeEmoji; }; +const getRoleIconData: GetRoleIconData = findByCodeLazy("convertSurrogateToName", "customIconSrc", "unicodeEmoji"); + + + +function getRoleIconSrc(role: Role) { + const icon = getRoleIconData(role, 20); + if (!icon) return; + + const { customIconSrc, unicodeEmoji } = icon; + return customIconSrc ?? unicodeEmoji?.url; +} + + +function MembersContainer({ guildId, roleId, props }: { guildId: string; roleId: string; props: ModalProps; }) { + // RMC: RoleMemberCounts + const [RMC, setRMC] = useState({}); + useEffect(() => { + let loading = true; + const interval = setInterval(async () => { + try { + await RestAPI.get({ + url: Constants.Endpoints.GUILD_ROLE_MEMBER_COUNTS(guildId) + }).then(x => { + if (x.ok) setRMC(x.body); clearInterval(interval); + }); + } catch (error) { console.error("Error fetching member counts", error); } + }, 1000); + return () => { loading = false; }; + }, []); + + let usersInRole = []; + const [rolesFetched, setRolesFetched] = useState(Array); + useEffect(() => { + if (!rolesFetched.includes(roleId)) { + const interval = setInterval(async () => { + try { + const response = await RestAPI.get({ + url: Constants.Endpoints.GUILD_ROLE_MEMBER_IDS(guildId, roleId), + }); + ({ body: usersInRole } = response); + await GuildUtils.requestMembersById(guildId, usersInRole, !1); + setRolesFetched([...rolesFetched, roleId]); + clearInterval(interval); + } catch (error) { console.error("Error fetching members:", error); } + }, 1200); + return () => clearInterval(interval); + } + }, [roleId]); // Fetch roles + + const [members, setMembers] = useState(GuildMemberStore.getMembers(guildId)); + useEffect(() => { + const interval = setInterval(async () => { + if (usersInRole) { + const guildMembers = GuildMemberStore.getMembers(guildId); + const storedIds = guildMembers.map(user => user.userId); + usersInRole.every(id => storedIds.includes(id)) && clearInterval(interval); + if (guildMembers !== members) { + setMembers(GuildMemberStore.getMembers(guildId)); + } + } + }, 500); + return () => clearInterval(interval); + }, [roleId, rolesFetched]); + + const roleMembers = members.filter(x => x.roles.includes(roleId)).map(x => UserStore.getUser(x.userId)); + + return ( + <> + + {roleMembers.length} loaded / {RMC[roleId] || 0} members with this role
{(roleMembers.length === RMC[roleId] || 0) ? "Loaded" : rolesFetched.includes(roleId) ? "Loaded" : "Loading..."} +
+
+ {roleMembers.map(x => { + + return ( +
+ + {Parser.parse(`<@${x.id}>`)} +
+ ); + })} + + ); +} + +function VMWRModal({ guildId, props }: { guildId: string; props: ModalProps; }) { + const roleObj = GuildStore.getRoles(guildId); + const roles = Object.keys(roleObj).map(key => roleObj[key]).sort((a, b) => b.position - a.position); + + const [selectedRole, selectRole] = useState(roles[0]); + + return ( + + + View members with role + + + +
+ + {roles.map((role, index) => { + + if (role.id === guildId) return; + + const roleIconSrc = role != null ? getRoleIconSrc(role) : undefined; + + return ( +
selectRole(roles[index])} + role="button" + tabIndex={0} + key={role.id} + > +
+ + { + roleIconSrc != null && ( + + ) + + } + + {role?.name || "Unknown role"} + +
+
+ ); + })} +
+
+ + + +
+ + + ); +} + +export function openVMWRModal(guildId) { + + openModal(props => + + ); +} + diff --git a/src/plugins/viewMembersWithRole/componenents/icons.tsx b/src/plugins/viewMembersWithRole/componenents/icons.tsx new file mode 100644 index 00000000000..26d432e218e --- /dev/null +++ b/src/plugins/viewMembersWithRole/componenents/icons.tsx @@ -0,0 +1,17 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +export function MemberIcon() { + return ( + + + + ); +} diff --git a/src/plugins/viewMembersWithRole/index.tsx b/src/plugins/viewMembersWithRole/index.tsx new file mode 100644 index 00000000000..2ae68cfea47 --- /dev/null +++ b/src/plugins/viewMembersWithRole/index.tsx @@ -0,0 +1,54 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import "./styles.css"; + +import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; +import definePlugin from "@utils/types"; +import { Menu } from "@webpack/common"; +import type { Guild } from "discord-types/general"; + +import { MemberIcon } from "./componenents/icons"; +import { openVMWRModal } from "./componenents/ViewMembersModal"; + +// VMWR: View Members With Role + +const makeContextMenuPatch: () => NavContextMenuPatchCallback = () => (children, { guild }: { guild: Guild, onClose(): void; }) => { + if (!guild) return; + + const group = findGroupChildrenByChildId("privacy", children); + group?.push( + openVMWRModal(guild.id)} + /> + ); +}; + +export default definePlugin({ + name: "ViewMembersWithRole", + description: "Shows all the members with the selected roles", + authors: [ + { + name: "Ryfter", + id: 898619112350183445n, + }, + ], + contextMenus: { + "guild-header-popout": makeContextMenuPatch() + }, + start() { }, + stop() { }, +}); + +/* + * getRolesWithMemberCount: https://discord.com/api/v9/guilds/GUILDID/roles/member-counts + * + * getMembersWithRole: https://discord.com/api/v9/guilds/GUILDID/roles/ROLEID/member-ids + */ + diff --git a/src/plugins/viewMembersWithRole/styles.css b/src/plugins/viewMembersWithRole/styles.css new file mode 100644 index 00000000000..be3e2bd0484 --- /dev/null +++ b/src/plugins/viewMembersWithRole/styles.css @@ -0,0 +1,93 @@ + + +.vc-vmwr-modal-content { + padding: 16px 4px 16px 16px; +} + +.vc-vmwr-modal-title { + flex-grow: 1; +} + +.vc-vmwr-modal-container { + width: 100%; + height: 100%; + display: flex; + gap: 8px; +} + +.vc-vmwr-modal-list { + display: flex; + flex-direction: column; + gap: 2px; + padding-right: 8px; + width: 200px; +} + +.vc-vmwr-modal-list-item-btn { + cursor: pointer; +} + +.vc-vmwr-modal-list-item { + display: flex; + align-items: center; + gap: 8px; + padding: 8px; + border-radius: 5px; +} + +.vc-vmwr-modal-list-item:hover { + background-color: var(--background-modifier-hover); +} + +.vc-vmwr-modal-list-item-active { + background-color: var(--background-modifier-selected); +} + +.vc-vmwr-modal-list-item > div { + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; +} + +.vc-vmwr-modal-role-circle { + border-radius: 50%; + width: 12px; + height: 12px; + flex-shrink: 0; +} + +.vc-vmwr-modal-role-image { + width: 20px; + height: 20px; + object-fit: contain; +} + +.vc-vmwr-role-button { + border-radius: var(--radius-xs); + background: var(--bg-mod-faint); + color: var(--interactive-normal); + border: 1px solid var(--border-faint); + /* stylelint-disable-next-line value-no-vendor-prefix */ + width: -moz-fit-content; + width: fit-content; + height: 24px; + padding: 4px +} + +.custom-profile-theme .vc-vmwr-role-button { + background: rgb(var(--bg-overlay-color)/var(--bg-overlay-opacity-6)); + border-color: var(--profile-body-border-color) +} + +.vc-vmwr-user-div{ + display: flex; + align-items: center; + gap: 0.2em; +} + +.vc-vmwr-user-avatar { + border-radius: 50%; + padding: 5px; + width: 30px; + height: 30px; +} diff --git a/src/plugins/viewMembersWithRole/utils.ts b/src/plugins/viewMembersWithRole/utils.ts new file mode 100644 index 00000000000..1fbaea65332 --- /dev/null +++ b/src/plugins/viewMembersWithRole/utils.ts @@ -0,0 +1,11 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { classNameFactory } from "@api/Styles"; +import { findByPropsLazy } from "@webpack"; + +export const cl = classNameFactory("vc-vmwr-"); +export const GuildUtils = findByPropsLazy("requestMembersById"); From 00cef007bcd97d0b3863bd9650f79f9ef1705615 Mon Sep 17 00:00:00 2001 From: RyfterWasTaken <144800123+RyfterWasTaken@users.noreply.github.com> Date: Sat, 25 Jan 2025 01:42:39 +0100 Subject: [PATCH 2/9] Update index.tsx --- src/plugins/viewMembersWithRole/index.tsx | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/plugins/viewMembersWithRole/index.tsx b/src/plugins/viewMembersWithRole/index.tsx index 2ae68cfea47..8042983bc82 100644 --- a/src/plugins/viewMembersWithRole/index.tsx +++ b/src/plugins/viewMembersWithRole/index.tsx @@ -7,6 +7,7 @@ import "./styles.css"; import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; +import { Dev } from "@utils/constants"; import definePlugin from "@utils/types"; import { Menu } from "@webpack/common"; import type { Guild } from "discord-types/general"; @@ -15,7 +16,6 @@ import { MemberIcon } from "./componenents/icons"; import { openVMWRModal } from "./componenents/ViewMembersModal"; // VMWR: View Members With Role - const makeContextMenuPatch: () => NavContextMenuPatchCallback = () => (children, { guild }: { guild: Guild, onClose(): void; }) => { if (!guild) return; @@ -34,10 +34,7 @@ export default definePlugin({ name: "ViewMembersWithRole", description: "Shows all the members with the selected roles", authors: [ - { - name: "Ryfter", - id: 898619112350183445n, - }, + Dev.Ryfter ], contextMenus: { "guild-header-popout": makeContextMenuPatch() @@ -45,10 +42,3 @@ export default definePlugin({ start() { }, stop() { }, }); - -/* - * getRolesWithMemberCount: https://discord.com/api/v9/guilds/GUILDID/roles/member-counts - * - * getMembersWithRole: https://discord.com/api/v9/guilds/GUILDID/roles/ROLEID/member-ids - */ - From 76a78509e85703f2366a7cd561ee18b14c2bac0e Mon Sep 17 00:00:00 2001 From: RyfterWasTaken <144800123+RyfterWasTaken@users.noreply.github.com> Date: Sat, 25 Jan 2025 01:44:28 +0100 Subject: [PATCH 3/9] Update constants.ts --- src/utils/constants.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/constants.ts b/src/utils/constants.ts index e7582591257..75affe397d6 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -575,6 +575,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "SomeAspy", id: 516750892372852754n, }, + Ryfter: { + name: "Ryfter", + id: 898619112350183445n, + }, jamesbt365: { name: "jamesbt365", id: 158567567487795200n, From df232183571ee2ab26c97c7ef5ff8f400638f461 Mon Sep 17 00:00:00 2001 From: RyfterWasTaken <144800123+RyfterWasTaken@users.noreply.github.com> Date: Sat, 25 Jan 2025 02:36:42 +0100 Subject: [PATCH 4/9] Update index.tsx imported Dev instead of Devs --- src/plugins/viewMembersWithRole/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/viewMembersWithRole/index.tsx b/src/plugins/viewMembersWithRole/index.tsx index 8042983bc82..72ac0ad0444 100644 --- a/src/plugins/viewMembersWithRole/index.tsx +++ b/src/plugins/viewMembersWithRole/index.tsx @@ -7,7 +7,7 @@ import "./styles.css"; import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; -import { Dev } from "@utils/constants"; +import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { Menu } from "@webpack/common"; import type { Guild } from "discord-types/general"; @@ -34,7 +34,7 @@ export default definePlugin({ name: "ViewMembersWithRole", description: "Shows all the members with the selected roles", authors: [ - Dev.Ryfter + Devs.Ryfter ], contextMenus: { "guild-header-popout": makeContextMenuPatch() From e39b57f4b36f4085b61c5c05347ae1ee8b201301 Mon Sep 17 00:00:00 2001 From: RyfterWasTaken <144800123+RyfterWasTaken@users.noreply.github.com> Date: Sat, 25 Jan 2025 14:26:54 +0100 Subject: [PATCH 5/9] Update ViewMembersModal.tsx Better UI --- .../componenents/ViewMembersModal.tsx | 90 ++++++++++++------- 1 file changed, 60 insertions(+), 30 deletions(-) diff --git a/src/plugins/viewMembersWithRole/componenents/ViewMembersModal.tsx b/src/plugins/viewMembersWithRole/componenents/ViewMembersModal.tsx index e80cca70e97..fc722320d15 100644 --- a/src/plugins/viewMembersWithRole/componenents/ViewMembersModal.tsx +++ b/src/plugins/viewMembersWithRole/componenents/ViewMembersModal.tsx @@ -4,15 +4,17 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +import { InfoIcon } from "@components/Icons"; import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; -import { findByCodeLazy } from "@webpack"; -import { Constants, GuildMemberStore, GuildStore, Parser, RestAPI, ScrollerThin, Text, useEffect, UserStore, useState } from "@webpack/common"; +import { findByCodeLazy, findExportedComponentLazy } from "@webpack"; +import { Constants, GuildMemberStore, GuildStore, Parser, RestAPI, ScrollerThin, Text, Tooltip, useEffect, UserStore, useState } from "@webpack/common"; import { UnicodeEmoji } from "@webpack/types"; import type { Role } from "discord-types/general"; import { cl, GuildUtils } from "../utils"; type GetRoleIconData = (role: Role, size: number) => { customIconSrc?: string; unicodeEmoji?: UnicodeEmoji; }; +const ThreeDots = findExportedComponentLazy("Dots", "AnimatedDots"); const getRoleIconData: GetRoleIconData = findByCodeLazy("convertSurrogateToName", "customIconSrc", "unicodeEmoji"); @@ -25,7 +27,6 @@ function getRoleIconSrc(role: Role) { return customIconSrc ?? unicodeEmoji?.url; } - function MembersContainer({ guildId, roleId, props }: { guildId: string; roleId: string; props: ModalProps; }) { // RMC: RoleMemberCounts const [RMC, setRMC] = useState({}); @@ -80,25 +81,56 @@ function MembersContainer({ guildId, roleId, props }: { guildId: string; roleId: const roleMembers = members.filter(x => x.roles.includes(roleId)).map(x => UserStore.getUser(x.userId)); return ( - <> - - {roleMembers.length} loaded / {RMC[roleId] || 0} members with this role
{(roleMembers.length === RMC[roleId] || 0) ? "Loaded" : rolesFetched.includes(roleId) ? "Loaded" : "Loading..."} -
-
- {roleMembers.map(x => { - - return ( -
- - {Parser.parse(`<@${x.id}>`)} -
- ); - })} - +
+
+
+ + {roleMembers.length} loaded / {RMC[roleId] || 0} members with this role
+
+ + {props => } + +
+ +
+ + {roleMembers.map(x => { + return ( +
+ + {Parser.parse(`<@${x.id}>`)} +
+ ); + })} + { + (Object.keys(RMC).length === 0) ? ( +
+ +
+ ) : !RMC[roleId] ? ( + No member found with this role + ) : RMC[roleId] === roleMembers.length ? ( + <> +
+ All members loaded + + ) : rolesFetched.includes(roleId) ? ( + <> +
+ All cached members loaded + + ) : ( +
+ +
+ ) + } + +
); } @@ -156,16 +188,14 @@ function VMWRModal({ guildId, props }: { guildId: string; props: ModalProps; }) })}
- - - +
- + ); } From 4f1de2ef3c8529b9969861de65d8ffbea235ee4a Mon Sep 17 00:00:00 2001 From: RyfterWasTaken <144800123+RyfterWasTaken@users.noreply.github.com> Date: Sat, 25 Jan 2025 14:28:52 +0100 Subject: [PATCH 6/9] Update styles.css Better UI --- src/plugins/viewMembersWithRole/styles.css | 52 ++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/src/plugins/viewMembersWithRole/styles.css b/src/plugins/viewMembersWithRole/styles.css index be3e2bd0484..c02bb90f025 100644 --- a/src/plugins/viewMembersWithRole/styles.css +++ b/src/plugins/viewMembersWithRole/styles.css @@ -1,5 +1,3 @@ - - .vc-vmwr-modal-content { padding: 16px 4px 16px 16px; } @@ -20,7 +18,8 @@ flex-direction: column; gap: 2px; padding-right: 8px; - width: 200px; + max-width: 300px; + min-width: 300px; } .vc-vmwr-modal-list-item-btn { @@ -62,6 +61,11 @@ object-fit: contain; } +.vc-vmwr-modal-divider { + width: 2px; + background-color: var(--background-modifier-active); +} + .vc-vmwr-role-button { border-radius: var(--radius-xs); background: var(--bg-mod-faint); @@ -85,9 +89,51 @@ gap: 0.2em; } +.vc-vmwr-modal-members { + display: flex; + flex-direction: column; + width: 100%; +} + + .vc-vmwr-user-avatar { border-radius: 50%; padding: 5px; width: 30px; height: 30px; } + +.vc-vmwr-member-list-header { + background-color: var(--background-secondary); + padding: 5px; + border-radius: 5px; +} + +.vc-vmwr-member-list-header-text { + display: flex; + align-items: center; + gap: 5px; +} + +.vc-vmwr-member-list-header-text .vc-info-icon { + color: var(--interactive-muted); + margin-left: auto; + cursor: pointer; + transition: color ease-in 0.1s; +} + +.vc-vmwr-member-list-header-text .vc-info-icon:hover { + color: var(--interactive-active); +} + +.vc-vmwr-member-list-footer { + padding: 5px; + text-align: center; + font-style: italic; +} + +.vc-vmwr-divider { + height: 2px; + width: 100%; + background-color: var(--background-modifier-active); +} From 9239cf5977b24a1c5e78d9ee93450cb58df243e7 Mon Sep 17 00:00:00 2001 From: RyfterWasTaken <144800123+RyfterWasTaken@users.noreply.github.com> Date: Sat, 25 Jan 2025 14:31:17 +0100 Subject: [PATCH 7/9] Update README.md Modified image to reflect UI change --- src/plugins/viewMembersWithRole/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/viewMembersWithRole/README.md b/src/plugins/viewMembersWithRole/README.md index 9069a812f99..31f1d54585d 100644 --- a/src/plugins/viewMembersWithRole/README.md +++ b/src/plugins/viewMembersWithRole/README.md @@ -9,7 +9,8 @@ Open server context menu and select View members with role image Now select the role you want -![image](https://github.com/user-attachments/assets/4e800bb3-ab6c-4c5d-9017-e75824a9073b) +![image](https://github.com/user-attachments/assets/d74aec13-cdcf-4170-9c40-0d12853bf600) + ### Limitations It will only show the first hundred members per role, as well as the already cached members. From 0925b7e583eaad016b705450528a55eb38ba6d8b Mon Sep 17 00:00:00 2001 From: RyfterWasTaken <144800123+RyfterWasTaken@users.noreply.github.com> Date: Sat, 25 Jan 2025 14:32:44 +0100 Subject: [PATCH 8/9] Update README.md --- src/plugins/viewMembersWithRole/README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/plugins/viewMembersWithRole/README.md b/src/plugins/viewMembersWithRole/README.md index 31f1d54585d..def2f0e5e89 100644 --- a/src/plugins/viewMembersWithRole/README.md +++ b/src/plugins/viewMembersWithRole/README.md @@ -15,10 +15,3 @@ Now select the role you want ### Limitations It will only show the first hundred members per role, as well as the already cached members. -### ToDo -Feel free to contribute if you want - - Better role overview - -![image](https://github.com/user-attachments/assets/bb647233-2829-47d4-8589-38cb381bbcfb) -- Limit width of role list -- Make members list more like role member view From 990d6ce43213508f34a978b7e1539341c5ec5e15 Mon Sep 17 00:00:00 2001 From: RyfterWasTaken <144800123+RyfterWasTaken@users.noreply.github.com> Date: Sat, 25 Jan 2025 14:59:16 +0100 Subject: [PATCH 9/9] Update ViewMembersModal.tsx Shows server profile instead of user profile --- .../componenents/ViewMembersModal.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/viewMembersWithRole/componenents/ViewMembersModal.tsx b/src/plugins/viewMembersWithRole/componenents/ViewMembersModal.tsx index fc722320d15..fb0dc0b2243 100644 --- a/src/plugins/viewMembersWithRole/componenents/ViewMembersModal.tsx +++ b/src/plugins/viewMembersWithRole/componenents/ViewMembersModal.tsx @@ -7,7 +7,7 @@ import { InfoIcon } from "@components/Icons"; import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; import { findByCodeLazy, findExportedComponentLazy } from "@webpack"; -import { Constants, GuildMemberStore, GuildStore, Parser, RestAPI, ScrollerThin, Text, Tooltip, useEffect, UserStore, useState } from "@webpack/common"; +import { Constants, GuildChannelStore, GuildMemberStore, GuildStore, Parser, RestAPI, ScrollerThin, Text, Tooltip, useEffect, UserStore, useState } from "@webpack/common"; import { UnicodeEmoji } from "@webpack/types"; import type { Role } from "discord-types/general"; @@ -27,7 +27,10 @@ function getRoleIconSrc(role: Role) { return customIconSrc ?? unicodeEmoji?.url; } -function MembersContainer({ guildId, roleId, props }: { guildId: string; roleId: string; props: ModalProps; }) { +function MembersContainer({ guildId, roleId }: { guildId: string; roleId: string; }) { + + const channelId = GuildChannelStore.getChannels(guildId).SELECTABLE[0].channel.id; + // RMC: RoleMemberCounts const [RMC, setRMC] = useState({}); useEffect(() => { @@ -102,7 +105,7 @@ function MembersContainer({ guildId, roleId, props }: { guildId: string; roleId: src={x.getAvatarURL()} alt="" /> - {Parser.parse(`<@${x.id}>`)} + {Parser.parse(`<@${x.id}>`, true, { channelId, viewingChannelId: channelId })}
); })} @@ -189,7 +192,6 @@ function VMWRModal({ guildId, props }: { guildId: string; props: ModalProps; })