diff --git a/src/equicordplugins/equicordHelper/index.tsx b/src/equicordplugins/equicordHelper/index.tsx index bd9672f90..b9f9ea77c 100644 --- a/src/equicordplugins/equicordHelper/index.tsx +++ b/src/equicordplugins/equicordHelper/index.tsx @@ -1,49 +1,41 @@ /* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and Megumin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ + * Vencord, a Discord client mod + * Copyright (c) 2025 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ import "@equicordplugins/_misc/styles.css"; +import { definePluginSettings, Settings } from "@api/Settings"; import { Devs, EQUICORD_HELPERS, EquicordDevs, GUILD_ID } from "@utils/constants"; import { Logger } from "@utils/Logger"; -import definePlugin from "@utils/types"; -import { Button, ChannelStore, Flex, Forms, GuildMemberStore, showToast, Toasts } from "@webpack/common"; +import definePlugin, { OptionType } from "@utils/types"; +import { Button, ChannelStore, Flex, GuildMemberStore, showToast, Toasts } from "@webpack/common"; import { JSX } from "react"; import { toggleEnabled } from "./utils"; +const settings = definePluginSettings({ + disableCreateDMButton: { + type: OptionType.BOOLEAN, + description: "Disables the create dm button", + restartNeeded: true, + default: false, + }, + disableDMContextMenu: { + type: OptionType.BOOLEAN, + description: "Disables the DM list context menu in favor of the x button", + restartNeeded: true, + default: false + } +}); export default definePlugin({ name: "EquicordHelper", - description: "Fixes some misc issues with discord", + description: "Used to provide support, fix discord caused crashes, and other misc features.", authors: [Devs.thororen, EquicordDevs.nyx, EquicordDevs.Naibuu], - settingsAboutComponent: () => <> - - This plugin was created to allow us as the Equicord Team & Contributors - to fix miscellaneous issues Discord may run into or cause. -
- This includes but is not limited to: -
- - Unknown Resolution/FPS Fixed? -
- - Whitelists all domains in CSP -
- , required: true, + settings, patches: [ // Fixes Unknown Resolution/FPS Crashing { @@ -58,47 +50,72 @@ export default definePlugin({ replace: "return $1;" } ] - } + }, + { + find: ".createDMButtonContainer,", + replacement: { + match: /"create-dm"\)/, + replace: "$&&&false" + }, + predicate: () => settings.store.disableCreateDMButton + }, + { + find: "#{intl::d+e27u::raw}", + replacement: { + match: /\{dotsInsteadOfCloseButton:(\i),rearrangeContextMenu:(\i).*?autoTrackExposure:!0\}\)/, + replace: "$1=false,$2=false" + }, + predicate: () => settings.store.disableDMContextMenu + }, ], - renderMessageAccessory(props) { - const buttons = [] as JSX.Element[]; - - const equicordSupport = GuildMemberStore.getMember(GUILD_ID, props.message.author.id)?.roles?.includes(EQUICORD_HELPERS); - - const msg = props.message.content?.toLowerCase() ?? ""; - - const contentWords = (msg.match(/`\w+`/g) ?? []).map(e => e.slice(1, -1)); - const matchedPlugins = Object.keys(Vencord.Plugins.plugins).filter(name => contentWords.includes(name.toLowerCase())); - const matchedPlugin = matchedPlugins.sort((a, b) => b.length - a.length)[0]; - const pluginData = matchedPlugin && Vencord.Plugins.plugins[matchedPlugin]; - const equicordGuild = ChannelStore.getChannel(props.channel.id)?.guild_id === GUILD_ID; - const ableCheck = msg.startsWith("enable") || msg.startsWith("disable"); - const shouldAddPluginButtons = equicordGuild && equicordSupport && matchedPlugin && pluginData && ableCheck; - - if (shouldAddPluginButtons) { - if (pluginData.required || pluginData.name.endsWith("API")) return; - const isEnabled = Vencord.Plugins.isPluginEnabled(matchedPlugin); - buttons.push( - - ); + start() { + if (Settings.plugins?.PinDMs?.disableCreateDMButton) { + settings.store.disableCreateDMButton = true; } - - return buttons.length - ? {buttons} - : null; + }, + renderMessageAccessory(props) { + return pluginToggleButtons(props); } }); + +function pluginToggleButtons(props) { + const buttons = [] as JSX.Element[]; + + const equicordSupport = GuildMemberStore.getMember(GUILD_ID, props.message.author.id)?.roles?.includes(EQUICORD_HELPERS); + + const msg = props.message.content?.toLowerCase() ?? ""; + + const contentWords = (msg.match(/`\w+`/g) ?? []).map(e => e.slice(1, -1)); + const matchedPlugins = Object.keys(Vencord.Plugins.plugins).filter(name => contentWords.includes(name.toLowerCase())); + const matchedPlugin = matchedPlugins.sort((a, b) => b.length - a.length)[0]; + const pluginData = matchedPlugin && Vencord.Plugins.plugins[matchedPlugin]; + const equicordGuild = ChannelStore.getChannel(props.channel.id)?.guild_id === GUILD_ID; + const ableCheck = msg.startsWith("enable") || msg.startsWith("disable"); + const shouldAddPluginButtons = equicordGuild && equicordSupport && matchedPlugin && pluginData && ableCheck; + + if (shouldAddPluginButtons) { + if (pluginData.required || pluginData.name.endsWith("API")) return; + const isEnabled = Vencord.Plugins.isPluginEnabled(matchedPlugin); + buttons.push( + + ); + } + + return buttons.length + ? {buttons} + : null; +} diff --git a/src/plugins/pinDms/index.tsx b/src/plugins/pinDms/index.tsx index 0cba4e332..a0832518c 100644 --- a/src/plugins/pinDms/index.tsx +++ b/src/plugins/pinDms/index.tsx @@ -62,11 +62,6 @@ export const settings = definePluginSettings({ default: {} as Record, description: "", }, - disableCreateDMButton: { - type: OptionType.BOOLEAN, - description: "Disables the create dm button", - default: true - } }); export default definePlugin({ @@ -159,14 +154,6 @@ export default definePlugin({ replace: "$self.getAllUncollapsedChannels().concat($&.filter(c=>!$self.isPinned(c)))" } }, - { - find: ".createDMButtonContainer,", - replacement: { - match: /"create-dm"\)/, - replace: "$&&&false" - }, - predicate: () => settings.store.disableCreateDMButton - }, ], sections: null as number[] | null,