From e9f2d6c4d2ab896391a72dafdc9b3110474f2c35 Mon Sep 17 00:00:00 2001 From: Roki <35699619+Roki100@users.noreply.github.com> Date: Tue, 7 Apr 2020 05:11:22 +0200 Subject: [PATCH 1/4] add 4096 avatar size that discord supports --- src/util/Constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/Constants.js b/src/util/Constants.js index baad5308461c..67959e27856c 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -100,7 +100,7 @@ exports.WSCodes = { const AllowedImageFormats = ['webp', 'png', 'jpg', '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 } = {}) { if (format && !AllowedImageFormats.includes(format)) throw new Error('IMAGE_FORMAT', format); From dc886122f56d5c10ac38b611d1fb7fe284e75de3 Mon Sep 17 00:00:00 2001 From: Roki <35699619+Roki100@users.noreply.github.com> Date: Tue, 7 Apr 2020 05:27:37 +0200 Subject: [PATCH 2/4] jpeg is also a thing --- src/util/Constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/Constants.js b/src/util/Constants.js index 67959e27856c..8ec34a712767 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -98,7 +98,7 @@ exports.WSCodes = { 4014: 'DISALLOWED_INTENTS', }; -const AllowedImageFormats = ['webp', 'png', 'jpg', 'gif']; +const AllowedImageFormats = ['webp', 'png', 'jpg', 'jpeg', 'gif']; const AllowedImageSizes = Array.from({ length: 9 }, (e, i) => 2 ** (i + 4)); From c628492f34281c2f8ba7d386c42c8efb21b3add6 Mon Sep 17 00:00:00 2001 From: Roki <35699619+Roki100@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:02:43 +0200 Subject: [PATCH 3/4] update jsdocs --- src/util/Constants.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/Constants.js b/src/util/Constants.js index 8ec34a712767..b3c23914d8f3 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -110,11 +110,11 @@ function makeImageUrl(root, { format = 'webp', size } = {}) { /** * Options for Image URLs. * @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`. * @property {boolean} [dynamic] If true, the format will dynamically change to `gif` for * 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 = { From 1e613006d300c7fe0277a7afc5fbe0f3df10b4bc Mon Sep 17 00:00:00 2001 From: Roki <35699619+Roki100@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:08:22 +0200 Subject: [PATCH 4/4] update typings and remove duplicate type --- typings/index.d.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 0d43e8708dd5..9e6aea833a2d 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -269,7 +269,7 @@ declare module 'discord.js' { public once(event: 'end', listener: (collected: Collection, reason: string) => void): this; } - type AllowedImageFormat = 'webp' | 'png' | 'jpg' | 'gif'; + type AllowedImageFormat = 'webp' | 'png' | 'jpg' | 'jpeg' | 'gif'; export const Constants: { Package: { @@ -2543,12 +2543,10 @@ declare module 'discord.js' { invite?: string; } - type ImageExt = 'webp' | 'png' | 'jpg' | 'gif'; - - type ImageSize = 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048; + type ImageSize = 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096; interface ImageURLOptions { - format?: ImageExt; + format?: AllowedImageFormat; size?: ImageSize; }