From a759eff956f45207165e19e2c2bd9ce56b573145 Mon Sep 17 00:00:00 2001 From: RobinRMC Date: Tue, 29 Apr 2025 22:27:15 +0200 Subject: [PATCH] Add ForwardAnywhere --- src/plusplugins/forwardAnywhere/index.ts | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/plusplugins/forwardAnywhere/index.ts diff --git a/src/plusplugins/forwardAnywhere/index.ts b/src/plusplugins/forwardAnywhere/index.ts new file mode 100644 index 00000000..e0716595 --- /dev/null +++ b/src/plusplugins/forwardAnywhere/index.ts @@ -0,0 +1,39 @@ +/* + * 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 { sendMessage } from "@utils/discord"; +import definePlugin from "@utils/types"; +import { Message } from "discord-types/general"; + +export default definePlugin({ + name: "ForwardAnywhere", + description: "Sends a forwarded message as a normal message if it's not possible to forward the message. Also allows messages from channels marked as NSFW to be forwarded to channels not marked as NSFW", + authors: [EquicordDevs.thororen], + patches: [ + { + find: "#{intl::MESSAGE_FORWARDING_NSFW_NOT_ALLOWED}", + replacement: { + match: /if\((\i)\.isNSFW\(\)&&.{0,25}\)\)\)/, + replace: "if(false)", + } + }, + { + find: "#{intl::MESSAGE_ACTION_FORWARD_TO}", + replacement: { + match: /(?<=let (\i)=.{0,25}rejected.{0,25}\);)(?=.{0,25}message:(\i))/, + replace: "if ($1) return $self.sendForward($1,$2);", + } + }, + ], + sendForward(channels: any, message: Message) { + for (const c of channels) { + sendMessage(c.id, { + content: `${message.content}\n\n> Forwarded from <#${message.channel_id}>` + }); + } + } +});