ShowHiddenChannels: Fix showing allowed roles

This commit is contained in:
Nuckyz 2025-08-06 21:46:02 -03:00
parent 74d78d89ed
commit fe2ed0776f
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -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