Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 4096 image size and jpeg format that discord supports #4031

Merged
merged 4 commits into from
Apr 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/util/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ exports.WSCodes = {
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 } = {}) {
if (format && !AllowedImageFormats.includes(format)) throw new Error('IMAGE_FORMAT', format);
Expand All @@ -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 = {
Expand Down
8 changes: 3 additions & 5 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ declare module 'discord.js' {
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: {
Package: {
Expand Down Expand Up @@ -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;
}

Expand Down