mirror of
https://github.com/RobinRMC/VencordPlus.git
synced 2025-05-11 18:05:39 +02:00
Update ForwardHere
This commit is contained in:
parent
73d0308d2c
commit
829afaebf5
1 changed files with 17 additions and 5 deletions
|
@ -1,22 +1,29 @@
|
||||||
/*
|
/*
|
||||||
* Vencord, a Discord client mod
|
* 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
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
import { UserStore } from "@webpack/common";
|
||||||
|
import { Message } from "discord-types/general";
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "ForwardHere",
|
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],
|
authors: [Devs.Sqaaakoi],
|
||||||
settings: definePluginSettings({
|
settings: definePluginSettings({
|
||||||
selectedByDefault: {
|
selectedByDefault: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Selects the current channel in the forward menu by default",
|
description: "Selects the current channel in the forward menu by default",
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
author: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Adds the author of the message to the forwarding menu",
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
patches: [
|
patches: [
|
||||||
|
@ -26,14 +33,19 @@ export default definePlugin({
|
||||||
// top of search results
|
// top of search results
|
||||||
{
|
{
|
||||||
match: /(selectedDestinations:)(\i)(,originDestination:)(\i)/,
|
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
|
// 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"
|
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 }];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue