diff --git a/src/equicordplugins/copyProfileColors/index.tsx b/src/equicordplugins/copyProfileColors/index.tsx new file mode 100644 index 000000000..256e86994 --- /dev/null +++ b/src/equicordplugins/copyProfileColors/index.tsx @@ -0,0 +1,98 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2025 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { NavContextMenuPatchCallback } from "@api/ContextMenu"; +import { copyToClipboard } from "@utils/clipboard"; +import { EquicordDevs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { Menu, Toasts, UserProfileStore } from "@webpack/common"; + +function getProfileColors(userId) { + try { + const profile = UserProfileStore.getUserProfile(userId); + + if (!profile || !profile.themeColors || profile.themeColors.length < 2) { + return null; + } + + const primaryColor = profile.themeColors[0].toString(16).padStart(6, "0"); + const secondaryColor = profile.themeColors[1].toString(16).padStart(6, "0"); + + return { primaryColor, secondaryColor }; + } catch (e) { + console.error("Failed to get profile colors:", e); + return null; + } +} + +function copyProfileColors(userId) { + const colors = getProfileColors(userId); + + if (!colors) { + Toasts.show({ + type: Toasts.Type.FAILURE, + message: "No profile colors found!", + id: Toasts.genId() + }); + return; + } + + const { primaryColor, secondaryColor } = colors; + + // Formatting + const formattedColors = `Primary-color #${primaryColor}, Secondary-Color #${secondaryColor}`; + + try { + copyToClipboard(formattedColors); + Toasts.show({ + type: Toasts.Type.SUCCESS, + message: "Profile colors copied to clipboard!", + id: Toasts.genId() + }); + } catch (e) { + console.error("Failed to copy to clipboard:", e); + Toasts.show({ + type: Toasts.Type.FAILURE, + message: "Error copying profile colors!", + id: Toasts.genId() + }); + } +} + +export function ColorIcon() { + return ( + + ); +} +// spawn in the context menu +const userContextMenuPatch: NavContextMenuPatchCallback = (children, { user }) => { + if (!user) return; + children.push( +
+ )}
+