mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 02:53:31 +01:00
feat: add supported 4096 image size and jpeg format (#4031)
* add 4096 avatar size that discord supports * jpeg is also a thing * update jsdocs * update typings and remove duplicate type
This commit is contained in:
@@ -98,9 +98,9 @@ exports.WSCodes = {
|
|||||||
4014: 'DISALLOWED_INTENTS',
|
4014: 'DISALLOWED_INTENTS',
|
||||||
};
|
};
|
||||||
|
|
||||||
const AllowedImageFormats = ['webp', 'png', 'jpg', 'gif'];
|
const AllowedImageFormats = ['webp', 'png', 'jpg', 'jpeg', 'gif'];
|
||||||
|
|
||||||
const AllowedImageSizes = Array.from({ length: 8 }, (e, i) => 2 ** (i + 4));
|
const AllowedImageSizes = Array.from({ length: 9 }, (e, i) => 2 ** (i + 4));
|
||||||
|
|
||||||
function makeImageUrl(root, { format = 'webp', size } = {}) {
|
function makeImageUrl(root, { format = 'webp', size } = {}) {
|
||||||
if (format && !AllowedImageFormats.includes(format)) throw new Error('IMAGE_FORMAT', format);
|
if (format && !AllowedImageFormats.includes(format)) throw new Error('IMAGE_FORMAT', format);
|
||||||
@@ -110,11 +110,11 @@ function makeImageUrl(root, { format = 'webp', size } = {}) {
|
|||||||
/**
|
/**
|
||||||
* Options for Image URLs.
|
* Options for Image URLs.
|
||||||
* @typedef {Object} ImageURLOptions
|
* @typedef {Object} ImageURLOptions
|
||||||
* @property {string} [format] One of `webp`, `png`, `jpg`, `gif`. If no format is provided,
|
* @property {string} [format] One of `webp`, `png`, `jpg`, `jpeg`, `gif`. If no format is provided,
|
||||||
* defaults to `webp`.
|
* defaults to `webp`.
|
||||||
* @property {boolean} [dynamic] If true, the format will dynamically change to `gif` for
|
* @property {boolean} [dynamic] If true, the format will dynamically change to `gif` for
|
||||||
* animated avatars; the default is false.
|
* animated avatars; the default is false.
|
||||||
* @property {number} [size] One of `16`, `32`, `64`, `128`, `256`, `512`, `1024`, `2048`
|
* @property {number} [size] One of `16`, `32`, `64`, `128`, `256`, `512`, `1024`, `2048`, `4096`
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.Endpoints = {
|
exports.Endpoints = {
|
||||||
|
|||||||
8
typings/index.d.ts
vendored
8
typings/index.d.ts
vendored
@@ -269,7 +269,7 @@ declare module 'discord.js' {
|
|||||||
public once(event: 'end', listener: (collected: Collection<K, V>, reason: string) => void): this;
|
public once(event: 'end', listener: (collected: Collection<K, V>, reason: string) => void): this;
|
||||||
}
|
}
|
||||||
|
|
||||||
type AllowedImageFormat = 'webp' | 'png' | 'jpg' | 'gif';
|
type AllowedImageFormat = 'webp' | 'png' | 'jpg' | 'jpeg' | 'gif';
|
||||||
|
|
||||||
export const Constants: {
|
export const Constants: {
|
||||||
Package: {
|
Package: {
|
||||||
@@ -2542,12 +2542,10 @@ declare module 'discord.js' {
|
|||||||
invite?: string;
|
invite?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type ImageExt = 'webp' | 'png' | 'jpg' | 'gif';
|
type ImageSize = 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096;
|
||||||
|
|
||||||
type ImageSize = 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048;
|
|
||||||
|
|
||||||
interface ImageURLOptions {
|
interface ImageURLOptions {
|
||||||
format?: ImageExt;
|
format?: AllowedImageFormat;
|
||||||
size?: ImageSize;
|
size?: ImageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user