-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
53 lines (44 loc) · 1.89 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 jesusqc
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import "./style.css";
import definePlugin from "@utils/types";
import { addChatBarButton, removeChatBarButton } from "@api/ChatButtons";
import { addMessagePreSendListener, removeMessagePreSendListener } from "@api/MessageEvents";
import { MoreEmotesButton, MoreEmotesPicker } from "./components/MoreEmotesComponents";
import { emoteSearchReplacer } from "./api/seventv";
export default definePlugin({
name: "MoreEmotes",
description: "Expand your emote game with a custom 7TV emote picker!",
authors: [{ name: "jesusqc", id: 430960270433845249n }],
/*
Hear me out, I wasn't able to get what function to call to open the vanilla emote picker in 30 mins,
so I surrendered and made my own emote picker, if someone knows how to open the fucking vanilla emote picker let me know,
Anyways, this works just as fine, the patch is a bit hacky but it works, really tried to speedrun this.
*/
patches: [
{
find: "hasStackedBar]",
replacement: {
match: /null:\((.*?)\)\((.*?)\)(.*?)chatInputType:(.*?)}/,
replace: "null:($1)($self.MoreEmotesPicker,{children:[($1)($2)],chatInputType:$4})$3chatInputType:$4}"
}
}
],
start() {
addChatBarButton("MoreEmotes", MoreEmotesButton);
/* We convert to an emote any message that goes like :+EMOTE NAME: */
this.preSend = addMessagePreSendListener(async (_, msg) => {
if (!msg.content || !msg.content.startsWith(":+") || !msg.content.endsWith(":"))
return;
msg.content = await emoteSearchReplacer(msg.content.slice(2, -1));
});
},
stop() {
removeChatBarButton("MoreEmotes");
removeMessagePreSendListener(this.preSend);
},
MoreEmotesPicker
});