From d62be1b94ac8a49131bc5adb8c9bcd876ff2706f Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 27 Mar 2025 01:25:57 +0100 Subject: [PATCH] SupportHelper: Enable in more channels --- src/plugins/_core/supportHelper.tsx | 22 ++++++++++++---------- src/plugins/webContextMenus.web/index.ts | 21 ++++++++++++--------- src/utils/constants.ts | 1 + 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/plugins/_core/supportHelper.tsx b/src/plugins/_core/supportHelper.tsx index 03639aea7..825bbc206 100644 --- a/src/plugins/_core/supportHelper.tsx +++ b/src/plugins/_core/supportHelper.tsx @@ -22,7 +22,7 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { Link } from "@components/Link"; import { openUpdaterModal } from "@components/VencordSettings/UpdaterTab"; -import { CONTRIB_ROLE_ID, Devs, DONOR_ROLE_ID, KNOWN_ISSUES_CHANNEL_ID, REGULAR_ROLE_ID, SUPPORT_CHANNEL_ID, VENBOT_USER_ID, VENCORD_GUILD_ID } from "@utils/constants"; +import { CONTRIB_ROLE_ID, Devs, DONOR_ROLE_ID, KNOWN_ISSUES_CHANNEL_ID, REGULAR_ROLE_ID, SUPPORT_CATEGORY_ID, SUPPORT_CHANNEL_ID, VENBOT_USER_ID, VENCORD_GUILD_ID } from "@utils/constants"; import { sendMessage } from "@utils/discord"; import { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; @@ -32,7 +32,8 @@ import { onlyOnce } from "@utils/onlyOnce"; import { makeCodeblock } from "@utils/text"; import definePlugin from "@utils/types"; import { checkForUpdates, isOutdated, update } from "@utils/updater"; -import { Alerts, Button, Card, ChannelStore, Forms, GuildMemberStore, Parser, RelationshipStore, showToast, Text, Toasts, UserStore } from "@webpack/common"; +import { Alerts, Button, Card, ChannelStore, Forms, GuildMemberStore, Parser, PermissionsBits, PermissionStore, RelationshipStore, showToast, Text, Toasts, UserStore } from "@webpack/common"; +import { Channel } from "discord-types/general"; import { JSX } from "react"; import gitHash from "~git-hash"; @@ -42,10 +43,8 @@ import SettingsPlugin from "./settings"; const CodeBlockRe = /```js\n(.+?)```/s; -const AllowedChannelIds = [ - SUPPORT_CHANNEL_ID, +const AdditionalAllowedChannelIds = [ "1024286218801926184", // Vencord > #bot-spam - "1033680203433660458", // Vencord > #v ]; const TrustedRolesIds = [ @@ -58,6 +57,8 @@ const AsyncFunction = async function () { }.constructor; const ShowCurrentGame = getUserSettingLazy("status", "showCurrentGame")!; +const isSupportAllowedChannel = (channel: Channel) => channel.parent_id === SUPPORT_CATEGORY_ID || AdditionalAllowedChannelIds.includes(channel.id); + async function forceUpdate() { const outdated = await checkForUpdates(); if (outdated) { @@ -155,20 +156,21 @@ export default definePlugin({ { name: "vencord-debug", description: "Send Vencord debug info", - predicate: ctx => isPluginDev(UserStore.getCurrentUser()?.id) || AllowedChannelIds.includes(ctx.channel.id), + predicate: ctx => isPluginDev(UserStore.getCurrentUser()?.id) || isSupportAllowedChannel(ctx.channel), execute: async () => ({ content: await generateDebugInfoMessage() }) }, { name: "vencord-plugins", description: "Send Vencord plugin list", - predicate: ctx => isPluginDev(UserStore.getCurrentUser()?.id) || AllowedChannelIds.includes(ctx.channel.id), + predicate: ctx => isPluginDev(UserStore.getCurrentUser()?.id) || isSupportAllowedChannel(ctx.channel), execute: () => ({ content: generatePluginList() }) } ], flux: { async CHANNEL_SELECT({ channelId }) { - if (channelId !== SUPPORT_CHANNEL_ID) return; + const isSupportChannel = channelId === SUPPORT_CHANNEL_ID || ChannelStore.getChannel(channelId)?.parent_id === SUPPORT_CATEGORY_ID; + if (!isSupportChannel) return; const selfId = UserStore.getCurrentUser()?.id; if (!selfId || isPluginDev(selfId)) return; @@ -239,7 +241,7 @@ export default definePlugin({ !IS_UPDATER_DISABLED && ( (props.channel.id === KNOWN_ISSUES_CHANNEL_ID) || - (props.channel.id === SUPPORT_CHANNEL_ID && props.message.author.id === VENBOT_USER_ID) + (props.channel.parent_id === SUPPORT_CATEGORY_ID && props.message.author.id === VENBOT_USER_ID) ) && props.message.content?.includes("update"); @@ -265,7 +267,7 @@ export default definePlugin({ ); } - if (props.channel.id === SUPPORT_CHANNEL_ID) { + if (props.channel.parent_id === SUPPORT_CATEGORY_ID && PermissionStore.can(PermissionsBits.SEND_MESSAGES, props.channel)) { if (props.message.content.includes("/vencord-debug") || props.message.content.includes("/vencord-plugins")) { buttons.push(