From 9c092b9c2996f029683e4fa3ea2c676c25a88c86 Mon Sep 17 00:00:00 2001 From: goodbee <100511746+schoeneBiene@users.noreply.github.com> Date: Tue, 21 May 2024 02:24:00 +0200 Subject: [PATCH] feat(BetterRoleContext): Add option to view role icons (#2482) Co-authored-by: vee --- src/plugins/betterRoleContext/README.md | 4 +-- src/plugins/betterRoleContext/index.tsx | 48 ++++++++++++++++++++++--- src/utils/constants.ts | 4 +++ 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/plugins/betterRoleContext/README.md b/src/plugins/betterRoleContext/README.md index 3f3086b..e54e1e3 100644 --- a/src/plugins/betterRoleContext/README.md +++ b/src/plugins/betterRoleContext/README.md @@ -1,6 +1,6 @@ # BetterRoleContext -Adds options to copy role color and edit role when right clicking roles in the user profile +Adds options to copy role color, edit role and view role icon when right clicking roles in the user profile -![](https://github.com/Vendicated/Vencord/assets/45497981/d1765e9e-7db2-4a3c-b110-139c59235326) +![](https://github.com/Vendicated/Vencord/assets/45497981/354220a4-09f3-4c5f-a28e-4b19ca775190) diff --git a/src/plugins/betterRoleContext/index.tsx b/src/plugins/betterRoleContext/index.tsx index 3db3494..ecb1ed4 100644 --- a/src/plugins/betterRoleContext/index.tsx +++ b/src/plugins/betterRoleContext/index.tsx @@ -4,9 +4,11 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +import { definePluginSettings } from "@api/Settings"; +import { ImageIcon } from "@components/Icons"; import { Devs } from "@utils/constants"; -import { getCurrentGuild } from "@utils/discord"; -import definePlugin from "@utils/types"; +import { getCurrentGuild, openImageModal } from "@utils/discord"; +import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; import { Clipboard, GuildStore, Menu, PermissionStore, TextAndImagesSettingsStores } from "@webpack/common"; @@ -34,10 +36,34 @@ function AppearanceIcon() { ); } +const settings = definePluginSettings({ + roleIconFileFormat: { + type: OptionType.SELECT, + description: "File format to use when viewing role icons", + options: [ + { + label: "png", + value: "png", + default: true + }, + { + label: "webp", + value: "webp", + }, + { + label: "jpg", + value: "jpg" + } + ] + } +}); + 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], + description: "Adds options to copy role color / edit role / view role icon when right clicking roles in the user profile", + authors: [Devs.Ven, Devs.goodbee], + + settings, start() { // DeveloperMode needs to be enabled for the context menu to be shown @@ -63,6 +89,20 @@ export default definePlugin({ ); } + if (role.icon) { + children.push( + { + openImageModal(`${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/role-icons/${role.id}/${role.icon}.${settings.store.roleIconFileFormat}`); + }} + icon={ImageIcon} + /> + + ); + } + if (PermissionStore.getGuildPermissionProps(guild).canManageRoles) { children.push(