From 03e663021e77caa421146badd28f564628f2b54b Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Thu, 15 May 2025 00:19:20 -0400 Subject: [PATCH] FastDeleteChannels --- README.md | 1 + .../fastDeleteChannels/index.tsx | 83 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 src/equicordplugins/fastDeleteChannels/index.tsx diff --git a/README.md b/README.md index a6ea882a..c58a409b 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch - ExportContacts by dat_insanity - FakeProfileThemesAndEffects by ryan - CopyProfileColors by Crxa +- FastDeleteChannels by thororen - FindReply by newwares - FixFileExtensions by thororen - FollowVoiceUser by TheArmagan diff --git a/src/equicordplugins/fastDeleteChannels/index.tsx b/src/equicordplugins/fastDeleteChannels/index.tsx new file mode 100644 index 00000000..1facee66 --- /dev/null +++ b/src/equicordplugins/fastDeleteChannels/index.tsx @@ -0,0 +1,83 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2025 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { EquicordDevs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { Constants, PermissionsBits, PermissionStore, React, RestAPI, useCallback, useEffect, useState } from "@webpack/common"; + +const showIcon = () => { + const [show, setShow] = useState(false); + + const handleKeys = useCallback(e => { + const keysHeld = e.ctrlKey && e.altKey; + setShow(keysHeld); + }, []); + + useEffect(() => { + window.addEventListener("keydown", handleKeys); + window.addEventListener("keyup", handleKeys); + + return () => { + window.removeEventListener("keydown", handleKeys); + window.removeEventListener("keyup", handleKeys); + }; + }, [handleKeys]); + + return show; +}; + +export default definePlugin({ + name: "FastDeleteChannels", + description: "Adds a trash icon to delete channels when holding ctrl + alt", + authors: [EquicordDevs.thororen], + patches: [ + // TY TypingIndicator + { + find: "UNREAD_IMPORTANT:", + replacement: { + match: /\.name,{.{0,140}\.children.+?:null(?<=,channel:(\i).+?)/, + replace: "$&,$self.TrashIcon($1)" + } + }, + { + find: "M11 9H4C2.89543 9 2 8.10457 2 7V1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1V7C0 9.20914 1.79086 11 4 11H11C11.5523 11 12 10.5523 12 10C12 9.44771 11.5523 9 11 9Z", + replacement: { + match: /mentionsCount:\i.+?null(?<=channel:(\i).+?)/, + replace: "$&,$self.TrashIcon($1)" + } + } + ], + TrashIcon: channel => { + const show = showIcon(); + + if (!show || !PermissionStore.can(PermissionsBits.MANAGE_CHANNELS, channel)) return null; + + return ( + RestAPI.del({ url: Constants.Endpoints.CHANNEL(channel.id) })} + > + + + + + + ); + } +});