ViewIcons: add avatar decoration support (#4383)

This commit is contained in:
0xE90 2026-07-21 17:56:02 +03:00 • committed by GitHub
parent 159698f6fc
commit 375950af4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 3 deletions

View file

@ -1,4 +1,4 @@
import { Channel, Guild, GuildMember, Message, User } from ".";
import { AvatarDecorationData, Channel, Guild, GuildMember, Message, User } from ".";
import type { ReactNode } from "react";
import { LiteralUnion } from "type-fest";
@ -203,7 +203,7 @@ export interface IconUtils {
getUserAvatarURL(user: User, canAnimate?: boolean, size?: number, format?: string): string;
getDefaultAvatarURL(id: string, discriminator?: string): string;
getUserBannerURL(data: { id: string, banner: string, canAnimate?: boolean, size: number; }): string | undefined;
getAvatarDecorationURL(data: { avatarDecoration: string, size: number; canCanimate?: boolean; }): string | undefined;
getAvatarDecorationURL(data: { avatarDecoration: AvatarDecorationData, size: number; canAnimate?: boolean; }): string | undefined;
getGuildMemberAvatarURL(member: GuildMember, canAnimate?: string): string | null;
getGuildMemberAvatarURLSimple(data: { guildId: string, userId: string, avatar: string, canAnimate?: boolean; size?: number; }): string;

View file

@ -99,6 +99,8 @@ const UserContext: NavContextMenuPatchCallback = (children, { user, guildId }: U
if (!user) return;
const memberAvatar = GuildMemberStore.getMember(guildId!, user.id)?.avatar || null;
const avatarDecoration = user.avatarDecorationData ?? user.avatarDecoration;
children.splice(-1, 0, (
<Menu.MenuGroup>
<Menu.MenuItem
@ -120,6 +122,18 @@ const UserContext: NavContextMenuPatchCallback = (children, { user, guildId }: U
icon={ImageIcon}
/>
)}
{avatarDecoration && (
<Menu.MenuItem
id="view-avatar-decoration"
label="View Avatar Decoration"
action={() => openAvatar(IconUtils.getAvatarDecorationURL({
avatarDecoration,
size: 1024,
canAnimate: true
})!)}
icon={ImageIcon}
/>
)}
</Menu.MenuGroup>
));
};
@ -180,7 +194,7 @@ const GroupDMContext: NavContextMenuPatchCallback = (children, { channel }: Grou
export default definePlugin({
name: "ViewIcons",
authors: [Devs.Ven, Devs.TheKodeToad, Devs.Nuckyz, Devs.nyx],
description: "Makes avatars and banners in user profiles clickable, adds View Icon/Banner entries in the user, server and group channel context menu.",
description: "Makes avatars and banners in user profiles clickable, adds View Icon/Banner/Avatar Decoration entries in the user, server and group channel context menu.",
tags: ["Media", "Servers", "Appearance"],
searchTerms: ["ImageUtilities"],
dependencies: ["DynamicImageModalAPI"],