From fe2ed0776f983ab79c6079c0a660d6091b57ba55 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 6 Aug 2025 21:46:02 -0300 Subject: [PATCH] ShowHiddenChannels: Fix showing allowed roles --- src/plugins/showHiddenChannels/index.tsx | 26 +++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index 78c81d00..b8075d8c 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -23,7 +23,6 @@ import { classNameFactory } from "@api/Styles"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { classes } from "@utils/misc"; -import { canonicalizeMatch } from "@utils/patches"; import definePlugin, { OptionType } from "@utils/types"; import type { Channel, Role } from "@vencord/discord-types"; import { findByPropsLazy } from "@webpack"; @@ -302,15 +301,18 @@ export default definePlugin({ }, { // Patch the header to only return allowed users and roles if it's a hidden channel or locked channel (Like when it's used on the HiddenChannelLockScreen) - match: /MANAGE_ROLES.{0,90}?return(?=\(.+?(\(0,\i\.jsxs\)\("div",{className:\i\.members.+?guildId:(\i)\.guild_id.+?roleColor.+?\]}\)))/, - replace: (m, component, channel) => { - // Export the channel for the users allowed component patch - component = component.replace(canonicalizeMatch(/(?<=users:\i)/), `,shcChannel:${channel}`); - // Always render the component for multiple allowed users - component = component.replace(canonicalizeMatch(/1!==\i\.length/), "true"); - - return `${m} $self.isHiddenChannel(${channel},true)?${component}:`; - } + match: /\.members.+?\]}\),(?<=channel:(\i).+?)/, + replace: (m, channel) => `${m}$self.isHiddenChannel(${channel},true)?null:` + }, + { + // Export the channel for the users allowed component patch + match: /maxUsers:\i,users:\i(?<=channel:(\i).+?)/, + replace: (m, channel) => `${m},shcChannel:${channel}` + }, + { + // Always render the component for multiple allowed users + match: /1!==\i\.length(?=\|\|)/, + replace: "true" } ] }, @@ -319,8 +321,8 @@ export default definePlugin({ replacement: [ { // Create a variable for the channel prop - match: /(function \i\(\i\)\{)([^}]+?hideOverflowCount)/, - replace: "$1let {shcChannel}=arguments[0];$2" + match: /let{users:\i,maxUsers:\i,/, + replace: "let{shcChannel}=arguments[0];$&" }, { // Make Discord always render the plus button if the component is used inside the HiddenChannelLockScreen