ViewIcons: add avatar decoration support (#4383)
This commit is contained in:
parent
159698f6fc
commit
375950af4e
2 changed files with 17 additions and 3 deletions
4
packages/discord-types/src/utils.d.ts
vendored
4
packages/discord-types/src/utils.d.ts
vendored
|
|
@ -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 type { ReactNode } from "react";
|
||||||
import { LiteralUnion } from "type-fest";
|
import { LiteralUnion } from "type-fest";
|
||||||
|
|
||||||
|
|
@ -203,7 +203,7 @@ export interface IconUtils {
|
||||||
getUserAvatarURL(user: User, canAnimate?: boolean, size?: number, format?: string): string;
|
getUserAvatarURL(user: User, canAnimate?: boolean, size?: number, format?: string): string;
|
||||||
getDefaultAvatarURL(id: string, discriminator?: string): string;
|
getDefaultAvatarURL(id: string, discriminator?: string): string;
|
||||||
getUserBannerURL(data: { id: string, banner: string, canAnimate?: boolean, size: number; }): string | undefined;
|
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;
|
getGuildMemberAvatarURL(member: GuildMember, canAnimate?: string): string | null;
|
||||||
getGuildMemberAvatarURLSimple(data: { guildId: string, userId: string, avatar: string, canAnimate?: boolean; size?: number; }): string;
|
getGuildMemberAvatarURLSimple(data: { guildId: string, userId: string, avatar: string, canAnimate?: boolean; size?: number; }): string;
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,8 @@ const UserContext: NavContextMenuPatchCallback = (children, { user, guildId }: U
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
const memberAvatar = GuildMemberStore.getMember(guildId!, user.id)?.avatar || null;
|
const memberAvatar = GuildMemberStore.getMember(guildId!, user.id)?.avatar || null;
|
||||||
|
|
||||||
|
const avatarDecoration = user.avatarDecorationData ?? user.avatarDecoration;
|
||||||
|
|
||||||
children.splice(-1, 0, (
|
children.splice(-1, 0, (
|
||||||
<Menu.MenuGroup>
|
<Menu.MenuGroup>
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
|
|
@ -120,6 +122,18 @@ const UserContext: NavContextMenuPatchCallback = (children, { user, guildId }: U
|
||||||
icon={ImageIcon}
|
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>
|
</Menu.MenuGroup>
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|
@ -180,7 +194,7 @@ const GroupDMContext: NavContextMenuPatchCallback = (children, { channel }: Grou
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "ViewIcons",
|
name: "ViewIcons",
|
||||||
authors: [Devs.Ven, Devs.TheKodeToad, Devs.Nuckyz, Devs.nyx],
|
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"],
|
tags: ["Media", "Servers", "Appearance"],
|
||||||
searchTerms: ["ImageUtilities"],
|
searchTerms: ["ImageUtilities"],
|
||||||
dependencies: ["DynamicImageModalAPI"],
|
dependencies: ["DynamicImageModalAPI"],
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue