diff --git a/packages/discord.js/src/structures/AnonymousGuild.js b/packages/discord.js/src/structures/AnonymousGuild.js index 9c6069a3c..8650211eb 100644 --- a/packages/discord.js/src/structures/AnonymousGuild.js +++ b/packages/discord.js/src/structures/AnonymousGuild.js @@ -68,20 +68,20 @@ class AnonymousGuild extends BaseGuild { /** * The URL to this guild's banner. - * @param {StaticImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - bannerURL({ format, size } = {}) { - return this.banner && this.client.rest.cdn.Banner(this.id, this.banner, format, size); + bannerURL(options = {}) { + return this.banner && this.client.rest.cdn.Banner(this.id, this.banner, options); } /** * The URL to this guild's invite splash image. - * @param {StaticImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - splashURL({ format, size } = {}) { - return this.splash && this.client.rest.cdn.Splash(this.id, this.splash, format, size); + splashURL(options = {}) { + return this.splash && this.client.rest.cdn.Splash(this.id, this.splash, options); } } diff --git a/packages/discord.js/src/structures/BaseGuild.js b/packages/discord.js/src/structures/BaseGuild.js index 16a09467b..12dce1fd1 100644 --- a/packages/discord.js/src/structures/BaseGuild.js +++ b/packages/discord.js/src/structures/BaseGuild.js @@ -87,12 +87,11 @@ class BaseGuild extends Base { /** * The URL to this guild's icon. - * @param {ImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - iconURL({ format, size, dynamic } = {}) { - if (!this.icon) return null; - return this.client.rest.cdn.Icon(this.id, this.icon, format, size, dynamic); + iconURL(options = {}) { + return this.icon && this.client.rest.cdn.Icon(this.id, this.icon, options); } /** diff --git a/packages/discord.js/src/structures/Guild.js b/packages/discord.js/src/structures/Guild.js index cfa0e845b..c562fe326 100644 --- a/packages/discord.js/src/structures/Guild.js +++ b/packages/discord.js/src/structures/Guild.js @@ -480,11 +480,11 @@ class Guild extends AnonymousGuild { /** * The URL to this guild's discovery splash image. - * @param {StaticImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - discoverySplashURL({ format, size } = {}) { - return this.discoverySplash && this.client.rest.cdn.DiscoverySplash(this.id, this.discoverySplash, format, size); + discoverySplashURL(options = {}) { + return this.discoverySplash && this.client.rest.cdn.DiscoverySplash(this.id, this.discoverySplash, options); } /** diff --git a/packages/discord.js/src/structures/GuildMember.js b/packages/discord.js/src/structures/GuildMember.js index ec7b36414..51c232779 100644 --- a/packages/discord.js/src/structures/GuildMember.js +++ b/packages/discord.js/src/structures/GuildMember.js @@ -123,12 +123,11 @@ class GuildMember extends Base { /** * A link to the member's guild avatar. - * @param {ImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - avatarURL({ format, size, dynamic } = {}) { - if (!this.avatar) return null; - return this.client.rest.cdn.GuildMemberAvatar(this.guild.id, this.id, this.avatar, format, size, dynamic); + avatarURL(options = {}) { + return this.avatar && this.client.rest.cdn.GuildMemberAvatar(this.guild.id, this.id, this.avatar, options); } /** diff --git a/packages/discord.js/src/structures/GuildPreview.js b/packages/discord.js/src/structures/GuildPreview.js index 544006061..ea2505cac 100644 --- a/packages/discord.js/src/structures/GuildPreview.js +++ b/packages/discord.js/src/structures/GuildPreview.js @@ -124,29 +124,29 @@ class GuildPreview extends Base { /** * The URL to this guild's splash. - * @param {StaticImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - splashURL({ format, size } = {}) { - return this.splash && this.client.rest.cdn.Splash(this.id, this.splash, format, size); + splashURL(options = {}) { + return this.splash && this.client.rest.cdn.Splash(this.id, this.splash, options); } /** * The URL to this guild's discovery splash. - * @param {StaticImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - discoverySplashURL({ format, size } = {}) { - return this.discoverySplash && this.client.rest.cdn.DiscoverySplash(this.id, this.discoverySplash, format, size); + discoverySplashURL(options = {}) { + return this.discoverySplash && this.client.rest.cdn.DiscoverySplash(this.id, this.discoverySplash, options); } /** * The URL to this guild's icon. - * @param {ImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - iconURL({ format, size, dynamic } = {}) { - return this.icon && this.client.rest.cdn.Icon(this.id, this.icon, format, size, dynamic); + iconURL(options = {}) { + return this.icon && this.client.rest.cdn.Icon(this.id, this.icon, options); } /** diff --git a/packages/discord.js/src/structures/PartialGroupDMChannel.js b/packages/discord.js/src/structures/PartialGroupDMChannel.js index 715d0b67d..6ef75fd08 100644 --- a/packages/discord.js/src/structures/PartialGroupDMChannel.js +++ b/packages/discord.js/src/structures/PartialGroupDMChannel.js @@ -38,11 +38,11 @@ class PartialGroupDMChannel extends Channel { /** * The URL to this channel's icon. - * @param {StaticImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - iconURL({ format, size } = {}) { - return this.icon && this.client.rest.cdn.GDMIcon(this.id, this.icon, format, size); + iconURL(options = {}) { + return this.icon && this.client.rest.cdn.GDMIcon(this.id, this.icon, options); } delete() { diff --git a/packages/discord.js/src/structures/Presence.js b/packages/discord.js/src/structures/Presence.js index 924bbf926..a3cc4191a 100644 --- a/packages/discord.js/src/structures/Presence.js +++ b/packages/discord.js/src/structures/Presence.js @@ -347,10 +347,10 @@ class RichPresenceAssets { /** * Gets the URL of the small image asset - * @param {StaticImageURLOptions} [options] Options for the image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - smallImageURL({ format, size } = {}) { + smallImageURL(options = {}) { if (!this.smallImage) return null; if (this.smallImage.includes(':')) { const [platform, id] = this.smallImage.split(':'); @@ -362,18 +362,15 @@ class RichPresenceAssets { } } - return this.activity.presence.client.rest.cdn.AppAsset(this.activity.applicationId, this.smallImage, { - format, - size, - }); + return this.activity.presence.client.rest.cdn.AppAsset(this.activity.applicationId, this.smallImage, options); } /** * Gets the URL of the large image asset - * @param {StaticImageURLOptions} [options] Options for the image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - largeImageURL({ format, size } = {}) { + largeImageURL(options = {}) { if (!this.largeImage) return null; if (this.largeImage.includes(':')) { const [platform, id] = this.largeImage.split(':'); @@ -391,10 +388,7 @@ class RichPresenceAssets { } } - return this.activity.presence.client.rest.cdn.AppAsset(this.activity.applicationId, this.largeImage, { - format, - size, - }); + return this.activity.presence.client.rest.cdn.AppAsset(this.activity.applicationId, this.largeImage, options); } } diff --git a/packages/discord.js/src/structures/Role.js b/packages/discord.js/src/structures/Role.js index 1a9b93054..90a1f6faa 100644 --- a/packages/discord.js/src/structures/Role.js +++ b/packages/discord.js/src/structures/Role.js @@ -391,12 +391,11 @@ class Role extends Base { /** * A link to the role's icon - * @param {StaticImageURLOptions} [options={}] Options for the image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - iconURL({ format, size } = {}) { - if (!this.icon) return null; - return this.client.rest.cdn.RoleIcon(this.id, this.icon, format, size); + iconURL(options = {}) { + return this.icon && this.client.rest.cdn.RoleIcon(this.id, this.icon, options); } /** diff --git a/packages/discord.js/src/structures/StickerPack.js b/packages/discord.js/src/structures/StickerPack.js index 66df3245b..d5458bbb4 100644 --- a/packages/discord.js/src/structures/StickerPack.js +++ b/packages/discord.js/src/structures/StickerPack.js @@ -84,11 +84,11 @@ class StickerPack extends Base { /** * The URL to this sticker pack's banner. - * @param {StaticImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - bannerURL({ format, size } = {}) { - return this.bannerId && this.client.rest.cdn.StickerPackBanner(this.bannerId, format, size); + bannerURL(options = {}) { + return this.bannerId && this.client.rest.cdn.StickerPackBanner(this.bannerId, options); } } diff --git a/packages/discord.js/src/structures/Team.js b/packages/discord.js/src/structures/Team.js index 7c3d39c2d..773b661ca 100644 --- a/packages/discord.js/src/structures/Team.js +++ b/packages/discord.js/src/structures/Team.js @@ -90,12 +90,11 @@ class Team extends Base { /** * A link to the team's icon. - * @param {StaticImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - iconURL({ format, size } = {}) { - if (!this.icon) return null; - return this.client.rest.cdn.TeamIcon(this.id, this.icon, { format, size }); + iconURL(options = {}) { + return this.icon && this.client.rest.cdn.TeamIcon(this.id, this.icon, options); } /** diff --git a/packages/discord.js/src/structures/User.js b/packages/discord.js/src/structures/User.js index 38c206795..cc0ebe1d3 100644 --- a/packages/discord.js/src/structures/User.js +++ b/packages/discord.js/src/structures/User.js @@ -140,12 +140,11 @@ class User extends Base { /** * A link to the user's avatar. - * @param {ImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - avatarURL({ format, size, dynamic } = {}) { - if (!this.avatar) return null; - return this.client.rest.cdn.Avatar(this.id, this.avatar, format, size, dynamic); + avatarURL(options = {}) { + return this.avatar && this.client.rest.cdn.Avatar(this.id, this.avatar, options); } /** @@ -180,12 +179,11 @@ class User extends Base { /** * A link to the user's banner. See {@link User#banner} for more info - * @param {ImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - bannerURL({ format, size, dynamic } = {}) { - if (!this.banner) return this.banner; - return this.client.rest.cdn.Banner(this.id, this.banner, format, size, dynamic); + bannerURL(options = {}) { + return this.banner && this.client.rest.cdn.Banner(this.id, this.banner, options); } /** diff --git a/packages/discord.js/src/structures/Webhook.js b/packages/discord.js/src/structures/Webhook.js index 69a27e768..457c0fb79 100644 --- a/packages/discord.js/src/structures/Webhook.js +++ b/packages/discord.js/src/structures/Webhook.js @@ -403,12 +403,11 @@ class Webhook { /** * A link to the webhook's avatar. - * @param {StaticImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - avatarURL({ format, size } = {}) { - if (!this.avatar) return null; - return this.client.rest.cdn.Avatar(this.id, this.avatar, format, size); + avatarURL(options = {}) { + return this.avatar && this.client.rest.cdn.Avatar(this.id, this.avatar, options); } /** diff --git a/packages/discord.js/src/structures/interfaces/Application.js b/packages/discord.js/src/structures/interfaces/Application.js index 5d29d165f..feba1b1bc 100644 --- a/packages/discord.js/src/structures/interfaces/Application.js +++ b/packages/discord.js/src/structures/interfaces/Application.js @@ -1,7 +1,6 @@ 'use strict'; const { DiscordSnowflake } = require('@sapphire/snowflake'); -const { Endpoints } = require('../../util/Constants'); const Base = require('../Base'); /** @@ -72,22 +71,20 @@ class Application extends Base { /** * A link to the application's icon. - * @param {StaticImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - iconURL({ format, size } = {}) { - if (!this.icon) return null; - return this.client.rest.cdn.AppIcon(this.id, this.icon, { format, size }); + iconURL(options = {}) { + return this.icon && this.client.rest.cdn.AppIcon(this.id, this.icon, options); } /** * A link to this application's cover image. - * @param {StaticImageURLOptions} [options={}] Options for the Image URL + * @param {ImageURLOptions} [options={}] Options for the image URL * @returns {?string} */ - coverURL({ format, size } = {}) { - if (!this.cover) return null; - return Endpoints.CDN(this.client.options.http.cdn).AppIcon(this.id, this.cover, { format, size }); + coverURL(options = {}) { + return this.cover && this.client.rest.cdn.AppIcon(this.id, this.cover, options); } /** diff --git a/packages/discord.js/src/util/Constants.js b/packages/discord.js/src/util/Constants.js index 7b149923c..153b069a8 100644 --- a/packages/discord.js/src/util/Constants.js +++ b/packages/discord.js/src/util/Constants.js @@ -15,68 +15,76 @@ exports.WSCodes = { 4014: 'DISALLOWED_INTENTS', }; -const AllowedImageFormats = ['webp', 'png', 'jpg', 'jpeg', 'gif']; +const AllowedImageFormats = ['webp', 'png', 'jpg', 'jpeg']; const AllowedImageSizes = [16, 32, 56, 64, 96, 128, 256, 300, 512, 600, 1024, 2048, 4096]; -function makeImageUrl(root, { format = 'webp', size } = {}) { +function makeImageUrl(root, { hash, format = 'webp', forceStatic = false, size } = {}) { if (!['undefined', 'number'].includes(typeof size)) throw new TypeError('INVALID_TYPE', 'size', 'number'); - if (format && !AllowedImageFormats.includes(format)) throw new Error('IMAGE_FORMAT', format); + if (!AllowedImageFormats.includes(format)) throw new Error('IMAGE_FORMAT', format); if (size && !AllowedImageSizes.includes(size)) throw new RangeError('IMAGE_SIZE', size); - return `${root}.${format}${size ? `?size=${size}` : ''}`; + if (!forceStatic && hash?.startsWith('a_')) format = 'gif'; + return `${root}${hash ? `/${hash}` : ''}.${format}${size ? `?size=${size}` : ''}`; } /** - * Options for Image URLs. - * @typedef {StaticImageURLOptions} ImageURLOptions - * @property {boolean} [dynamic=false] If true, the format will dynamically change to `gif` for animated avatars. + * A list of image sizes: + * * `16` + * * `32` + * * `56` + * * `64` + * * `96` + * * `128` + * * `256` + * * `300` + * * `512` + * * `600` + * * `1024` + * * `2048` + * * `4096` + * @typedef {number} ImageSize */ /** - * Options for static Image URLs. - * @typedef {Object} StaticImageURLOptions - * @property {string} [format='webp'] One of `webp`, `png`, `jpg`, `jpeg`. - * @property {number} [size] One of `16`, `32`, `56`, `64`, `96`, `128`, `256`, `300`, `512`, `600`, `1024`, `2048`, - * `4096` + * A list of image formats: + * * `webp` + * * `png` + * * `jpg` + * * `jpeg` + * @typedef {string} ImageFormat + */ + +/** + * Options for image URLs. + * @typedef {Object} ImageURLOptions + * @property {ImageFormat} [format='webp'] An image format. + * @property {boolean} [forceStatic=false] If `true`, the format will be as specified. + * If `false`, `format` may be a `gif` if animated. + * @property {ImageSize} [size] An image size. */ // https://discord.com/developers/docs/reference#image-formatting-cdn-endpoints exports.Endpoints = { CDN(root) { return { - Emoji: (emojiId, format = 'webp') => `${root}/emojis/${emojiId}.${format}`, - Asset: name => `${root}/assets/${name}`, + Emoji: (emojiId, format) => `${root}/emojis/${emojiId}.${format}`, DefaultAvatar: discriminator => `${root}/embed/avatars/${discriminator}.png`, - Avatar: (userId, hash, format, size, dynamic = false) => { - if (dynamic && hash.startsWith('a_')) format = 'gif'; - return makeImageUrl(`${root}/avatars/${userId}/${hash}`, { format, size }); - }, - GuildMemberAvatar: (guildId, memberId, hash, format = 'webp', size, dynamic = false) => { - if (dynamic && hash.startsWith('a_')) format = 'gif'; - return makeImageUrl(`${root}/guilds/${guildId}/users/${memberId}/avatars/${hash}`, { format, size }); - }, - Banner: (id, hash, format, size, dynamic = false) => { - if (dynamic && hash.startsWith('a_')) format = 'gif'; - return makeImageUrl(`${root}/banners/${id}/${hash}`, { format, size }); - }, - Icon: (guildId, hash, format, size, dynamic = false) => { - if (dynamic && hash.startsWith('a_')) format = 'gif'; - return makeImageUrl(`${root}/icons/${guildId}/${hash}`, { format, size }); - }, - AppIcon: (appId, hash, options) => makeImageUrl(`${root}/app-icons/${appId}/${hash}`, options), - AppAsset: (appId, hash, options) => makeImageUrl(`${root}/app-assets/${appId}/${hash}`, options), - StickerPackBanner: (bannerId, format, size) => - makeImageUrl(`${root}/app-assets/710982414301790216/store/${bannerId}`, { size, format }), - GDMIcon: (channelId, hash, format, size) => - makeImageUrl(`${root}/channel-icons/${channelId}/${hash}`, { size, format }), - Splash: (guildId, hash, format, size) => makeImageUrl(`${root}/splashes/${guildId}/${hash}`, { size, format }), - DiscoverySplash: (guildId, hash, format, size) => - makeImageUrl(`${root}/discovery-splashes/${guildId}/${hash}`, { size, format }), - TeamIcon: (teamId, hash, options) => makeImageUrl(`${root}/team-icons/${teamId}/${hash}`, options), - Sticker: (stickerId, stickerFormat) => - `${root}/stickers/${stickerId}.${stickerFormat === 'LOTTIE' ? 'json' : 'png'}`, - RoleIcon: (roleId, hash, format = 'webp', size) => - makeImageUrl(`${root}/role-icons/${roleId}/${hash}`, { size, format }), + Avatar: (userId, hash, options) => makeImageUrl(`${root}/avatars/${userId}`, { hash, ...options }), + GuildMemberAvatar: (guildId, memberId, hash, options) => + makeImageUrl(`${root}/guilds/${guildId}/users/${memberId}/avatars`, { hash, ...options }), + Banner: (id, hash, options) => makeImageUrl(`${root}/banners/${id}`, { hash, ...options }), + Icon: (guildId, hash, options) => makeImageUrl(`${root}/icons/${guildId}`, { hash, ...options }), + AppIcon: (appId, hash, options) => makeImageUrl(`${root}/app-icons/${appId}`, { hash, ...options }), + AppAsset: (appId, hash, options) => makeImageUrl(`${root}/app-assets/${appId}`, { hash, ...options }), + StickerPackBanner: (bannerId, options) => + makeImageUrl(`${root}/app-assets/710982414301790216/store/${bannerId}`, options), + GDMIcon: (channelId, hash, options) => makeImageUrl(`${root}/channel-icons/${channelId}`, { hash, ...options }), + Splash: (guildId, hash, options) => makeImageUrl(`${root}/splashes/${guildId}`, { hash, ...options }), + DiscoverySplash: (guildId, hash, options) => + makeImageUrl(`${root}/discovery-splashes/${guildId}`, { hash, ...options }), + TeamIcon: (teamId, hash, options) => makeImageUrl(`${root}/team-icons/${teamId}`, { hash, ...options }), + Sticker: (stickerId, format) => `${root}/stickers/${stickerId}.${format === 'LOTTIE' ? 'json' : 'png'}`, + RoleIcon: (roleId, hash, options) => makeImageUrl(`${root}/role-icons/${roleId}`, { hash, ...options }), }; }, invite: (root, code, eventId) => (eventId ? `${root}/${code}?event=${eventId}` : `${root}/${code}`), diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 2af371602..49ee82fe6 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -188,8 +188,8 @@ export abstract class AnonymousGuild extends BaseGuild { public splash: string | null; public vanityURLCode: string | null; public verificationLevel: GuildVerificationLevelKey; - public bannerURL(options?: StaticImageURLOptions): string | null; - public splashURL(options?: StaticImageURLOptions): string | null; + public bannerURL(options?: ImageURLOptions): string | null; + public splashURL(options?: ImageURLOptions): string | null; } export abstract class Application extends Base { @@ -200,8 +200,8 @@ export abstract class Application extends Base { public icon: string | null; public id: Snowflake; public name: string | null; - public coverURL(options?: StaticImageURLOptions): string | null; - public iconURL(options?: StaticImageURLOptions): string | null; + public coverURL(options?: ImageURLOptions): string | null; + public iconURL(options?: ImageURLOptions): string | null; public toJSON(): unknown; public toString(): string | null; } @@ -923,7 +923,7 @@ export class Guild extends AnonymousGuild { public readonly maximumBitrate: number; public createTemplate(name: string, description?: string): Promise; public delete(): Promise; - public discoverySplashURL(options?: StaticImageURLOptions): string | null; + public discoverySplashURL(options?: ImageURLOptions): string | null; public edit(data: GuildEditData, reason?: string): Promise; public editWelcomeScreen(data: WelcomeScreenEditData): Promise; public equals(guild: Guild): boolean; @@ -1139,9 +1139,9 @@ export class GuildPreview extends Base { public id: Snowflake; public name: string; public splash: string | null; - public discoverySplashURL(options?: StaticImageURLOptions): string | null; + public discoverySplashURL(options?: ImageURLOptions): string | null; public iconURL(options?: ImageURLOptions): string | null; - public splashURL(options?: StaticImageURLOptions): string | null; + public splashURL(options?: ImageURLOptions): string | null; public fetch(): Promise; public toJSON(): unknown; public toString(): string; @@ -1817,7 +1817,7 @@ export class PartialGroupDMChannel extends Channel { public name: string | null; public icon: string | null; public recipients: PartialRecipient[]; - public iconURL(options?: StaticImageURLOptions): string | null; + public iconURL(options?: ImageURLOptions): string | null; } export class PermissionOverwrites extends Base { @@ -1905,8 +1905,8 @@ export class RichPresenceAssets { public largeText: string | null; public smallImage: Snowflake | null; public smallText: string | null; - public largeImageURL(options?: StaticImageURLOptions): string | null; - public smallImageURL(options?: StaticImageURLOptions): string | null; + public largeImageURL(options?: ImageURLOptions): string | null; + public smallImageURL(options?: ImageURLOptions): string | null; } export class Role extends Base { @@ -1933,7 +1933,7 @@ export class Role extends Base { public delete(reason?: string): Promise; public edit(data: RoleData, reason?: string): Promise; public equals(role: Role): boolean; - public iconURL(options?: StaticImageURLOptions): string | null; + public iconURL(options?: ImageURLOptions): string | null; public permissionsIn(channel: NonThreadGuildBasedChannel | Snowflake, checkAdmin?: boolean): Readonly; public setColor(color: ColorResolvable, reason?: string): Promise; public setHoist(hoist?: boolean, reason?: string): Promise; @@ -2150,7 +2150,7 @@ export class StickerPack extends Base { public name: string; public skuId: Snowflake; public stickers: Collection; - public bannerURL(options?: StaticImageURLOptions): string | null; + public bannerURL(options?: ImageURLOptions): string | null; } /** @deprecated See [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) for more information */ @@ -2243,7 +2243,7 @@ export class Team extends Base { public readonly createdAt: Date; public readonly createdTimestamp: number; - public iconURL(options?: StaticImageURLOptions): string | null; + public iconURL(options?: ImageURLOptions): string | null; public toJSON(): unknown; public toString(): string; } @@ -2503,7 +2503,7 @@ export class VoiceState extends Base { export class Webhook extends WebhookMixin() { private constructor(client: Client, data?: RawWebhookData); public avatar: string; - public avatarURL(options?: StaticImageURLOptions): string | null; + public avatarURL(options?: ImageURLOptions): string | null; public channelId: Snowflake; public client: Client; public guildId: Snowflake; @@ -2704,59 +2704,22 @@ export const Constants: { invite: (root: string, code: string, eventId?: Snowflake) => string; scheduledEvent: (root: string, guildId: Snowflake, eventId: Snowflake) => string; CDN: (root: string) => { - Emoji: (emojiId: Snowflake, format: DynamicImageFormat) => string; + Emoji: (emojiId: Snowflake, format: 'gif' | 'png') => string; Asset: (name: string) => string; DefaultAvatar: (discriminator: number) => string; - Avatar: ( - userId: Snowflake, - hash: string, - format: DynamicImageFormat, - size: AllowedImageSize, - dynamic: boolean, - ) => string; - Banner: ( - id: Snowflake, - hash: string, - format: DynamicImageFormat, - size: AllowedImageSize, - dynamic: boolean, - ) => string; - GuildMemberAvatar: ( - guildId: Snowflake, - memberId: Snowflake, - hash: string, - format?: DynamicImageFormat, - size?: AllowedImageSize, - dynamic?: boolean, - ) => string; - Icon: ( - guildId: Snowflake, - hash: string, - format: DynamicImageFormat, - size: AllowedImageSize, - dynamic: boolean, - ) => string; - AppIcon: ( - appId: Snowflake, - hash: string, - { format, size }: { format: AllowedImageFormat; size: AllowedImageSize }, - ) => string; - AppAsset: ( - appId: Snowflake, - hash: string, - { format, size }: { format: AllowedImageFormat; size: AllowedImageSize }, - ) => string; - StickerPackBanner: (bannerId: Snowflake, format: AllowedImageFormat, size: AllowedImageSize) => string; - GDMIcon: (channelId: Snowflake, hash: string, format: AllowedImageFormat, size: AllowedImageSize) => string; - Splash: (guildId: Snowflake, hash: string, format: AllowedImageFormat, size: AllowedImageSize) => string; - DiscoverySplash: (guildId: Snowflake, hash: string, format: AllowedImageFormat, size: AllowedImageSize) => string; - TeamIcon: ( - teamId: Snowflake, - hash: string, - { format, size }: { format: AllowedImageFormat; size: AllowedImageSize }, - ) => string; - Sticker: (stickerId: Snowflake, stickerFormat: StickerFormatType) => string; - RoleIcon: (roleId: Snowflake, hash: string, format: AllowedImageFormat, size: AllowedImageSize) => string; + Avatar: (userId: Snowflake, hash: string, options: ImageURLOptions) => string; + Banner: (id: Snowflake, hash: string, options: ImageURLOptions) => string; + GuildMemberAvatar: (guildId: Snowflake, memberId: Snowflake, hash: string, options: ImageURLOptions) => string; + Icon: (guildId: Snowflake, hash: string, options: ImageURLOptions) => string; + AppIcon: (appId: Snowflake, hash: string, options: ImageURLOptions) => string; + AppAsset: (appId: Snowflake, hash: string, options: ImageURLOptions) => string; + StickerPackBanner: (bannerId: Snowflake, options: ImageURLOptions) => string; + GDMIcon: (channelId: Snowflake, hash: string, options: ImageURLOptions) => string; + Splash: (guildId: Snowflake, hash: string, options: ImageURLOptions) => string; + DiscoverySplash: (guildId: Snowflake, hash: string, options: ImageURLOptions) => string; + TeamIcon: (teamId: Snowflake, hash: string, options: ImageURLOptions) => string; + Sticker: (stickerId: Snowflake, format: StickerFormatType) => string; + RoleIcon: (roleId: Snowflake, hash: string, options: ImageURLOptions) => string; }; }; WSCodes: { @@ -4056,8 +4019,6 @@ export type DateResolvable = Date | number | string; export type GuildDefaultMessageNotificationsKey = keyof typeof GuildDefaultMessageNotifications; -export type DynamicImageFormat = AllowedImageFormat | 'gif'; - export interface EditGuildTemplateOptions { name?: string; description?: string; @@ -4612,9 +4573,10 @@ export interface HTTPOptions { scheduledEvent?: string; } -export interface ImageURLOptions extends Omit { - dynamic?: boolean; - format?: DynamicImageFormat; +export interface ImageURLOptions { + format?: AllowedImageFormat; + forceStatic?: boolean; + size?: AllowedImageSize; } export interface IntegrationAccount { @@ -5230,11 +5192,6 @@ export interface SplitOptions { append?: string; } -export interface StaticImageURLOptions { - format?: AllowedImageFormat; - size?: AllowedImageSize; -} - export type StageInstanceResolvable = StageInstance | Snowflake; export interface StartThreadOptions {