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>
This commit is contained in:
vMohammad 2024-12-11 22:50:59 +03:00 committed by GitHub
parent a1ff675363
commit 5da4bd72a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 62 additions and 0 deletions

View file

@ -25,6 +25,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch
- BetterInvites by iamme - BetterInvites by iamme
- BetterQuickReact by Ven & Sqaaakoi - BetterQuickReact by Ven & Sqaaakoi
- BetterUserArea by Samwich - BetterUserArea by Samwich
- BetterPlusReacts by Joona
- BlockKeywords by catcraft - BlockKeywords by catcraft
- BlockKrsip by D3SOX - BlockKrsip by D3SOX
- BypassStatus by Inbestigator & thororen - BypassStatus by Inbestigator & thororen

View file

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