fix var names, regex, and types

This commit is contained in:
sadan 2024-07-11 02:20:07 -04:00
parent 8e649cfcc4
commit bdae37ff23
No known key found for this signature in database

View file

@ -360,19 +360,19 @@ const expressionPickerPatch: NavContextMenuPatchCallback = (children, props: { t
} }
}; };
function imageContextPatch(c, p: { const imageContextPatch: NavContextMenuPatchCallback = (children, props: {
src: string src: string
}){ }) => {
if ("src" in p && /https:\/\/cdn\.discordapp\.com\/emojis\/(\d+)\.[a-zA-Z]{3,4}.*/gm.test(p.src)) { if ("src" in props && /https:\/\/cdn\.discordapp\.com\/emojis\/(\d+)\.([a-zA-Z]{3,4}).*/gm.test(props.src)) {
const matches = [...p.src.matchAll(/https:\/\/cdn\.discordapp\.com\/emojis\/(\d+)\.[a-zA-Z]{3,4}.*/gm)]; const matches = [...props.src.matchAll(/https:\/\/cdn\.discordapp\.com\/emojis\/(\d+)\.([a-zA-Z]{3,4}).*/gm)];
if (!matches) return; if (!matches) return;
c.push(buildMenuItem("Emoji", () => ({ children.push(buildMenuItem("Emoji", () => ({
id: matches[0][1], id: matches[0][1],
isAnimated: (matches[0][2] === "gif"), isAnimated: (matches[0][2] === "gif"),
name: "ProfileEmoji" name: "ProfileEmoji"
}))); })));
} }
} };
interface HangStatus { interface HangStatus {
emoji?: { emoji?: {
// used for unicode emojis and custom emojis // used for unicode emojis and custom emojis
@ -382,19 +382,19 @@ interface HangStatus {
animated?: boolean animated?: boolean
} }
} }
function vcHangStatusContextPatch(c, p: { const vcHangStatusContextPatch: NavContextMenuPatchCallback =(children, props: {
user: { user: {
HangStatus?: HangStatus HangStatus?: HangStatus
} }
}){ }) => {
if(p.user.HangStatus?.emoji?.id){ if(props.user.HangStatus?.emoji?.id){
const e = p.user.HangStatus.emoji as Emoji; const e = props.user.HangStatus.emoji as Emoji;
e.isAnimated = p.user.HangStatus.emoji.animated ?? false; e.isAnimated = props.user.HangStatus.emoji.animated ?? false;
c.push(buildMenuItem("Emoji", () => { children.push(buildMenuItem("Emoji", () => {
return e; return e;
})); }));
} }
} };
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)",