Update ForwardHere

This commit is contained in:
RobinRMC 2025-02-21 11:50:27 +01:00 committed by GitHub
parent 73d0308d2c
commit 829afaebf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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