Add ForwardAnywhere

This commit is contained in:
RobinRMC 2025-04-29 22:27:15 +02:00 committed by GitHub
parent bebbe404e0
commit a759eff956
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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}>`
});
}
}
});