/* * Vencord, a Discord client mod * Copyright (c) 2024 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ import { Devs } from "@utils/constants"; import { getCurrentGuild, getGuildRoles } from "@utils/discord"; import definePlugin from "@utils/types"; import { findByPropsLazy } from "@webpack"; import { Clipboard, Menu, PermissionStore, TextAndImagesSettingsStores } from "@webpack/common"; const GuildSettingsActions = findByPropsLazy("open", "selectRole", "updateGuild"); function PencilIcon() { return ( ); } function AppearanceIcon() { return ( ); } export default definePlugin({ name: "BetterRoleContext", description: "Adds options to copy role color / edit role when right clicking roles in the user profile", authors: [Devs.Ven], start() { // DeveloperMode needs to be enabled for the context menu to be shown TextAndImagesSettingsStores.DeveloperMode.updateSetting(true); }, contextMenus: { "dev-context"(children, { id }: { id: string; }) { const guild = getCurrentGuild(); if (!guild) return; const role = getGuildRoles(guild.id)[id]; if (!role) return; if (role.colorString) { children.push( Clipboard.copy(role.colorString!)} icon={AppearanceIcon} /> ); } if (PermissionStore.getGuildPermissionProps(guild).canManageRoles) { children.push( { await GuildSettingsActions.open(guild.id, "ROLES"); GuildSettingsActions.selectRole(id); }} icon={PencilIcon} /> ); } } } });