mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
refactor: Default *URL methods to animated hash (#7149)
Co-authored-by: Jan <66554238+vaporox@users.noreply.github.com>
This commit is contained in:
@@ -68,20 +68,20 @@ class AnonymousGuild extends BaseGuild {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL to this guild's banner.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
bannerURL({ format, size } = {}) {
|
bannerURL(options = {}) {
|
||||||
return this.banner && this.client.rest.cdn.Banner(this.id, this.banner, format, size);
|
return this.banner && this.client.rest.cdn.Banner(this.id, this.banner, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL to this guild's invite splash image.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
splashURL({ format, size } = {}) {
|
splashURL(options = {}) {
|
||||||
return this.splash && this.client.rest.cdn.Splash(this.id, this.splash, format, size);
|
return this.splash && this.client.rest.cdn.Splash(this.id, this.splash, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,12 +87,11 @@ class BaseGuild extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL to this guild's icon.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
iconURL({ format, size, dynamic } = {}) {
|
iconURL(options = {}) {
|
||||||
if (!this.icon) return null;
|
return this.icon && this.client.rest.cdn.Icon(this.id, this.icon, options);
|
||||||
return this.client.rest.cdn.Icon(this.id, this.icon, format, size, dynamic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -480,11 +480,11 @@ class Guild extends AnonymousGuild {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL to this guild's discovery splash image.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
discoverySplashURL({ format, size } = {}) {
|
discoverySplashURL(options = {}) {
|
||||||
return this.discoverySplash && this.client.rest.cdn.DiscoverySplash(this.id, this.discoverySplash, format, size);
|
return this.discoverySplash && this.client.rest.cdn.DiscoverySplash(this.id, this.discoverySplash, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -123,12 +123,11 @@ class GuildMember extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A link to the member's guild avatar.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
avatarURL({ format, size, dynamic } = {}) {
|
avatarURL(options = {}) {
|
||||||
if (!this.avatar) return null;
|
return this.avatar && this.client.rest.cdn.GuildMemberAvatar(this.guild.id, this.id, this.avatar, options);
|
||||||
return this.client.rest.cdn.GuildMemberAvatar(this.guild.id, this.id, this.avatar, format, size, dynamic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -124,29 +124,29 @@ class GuildPreview extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL to this guild's splash.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
splashURL({ format, size } = {}) {
|
splashURL(options = {}) {
|
||||||
return this.splash && this.client.rest.cdn.Splash(this.id, this.splash, format, size);
|
return this.splash && this.client.rest.cdn.Splash(this.id, this.splash, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL to this guild's discovery splash.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
discoverySplashURL({ format, size } = {}) {
|
discoverySplashURL(options = {}) {
|
||||||
return this.discoverySplash && this.client.rest.cdn.DiscoverySplash(this.id, this.discoverySplash, format, size);
|
return this.discoverySplash && this.client.rest.cdn.DiscoverySplash(this.id, this.discoverySplash, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL to this guild's icon.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
iconURL({ format, size, dynamic } = {}) {
|
iconURL(options = {}) {
|
||||||
return this.icon && this.client.rest.cdn.Icon(this.id, this.icon, format, size, dynamic);
|
return this.icon && this.client.rest.cdn.Icon(this.id, this.icon, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -38,11 +38,11 @@ class PartialGroupDMChannel extends Channel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL to this channel's icon.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
iconURL({ format, size } = {}) {
|
iconURL(options = {}) {
|
||||||
return this.icon && this.client.rest.cdn.GDMIcon(this.id, this.icon, format, size);
|
return this.icon && this.client.rest.cdn.GDMIcon(this.id, this.icon, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete() {
|
delete() {
|
||||||
|
|||||||
@@ -347,10 +347,10 @@ class RichPresenceAssets {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the URL of the small image asset
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
smallImageURL({ format, size } = {}) {
|
smallImageURL(options = {}) {
|
||||||
if (!this.smallImage) return null;
|
if (!this.smallImage) return null;
|
||||||
if (this.smallImage.includes(':')) {
|
if (this.smallImage.includes(':')) {
|
||||||
const [platform, id] = this.smallImage.split(':');
|
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, {
|
return this.activity.presence.client.rest.cdn.AppAsset(this.activity.applicationId, this.smallImage, options);
|
||||||
format,
|
|
||||||
size,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the URL of the large image asset
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
largeImageURL({ format, size } = {}) {
|
largeImageURL(options = {}) {
|
||||||
if (!this.largeImage) return null;
|
if (!this.largeImage) return null;
|
||||||
if (this.largeImage.includes(':')) {
|
if (this.largeImage.includes(':')) {
|
||||||
const [platform, id] = this.largeImage.split(':');
|
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, {
|
return this.activity.presence.client.rest.cdn.AppAsset(this.activity.applicationId, this.largeImage, options);
|
||||||
format,
|
|
||||||
size,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -391,12 +391,11 @@ class Role extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A link to the role's icon
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
iconURL({ format, size } = {}) {
|
iconURL(options = {}) {
|
||||||
if (!this.icon) return null;
|
return this.icon && this.client.rest.cdn.RoleIcon(this.id, this.icon, options);
|
||||||
return this.client.rest.cdn.RoleIcon(this.id, this.icon, format, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -84,11 +84,11 @@ class StickerPack extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL to this sticker pack's banner.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
bannerURL({ format, size } = {}) {
|
bannerURL(options = {}) {
|
||||||
return this.bannerId && this.client.rest.cdn.StickerPackBanner(this.bannerId, format, size);
|
return this.bannerId && this.client.rest.cdn.StickerPackBanner(this.bannerId, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,12 +90,11 @@ class Team extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A link to the team's icon.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
iconURL({ format, size } = {}) {
|
iconURL(options = {}) {
|
||||||
if (!this.icon) return null;
|
return this.icon && this.client.rest.cdn.TeamIcon(this.id, this.icon, options);
|
||||||
return this.client.rest.cdn.TeamIcon(this.id, this.icon, { format, size });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -140,12 +140,11 @@ class User extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A link to the user's avatar.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
avatarURL({ format, size, dynamic } = {}) {
|
avatarURL(options = {}) {
|
||||||
if (!this.avatar) return null;
|
return this.avatar && this.client.rest.cdn.Avatar(this.id, this.avatar, options);
|
||||||
return this.client.rest.cdn.Avatar(this.id, this.avatar, format, size, dynamic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -180,12 +179,11 @@ class User extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A link to the user's banner. See {@link User#banner} for more info
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
bannerURL({ format, size, dynamic } = {}) {
|
bannerURL(options = {}) {
|
||||||
if (!this.banner) return this.banner;
|
return this.banner && this.client.rest.cdn.Banner(this.id, this.banner, options);
|
||||||
return this.client.rest.cdn.Banner(this.id, this.banner, format, size, dynamic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -403,12 +403,11 @@ class Webhook {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A link to the webhook's avatar.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
avatarURL({ format, size } = {}) {
|
avatarURL(options = {}) {
|
||||||
if (!this.avatar) return null;
|
return this.avatar && this.client.rest.cdn.Avatar(this.id, this.avatar, options);
|
||||||
return this.client.rest.cdn.Avatar(this.id, this.avatar, format, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
const { Endpoints } = require('../../util/Constants');
|
|
||||||
const Base = require('../Base');
|
const Base = require('../Base');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,22 +71,20 @@ class Application extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A link to the application's icon.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
iconURL({ format, size } = {}) {
|
iconURL(options = {}) {
|
||||||
if (!this.icon) return null;
|
return this.icon && this.client.rest.cdn.AppIcon(this.id, this.icon, options);
|
||||||
return this.client.rest.cdn.AppIcon(this.id, this.icon, { format, size });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A link to this application's cover image.
|
* 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}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
coverURL({ format, size } = {}) {
|
coverURL(options = {}) {
|
||||||
if (!this.cover) return null;
|
return this.cover && this.client.rest.cdn.AppIcon(this.id, this.cover, options);
|
||||||
return Endpoints.CDN(this.client.options.http.cdn).AppIcon(this.id, this.cover, { format, size });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -15,68 +15,76 @@ exports.WSCodes = {
|
|||||||
4014: 'DISALLOWED_INTENTS',
|
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];
|
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 (!['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);
|
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.
|
* A list of image sizes:
|
||||||
* @typedef {StaticImageURLOptions} ImageURLOptions
|
* * `16`
|
||||||
* @property {boolean} [dynamic=false] If true, the format will dynamically change to `gif` for animated avatars.
|
* * `32`
|
||||||
|
* * `56`
|
||||||
|
* * `64`
|
||||||
|
* * `96`
|
||||||
|
* * `128`
|
||||||
|
* * `256`
|
||||||
|
* * `300`
|
||||||
|
* * `512`
|
||||||
|
* * `600`
|
||||||
|
* * `1024`
|
||||||
|
* * `2048`
|
||||||
|
* * `4096`
|
||||||
|
* @typedef {number} ImageSize
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for static Image URLs.
|
* A list of image formats:
|
||||||
* @typedef {Object} StaticImageURLOptions
|
* * `webp`
|
||||||
* @property {string} [format='webp'] One of `webp`, `png`, `jpg`, `jpeg`.
|
* * `png`
|
||||||
* @property {number} [size] One of `16`, `32`, `56`, `64`, `96`, `128`, `256`, `300`, `512`, `600`, `1024`, `2048`,
|
* * `jpg`
|
||||||
* `4096`
|
* * `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
|
// https://discord.com/developers/docs/reference#image-formatting-cdn-endpoints
|
||||||
exports.Endpoints = {
|
exports.Endpoints = {
|
||||||
CDN(root) {
|
CDN(root) {
|
||||||
return {
|
return {
|
||||||
Emoji: (emojiId, format = 'webp') => `${root}/emojis/${emojiId}.${format}`,
|
Emoji: (emojiId, format) => `${root}/emojis/${emojiId}.${format}`,
|
||||||
Asset: name => `${root}/assets/${name}`,
|
|
||||||
DefaultAvatar: discriminator => `${root}/embed/avatars/${discriminator}.png`,
|
DefaultAvatar: discriminator => `${root}/embed/avatars/${discriminator}.png`,
|
||||||
Avatar: (userId, hash, format, size, dynamic = false) => {
|
Avatar: (userId, hash, options) => makeImageUrl(`${root}/avatars/${userId}`, { hash, ...options }),
|
||||||
if (dynamic && hash.startsWith('a_')) format = 'gif';
|
GuildMemberAvatar: (guildId, memberId, hash, options) =>
|
||||||
return makeImageUrl(`${root}/avatars/${userId}/${hash}`, { format, size });
|
makeImageUrl(`${root}/guilds/${guildId}/users/${memberId}/avatars`, { hash, ...options }),
|
||||||
},
|
Banner: (id, hash, options) => makeImageUrl(`${root}/banners/${id}`, { hash, ...options }),
|
||||||
GuildMemberAvatar: (guildId, memberId, hash, format = 'webp', size, dynamic = false) => {
|
Icon: (guildId, hash, options) => makeImageUrl(`${root}/icons/${guildId}`, { hash, ...options }),
|
||||||
if (dynamic && hash.startsWith('a_')) format = 'gif';
|
AppIcon: (appId, hash, options) => makeImageUrl(`${root}/app-icons/${appId}`, { hash, ...options }),
|
||||||
return makeImageUrl(`${root}/guilds/${guildId}/users/${memberId}/avatars/${hash}`, { format, size });
|
AppAsset: (appId, hash, options) => makeImageUrl(`${root}/app-assets/${appId}`, { hash, ...options }),
|
||||||
},
|
StickerPackBanner: (bannerId, options) =>
|
||||||
Banner: (id, hash, format, size, dynamic = false) => {
|
makeImageUrl(`${root}/app-assets/710982414301790216/store/${bannerId}`, options),
|
||||||
if (dynamic && hash.startsWith('a_')) format = 'gif';
|
GDMIcon: (channelId, hash, options) => makeImageUrl(`${root}/channel-icons/${channelId}`, { hash, ...options }),
|
||||||
return makeImageUrl(`${root}/banners/${id}/${hash}`, { format, size });
|
Splash: (guildId, hash, options) => makeImageUrl(`${root}/splashes/${guildId}`, { hash, ...options }),
|
||||||
},
|
DiscoverySplash: (guildId, hash, options) =>
|
||||||
Icon: (guildId, hash, format, size, dynamic = false) => {
|
makeImageUrl(`${root}/discovery-splashes/${guildId}`, { hash, ...options }),
|
||||||
if (dynamic && hash.startsWith('a_')) format = 'gif';
|
TeamIcon: (teamId, hash, options) => makeImageUrl(`${root}/team-icons/${teamId}`, { hash, ...options }),
|
||||||
return makeImageUrl(`${root}/icons/${guildId}/${hash}`, { format, size });
|
Sticker: (stickerId, format) => `${root}/stickers/${stickerId}.${format === 'LOTTIE' ? 'json' : 'png'}`,
|
||||||
},
|
RoleIcon: (roleId, hash, options) => makeImageUrl(`${root}/role-icons/${roleId}`, { 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, 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 }),
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
invite: (root, code, eventId) => (eventId ? `${root}/${code}?event=${eventId}` : `${root}/${code}`),
|
invite: (root, code, eventId) => (eventId ? `${root}/${code}?event=${eventId}` : `${root}/${code}`),
|
||||||
|
|||||||
107
packages/discord.js/typings/index.d.ts
vendored
107
packages/discord.js/typings/index.d.ts
vendored
@@ -188,8 +188,8 @@ export abstract class AnonymousGuild extends BaseGuild {
|
|||||||
public splash: string | null;
|
public splash: string | null;
|
||||||
public vanityURLCode: string | null;
|
public vanityURLCode: string | null;
|
||||||
public verificationLevel: GuildVerificationLevelKey;
|
public verificationLevel: GuildVerificationLevelKey;
|
||||||
public bannerURL(options?: StaticImageURLOptions): string | null;
|
public bannerURL(options?: ImageURLOptions): string | null;
|
||||||
public splashURL(options?: StaticImageURLOptions): string | null;
|
public splashURL(options?: ImageURLOptions): string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class Application extends Base {
|
export abstract class Application extends Base {
|
||||||
@@ -200,8 +200,8 @@ export abstract class Application extends Base {
|
|||||||
public icon: string | null;
|
public icon: string | null;
|
||||||
public id: Snowflake;
|
public id: Snowflake;
|
||||||
public name: string | null;
|
public name: string | null;
|
||||||
public coverURL(options?: StaticImageURLOptions): string | null;
|
public coverURL(options?: ImageURLOptions): string | null;
|
||||||
public iconURL(options?: StaticImageURLOptions): string | null;
|
public iconURL(options?: ImageURLOptions): string | null;
|
||||||
public toJSON(): unknown;
|
public toJSON(): unknown;
|
||||||
public toString(): string | null;
|
public toString(): string | null;
|
||||||
}
|
}
|
||||||
@@ -923,7 +923,7 @@ export class Guild extends AnonymousGuild {
|
|||||||
public readonly maximumBitrate: number;
|
public readonly maximumBitrate: number;
|
||||||
public createTemplate(name: string, description?: string): Promise<GuildTemplate>;
|
public createTemplate(name: string, description?: string): Promise<GuildTemplate>;
|
||||||
public delete(): Promise<Guild>;
|
public delete(): Promise<Guild>;
|
||||||
public discoverySplashURL(options?: StaticImageURLOptions): string | null;
|
public discoverySplashURL(options?: ImageURLOptions): string | null;
|
||||||
public edit(data: GuildEditData, reason?: string): Promise<Guild>;
|
public edit(data: GuildEditData, reason?: string): Promise<Guild>;
|
||||||
public editWelcomeScreen(data: WelcomeScreenEditData): Promise<WelcomeScreen>;
|
public editWelcomeScreen(data: WelcomeScreenEditData): Promise<WelcomeScreen>;
|
||||||
public equals(guild: Guild): boolean;
|
public equals(guild: Guild): boolean;
|
||||||
@@ -1139,9 +1139,9 @@ export class GuildPreview extends Base {
|
|||||||
public id: Snowflake;
|
public id: Snowflake;
|
||||||
public name: string;
|
public name: string;
|
||||||
public splash: string | null;
|
public splash: string | null;
|
||||||
public discoverySplashURL(options?: StaticImageURLOptions): string | null;
|
public discoverySplashURL(options?: ImageURLOptions): string | null;
|
||||||
public iconURL(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<GuildPreview>;
|
public fetch(): Promise<GuildPreview>;
|
||||||
public toJSON(): unknown;
|
public toJSON(): unknown;
|
||||||
public toString(): string;
|
public toString(): string;
|
||||||
@@ -1817,7 +1817,7 @@ export class PartialGroupDMChannel extends Channel {
|
|||||||
public name: string | null;
|
public name: string | null;
|
||||||
public icon: string | null;
|
public icon: string | null;
|
||||||
public recipients: PartialRecipient[];
|
public recipients: PartialRecipient[];
|
||||||
public iconURL(options?: StaticImageURLOptions): string | null;
|
public iconURL(options?: ImageURLOptions): string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PermissionOverwrites extends Base {
|
export class PermissionOverwrites extends Base {
|
||||||
@@ -1905,8 +1905,8 @@ export class RichPresenceAssets {
|
|||||||
public largeText: string | null;
|
public largeText: string | null;
|
||||||
public smallImage: Snowflake | null;
|
public smallImage: Snowflake | null;
|
||||||
public smallText: string | null;
|
public smallText: string | null;
|
||||||
public largeImageURL(options?: StaticImageURLOptions): string | null;
|
public largeImageURL(options?: ImageURLOptions): string | null;
|
||||||
public smallImageURL(options?: StaticImageURLOptions): string | null;
|
public smallImageURL(options?: ImageURLOptions): string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Role extends Base {
|
export class Role extends Base {
|
||||||
@@ -1933,7 +1933,7 @@ export class Role extends Base {
|
|||||||
public delete(reason?: string): Promise<Role>;
|
public delete(reason?: string): Promise<Role>;
|
||||||
public edit(data: RoleData, reason?: string): Promise<Role>;
|
public edit(data: RoleData, reason?: string): Promise<Role>;
|
||||||
public equals(role: Role): boolean;
|
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<Permissions>;
|
public permissionsIn(channel: NonThreadGuildBasedChannel | Snowflake, checkAdmin?: boolean): Readonly<Permissions>;
|
||||||
public setColor(color: ColorResolvable, reason?: string): Promise<Role>;
|
public setColor(color: ColorResolvable, reason?: string): Promise<Role>;
|
||||||
public setHoist(hoist?: boolean, reason?: string): Promise<Role>;
|
public setHoist(hoist?: boolean, reason?: string): Promise<Role>;
|
||||||
@@ -2150,7 +2150,7 @@ export class StickerPack extends Base {
|
|||||||
public name: string;
|
public name: string;
|
||||||
public skuId: Snowflake;
|
public skuId: Snowflake;
|
||||||
public stickers: Collection<Snowflake, Sticker>;
|
public stickers: Collection<Snowflake, Sticker>;
|
||||||
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 */
|
/** @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 createdAt: Date;
|
||||||
public readonly createdTimestamp: number;
|
public readonly createdTimestamp: number;
|
||||||
|
|
||||||
public iconURL(options?: StaticImageURLOptions): string | null;
|
public iconURL(options?: ImageURLOptions): string | null;
|
||||||
public toJSON(): unknown;
|
public toJSON(): unknown;
|
||||||
public toString(): string;
|
public toString(): string;
|
||||||
}
|
}
|
||||||
@@ -2503,7 +2503,7 @@ export class VoiceState extends Base {
|
|||||||
export class Webhook extends WebhookMixin() {
|
export class Webhook extends WebhookMixin() {
|
||||||
private constructor(client: Client, data?: RawWebhookData);
|
private constructor(client: Client, data?: RawWebhookData);
|
||||||
public avatar: string;
|
public avatar: string;
|
||||||
public avatarURL(options?: StaticImageURLOptions): string | null;
|
public avatarURL(options?: ImageURLOptions): string | null;
|
||||||
public channelId: Snowflake;
|
public channelId: Snowflake;
|
||||||
public client: Client;
|
public client: Client;
|
||||||
public guildId: Snowflake;
|
public guildId: Snowflake;
|
||||||
@@ -2704,59 +2704,22 @@ export const Constants: {
|
|||||||
invite: (root: string, code: string, eventId?: Snowflake) => string;
|
invite: (root: string, code: string, eventId?: Snowflake) => string;
|
||||||
scheduledEvent: (root: string, guildId: Snowflake, eventId: Snowflake) => string;
|
scheduledEvent: (root: string, guildId: Snowflake, eventId: Snowflake) => string;
|
||||||
CDN: (root: string) => {
|
CDN: (root: string) => {
|
||||||
Emoji: (emojiId: Snowflake, format: DynamicImageFormat) => string;
|
Emoji: (emojiId: Snowflake, format: 'gif' | 'png') => string;
|
||||||
Asset: (name: string) => string;
|
Asset: (name: string) => string;
|
||||||
DefaultAvatar: (discriminator: number) => string;
|
DefaultAvatar: (discriminator: number) => string;
|
||||||
Avatar: (
|
Avatar: (userId: Snowflake, hash: string, options: ImageURLOptions) => string;
|
||||||
userId: Snowflake,
|
Banner: (id: Snowflake, hash: string, options: ImageURLOptions) => string;
|
||||||
hash: string,
|
GuildMemberAvatar: (guildId: Snowflake, memberId: Snowflake, hash: string, options: ImageURLOptions) => string;
|
||||||
format: DynamicImageFormat,
|
Icon: (guildId: Snowflake, hash: string, options: ImageURLOptions) => string;
|
||||||
size: AllowedImageSize,
|
AppIcon: (appId: Snowflake, hash: string, options: ImageURLOptions) => string;
|
||||||
dynamic: boolean,
|
AppAsset: (appId: Snowflake, hash: string, options: ImageURLOptions) => string;
|
||||||
) => string;
|
StickerPackBanner: (bannerId: Snowflake, options: ImageURLOptions) => string;
|
||||||
Banner: (
|
GDMIcon: (channelId: Snowflake, hash: string, options: ImageURLOptions) => string;
|
||||||
id: Snowflake,
|
Splash: (guildId: Snowflake, hash: string, options: ImageURLOptions) => string;
|
||||||
hash: string,
|
DiscoverySplash: (guildId: Snowflake, hash: string, options: ImageURLOptions) => string;
|
||||||
format: DynamicImageFormat,
|
TeamIcon: (teamId: Snowflake, hash: string, options: ImageURLOptions) => string;
|
||||||
size: AllowedImageSize,
|
Sticker: (stickerId: Snowflake, format: StickerFormatType) => string;
|
||||||
dynamic: boolean,
|
RoleIcon: (roleId: Snowflake, hash: string, options: ImageURLOptions) => string;
|
||||||
) => 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;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
WSCodes: {
|
WSCodes: {
|
||||||
@@ -4056,8 +4019,6 @@ export type DateResolvable = Date | number | string;
|
|||||||
|
|
||||||
export type GuildDefaultMessageNotificationsKey = keyof typeof GuildDefaultMessageNotifications;
|
export type GuildDefaultMessageNotificationsKey = keyof typeof GuildDefaultMessageNotifications;
|
||||||
|
|
||||||
export type DynamicImageFormat = AllowedImageFormat | 'gif';
|
|
||||||
|
|
||||||
export interface EditGuildTemplateOptions {
|
export interface EditGuildTemplateOptions {
|
||||||
name?: string;
|
name?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
@@ -4612,9 +4573,10 @@ export interface HTTPOptions {
|
|||||||
scheduledEvent?: string;
|
scheduledEvent?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ImageURLOptions extends Omit<StaticImageURLOptions, 'format'> {
|
export interface ImageURLOptions {
|
||||||
dynamic?: boolean;
|
format?: AllowedImageFormat;
|
||||||
format?: DynamicImageFormat;
|
forceStatic?: boolean;
|
||||||
|
size?: AllowedImageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IntegrationAccount {
|
export interface IntegrationAccount {
|
||||||
@@ -5230,11 +5192,6 @@ export interface SplitOptions {
|
|||||||
append?: string;
|
append?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StaticImageURLOptions {
|
|
||||||
format?: AllowedImageFormat;
|
|
||||||
size?: AllowedImageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type StageInstanceResolvable = StageInstance | Snowflake;
|
export type StageInstanceResolvable = StageInstance | Snowflake;
|
||||||
|
|
||||||
export interface StartThreadOptions {
|
export interface StartThreadOptions {
|
||||||
|
|||||||
Reference in New Issue
Block a user