From 02d34de59b187a625f2210ed0c60ad8928f97d26 Mon Sep 17 00:00:00 2001 From: Crxaw <48805031+sitescript@users.noreply.github.com> Date: Fri, 11 Apr 2025 00:41:02 +0100 Subject: [PATCH] feat(plugin): copyProfileColors + update LastActive (#225) * feat(Copy Profile Colors) Plugin A button added to a user's context menu to collect their colors of their profile (https://discord.com/channels/1173279886065029291/1357341192475508876) * Update README.md * Updated LastActive Clean up! * Fixed imports --- README.md | 3 +- .../copyProfileColors/index.tsx | 106 ++++++++++++++++++ src/equicordplugins/lastActive/index.tsx | 39 ++++++- 3 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 src/equicordplugins/copyProfileColors/index.tsx diff --git a/README.md b/README.md index 11c3bb09..99478980 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch ### Extra included plugins
-164 additional plugins +165 additional plugins ### All Platforms @@ -57,6 +57,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch - Equissant by SomeAspy & thororen - ExportContacts by dat_insanity - FakeProfileThemesAndEffects by ryan +- CopyProfileColors by Crxa - FindReply by newwares - FixFileExtensions by thororen - FollowVoiceUser by TheArmagan diff --git a/src/equicordplugins/copyProfileColors/index.tsx b/src/equicordplugins/copyProfileColors/index.tsx new file mode 100644 index 00000000..216adacf --- /dev/null +++ b/src/equicordplugins/copyProfileColors/index.tsx @@ -0,0 +1,106 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2025 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu"; +import { EquicordDevs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { Clipboard, 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 { + Clipboard.copy(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( + Copy Profile Colors} + action={() => copyProfileColors(user.id)} + /> + ); +}; + +export default definePlugin({ + name: "CopyProfileColors", + description: "A plugin to copy people's profile gradient colors to clipboard.", + authors: [EquicordDevs.Crxa, EquicordDevs.Cortex], // Cortex is here because he showed me how to add icons <3 + + start() { + addContextMenuPatch("user-context", userContextMenuPatch); + addContextMenuPatch("user-profile-actions", userContextMenuPatch); + }, + + stop() { + // bye bye menu options + removeContextMenuPatch("user-context", userContextMenuPatch); + removeContextMenuPatch("user-profile-actions", userContextMenuPatch); + } +}); diff --git a/src/equicordplugins/lastActive/index.tsx b/src/equicordplugins/lastActive/index.tsx index 4325bee6..838d5759 100644 --- a/src/equicordplugins/lastActive/index.tsx +++ b/src/equicordplugins/lastActive/index.tsx @@ -84,7 +84,8 @@ const ChannelContextMenuPatch: NavContextMenuPatchCallback = (children, { channe children.push( Jump to Your Last Message} + label={Your Last Message} + icon={LastActiveIcon} action={() => { jumpToLastActive(channel); }} @@ -97,13 +98,47 @@ const UserContextMenuPatch: NavContextMenuPatchCallback = (children, { user, cha children.push( Jump to User's Last Message} + label={User's Last Message} + icon={UserLastActiveIcon} action={() => { jumpToLastActive(channel, user.id); }} /> ); }; +export function UserLastActiveIcon() { + return ( + + + + + + + ); +} + +export function LastActiveIcon() { + return ( + + + + ); +} export default definePlugin({ name: "LastActive", description: "A plugin to jump to last active message from yourself or another user in a channel/server.",