diff --git a/src/plusplugins/forwardHere/index.ts b/src/plusplugins/forwardHere/index.ts index f832f6f4..6d6213be 100644 --- a/src/plusplugins/forwardHere/index.ts +++ b/src/plusplugins/forwardHere/index.ts @@ -1,22 +1,29 @@ /* * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors + * Copyright (c) 2025 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; +import { UserStore } from "@webpack/common"; +import { Message } from "discord-types/general"; export default definePlugin({ name: "ForwardHere", - description: "Adds the current channel at the top of the Forward menu", + description: "Adds the current channel and the author of the message at the top of the forwarding menu", authors: [Devs.Sqaaakoi], settings: definePluginSettings({ selectedByDefault: { type: OptionType.BOOLEAN, description: "Selects the current channel in the forward menu by default", default: false + }, + author: { + type: OptionType.BOOLEAN, + description: "Adds the author of the message to the forwarding menu", + default: false } }), patches: [ @@ -26,14 +33,19 @@ export default definePlugin({ // top of search results { match: /(selectedDestinations:)(\i)(,originDestination:)(\i)/, - replace: "$1[$4,...$2]$3$4" + replace: "$1[$4,...($self.injectAuthor(arguments[0].message)),...$2]$3$4" }, // select by default { - match: /(\[\i,\i]=\i\.useState\()(\i)(\).{0,120}originDestination:)(\i)/, + match: /(\[\i,\i]=\i\.useState\()(\i)(\).{0,200}?originDestination:)(\i)/, replace: "$1$2.length<1&&$self.settings.store.selectedByDefault?[$4]:$2$3$4" } ] } - ] + ], + injectAuthor(message: Message) { + const userId = message.author.id; + if (!this.settings.store.author || (UserStore.getCurrentUser().id === userId) || (message.webhookId && message.author.isNonUserBot())) return []; + return [{ type: "user", id: userId }]; + } });