From 366da53247ad02e8ccbb87a10b7a42a1f85ea4f5 Mon Sep 17 00:00:00 2001 From: ryan-0324 <77452312+ryan-0324@users.noreply.github.com> Date: Sun, 30 Jun 2024 18:50:34 -0400 Subject: [PATCH] fix: regression where ShowHiddenChannels errors when `isHiddenChannel` is called with an object that is not a `ChannelRecord` --- src/plugins/showHiddenChannels/index.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index e3e3b75643..5259ce092f 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -25,7 +25,7 @@ import { canonicalizeMatch } from "@utils/patches"; import definePlugin, { OptionType, type Patch } from "@utils/types"; import type { ChannelRecord, GuildCategoryChannelRecord, GuildChannel, GuildChannelRecord, Role } from "@vencord/discord-types"; import { findByPropsLazy } from "@webpack"; -import { Permissions, PermissionStore, Tooltip } from "@webpack/common"; +import { ChannelStore, Permissions, PermissionStore, Tooltip } from "@webpack/common"; import HiddenChannelLockScreen from "./components/HiddenChannelLockScreen"; @@ -476,8 +476,13 @@ export default definePlugin({ } ], - isHiddenChannel(channel?: ChannelRecord, checkConnect = false) { - if (!channel || channel.isPrivate()) return false; + isHiddenChannel(channel?: ChannelRecord | { channelId: string; }, checkConnect = false) { + if (!channel) return false; + + if (!("isPrivate" in channel)) { + channel = ChannelStore.getChannel(channel.channelId); + if (!channel || !channel.isPrivate()) return false; + } return !PermissionStore.can(Permissions.VIEW_CHANNEL, channel) || checkConnect && !PermissionStore.can(Permissions.CONNECT, channel);