1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-10 09:56:24 +00:00

add forum tags

This commit is contained in:
sadan 2025-01-04 23:39:32 -05:00
parent e139522fa7
commit d9fd55d9a8
No known key found for this signature in database

View file

@ -30,6 +30,12 @@ import { Promisable } from "type-fest";
const StickersStore = findStoreLazy("StickersStore"); const StickersStore = findStoreLazy("StickersStore");
const uploadEmoji = findByCodeLazy(".GUILD_EMOJIS(", "EMOJI_UPLOAD_START"); const uploadEmoji = findByCodeLazy(".GUILD_EMOJIS(", "EMOJI_UPLOAD_START");
interface ForumTagContextMenuProps {
tag: {
emojiId: null | string;
};
}
interface OnboardingContextMenuProps { interface OnboardingContextMenuProps {
option: { option: {
emoji: { id: string; name: string; animated: boolean; } | { id: null; }; emoji: { id: string; name: string; animated: boolean; } | { id: null; };
@ -388,6 +394,20 @@ const imageContextMenuPatch: NavContextMenuPatchCallback = (children, { target,
return; return;
}; };
const forumTagContextMenuPatch: NavContextMenuPatchCallback = (children, { tag }: ForumTagContextMenuProps) => {
if (!tag?.emojiId) return;
// same function discord calls on the emoji id
const emoji = EmojiStore.getUsableCustomEmojiById(tag.emojiId);
if (!emoji) return;
children.push(buildMenuItem("Emoji", () => ({
id: emoji.id,
name: emoji.name,
isAnimated: emoji.animated,
})));
};
export default definePlugin({ export default definePlugin({
name: "EmoteCloner", name: "EmoteCloner",
description: "Allows you to clone Emotes & Stickers to your own server (right click them)", description: "Allows you to clone Emotes & Stickers to your own server (right click them)",
@ -398,8 +418,17 @@ export default definePlugin({
{ {
find: "emoji.animated||", find: "emoji.animated||",
replacement: { replacement: {
match: /(?=onClick:)/, match: /(?=onClick:)(?=.*\(\)=>(\i)\(!1\))/,
replace: "onContextMenu:$self.OnboardingContextMenu.bind(null, arguments[0])," replace: "onContextMenu:$self.OnboardingContextMenu.bind(null,arguments[0],$1),"
}
},
// needed because the context menu wont show up if dev mode is disabled (only used for copying ids)
{
find: '"forum-tag-"',
replacement: {
match: /(?<=&&)\i(?=&&)/,
// make sure there is a custom emoji as well
replace: "arguments[0]?.tag?.emojiId != null"
} }
} }
], ],
@ -412,14 +441,14 @@ export default definePlugin({
contextMenus: { contextMenus: {
"message": messageContextMenuPatch, "message": messageContextMenuPatch,
"expression-picker": expressionPickerPatch, "expression-picker": expressionPickerPatch,
"image-context": imageContextMenuPatch "image-context": imageContextMenuPatch,
"forum-tag": forumTagContextMenuPatch,
}, },
OnboardingContextMenu({ option: { emoji } }: OnboardingContextMenuProps, ev: React.MouseEvent) { OnboardingContextMenu({ option: { emoji } }: OnboardingContextMenuProps, setMouseDown: (v: boolean) => void, ev: React.MouseEvent) {
// covers no emoji and unicode emojis // covers no emoji and unicode emojis
if (emoji?.id == null) return; if (emoji?.id == null) return;
console.log(emoji);
ContextMenuApi.openContextMenuLazy(ev, async () => { ContextMenuApi.openContextMenuLazy(ev, async () => {
return () => (<Menu.Menu return () => (<Menu.Menu
navId="onboarding-question-context" navId="onboarding-question-context"
@ -431,5 +460,7 @@ export default definePlugin({
}))} }))}
</Menu.Menu>); </Menu.Menu>);
}); });
// fixes really annoying visual quirk due to discords code
setMouseDown(false);
}, },
}); });