From 5da4bd72a85661f48a0b7d7b76df2f7366813ac5 Mon Sep 17 00:00:00 2001 From: vMohammad <62218284+vMohammad24@users.noreply.github.com> Date: Wed, 11 Dec 2024 22:50:59 +0300 Subject: [PATCH] Added BetterPlusReacts plugin (#110) * Added BetterPlusReacts plugin * added betterplusreacts to the readme * Revert Count * Fix Authors --------- Co-authored-by: thororen <78185467+thororen1234@users.noreply.github.com> --- README.md | 1 + src/equicordplugins/betterplusreacts/index.ts | 61 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/equicordplugins/betterplusreacts/index.ts diff --git a/README.md b/README.md index 1109ae85..2146bb7e 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch - BetterInvites by iamme - BetterQuickReact by Ven & Sqaaakoi - BetterUserArea by Samwich +- BetterPlusReacts by Joona - BlockKeywords by catcraft - BlockKrsip by D3SOX - BypassStatus by Inbestigator & thororen diff --git a/src/equicordplugins/betterplusreacts/index.ts b/src/equicordplugins/betterplusreacts/index.ts new file mode 100644 index 00000000..5426dbcb --- /dev/null +++ b/src/equicordplugins/betterplusreacts/index.ts @@ -0,0 +1,61 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +// https://github.com/Masterjoona/vc-betterplusreacts/blob/main/index.ts +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findByPropsLazy } from "@webpack"; + +const { getMessages } = findByPropsLazy("getMessages"); + +export default definePlugin({ + name: "BetterPlusReacts", + authors: [Devs.Joona], + description: "The amount of plus before :emoji: is the message to add it to", + patches: [ + { + find: ".SLASH_COMMAND_USED,", + replacement: [ + { + match: /\\\+/, + replace: "$&*" + }, + { + match: /\i.trim\(\)/, + replace: "$&.replace(/^\\++/, '+')" + }, + { + match: /=(\i\.\i\.getMessages\(\i\.id\))\.last\(\)(?=.{78,85}.getByName\((\i)\.)/, + replace: "=$self.getMsgReference()" + } + ] + }, + { + find: "this.props.activeCommandOption,", + replacement: [ + // Enable auto complete for multiple plusses + // and set the message reference + { + match: /:this.props.currentWord/, + replace: "$&.replace(/^\\++/, '+')" + }, + { + match: /this.props.editorRef.current\)return;/, + replace: "$&$self.setMsgReference(this.props.currentWord.split(':')[0],this.props.channel.id);" + } + ] + }, + ], + message: null, + getMsgReference() { + const { message } = this; + this.message = null; + return message; + }, + setMsgReference(plusses: string, channelId: string) { + this.message = getMessages(channelId).getByIndex(getMessages(channelId).length - plusses.split("+").length + 1); + } +});