diff --git a/packages/structures/src/emojis/Emoji.ts b/packages/structures/src/emojis/Emoji.ts index 5765008eaacd..1d4548e92cf3 100644 --- a/packages/structures/src/emojis/Emoji.ts +++ b/packages/structures/src/emojis/Emoji.ts @@ -1,5 +1,5 @@ import { DiscordSnowflake } from '@sapphire/snowflake'; -import type { APIEmoji } from 'discord-api-types/v10'; +import { CDNRoutes, ImageFormat, RouteBases, type APIEmoji, type EmojiFormat } from 'discord-api-types/v10'; import { Structure } from '../Structure.js'; import { kData } from '../utils/symbols.js'; import { isIdSet } from '../utils/type-guards.js'; @@ -85,4 +85,13 @@ export class Emoji extends Structure; + /** * Represents a sticker on Discord. * @@ -69,4 +84,13 @@ export class Sticker extends Structu public get type() { return this[kData].type; } + + /** + * Get the URL to the sticker + */ + public get url() { + return isIdSet(this[kData].id) && isFieldSet(this[kData], 'format_type', 'number') + ? `${RouteBases.cdn}${CDNRoutes.sticker(this[kData].id.toString(), StickerFormatExtensionMap[this[kData].format_type] as StickerFormat)}` + : null; + } } diff --git a/packages/structures/src/users/AvatarDecorationData.ts b/packages/structures/src/users/AvatarDecorationData.ts index f006d47b37ca..f09ad4c22f04 100644 --- a/packages/structures/src/users/AvatarDecorationData.ts +++ b/packages/structures/src/users/AvatarDecorationData.ts @@ -1,6 +1,7 @@ -import type { APIAvatarDecorationData } from 'discord-api-types/v10'; +import { CDNRoutes, RouteBases, type APIAvatarDecorationData } from 'discord-api-types/v10'; import { Structure } from '../Structure.js'; import { kData } from '../utils/symbols.js'; +import { isFieldSet } from '../utils/type-guards.js'; import type { Partialize } from '../utils/types.js'; /** @@ -37,4 +38,15 @@ export class AvatarDecorationData extends Structure> 22n) % 6) as DefaultUserAvatarAssets, + )}` + : null; + } + + /** + * Get the URL to the user avatar or their default avatar, if none is set + */ + public displayAvatarURL(format: UserAvatarFormat = ImageFormat.WebP) { + return this.avatarURL(format) ?? this.defaultAvatarURL; + } + /** * Whether the user is a bot */ @@ -98,6 +137,17 @@ export class User extends Structure