From c46cbbfd8464714dbea0ed4364821ac7efbbccfe Mon Sep 17 00:00:00 2001 From: PLASMAchicken Date: Thu, 26 Jul 2018 03:04:47 +0200 Subject: [PATCH] docs: added sizes 16, 32, 64 (#2666) * documented sizes 16, 32, 64 * Removed space * Added typedef * The options to provide => Options for the Image URL * fixed --- src/structures/ClientApplication.js | 8 ++------ src/structures/GroupDMChannel.js | 4 +--- src/structures/Guild.js | 8 ++------ src/structures/User.js | 10 ++-------- src/util/Constants.js | 7 +++++++ 5 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js index f76e98b0a..b884dfd11 100644 --- a/src/structures/ClientApplication.js +++ b/src/structures/ClientApplication.js @@ -121,9 +121,7 @@ class ClientApplication extends Base { /** * A link to the application's icon. - * @param {Object} [options={}] Options for the icon url - * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg` - * @param {number} [options.size=128] One of `128`, `256`, `512`, `1024`, `2048` + * @param {ImageURLOptions} [options={}] Options for the Image URL * @returns {?string} URL to the icon */ iconURL({ format, size } = {}) { @@ -133,9 +131,7 @@ class ClientApplication extends Base { /** * A link to this application's cover image. - * @param {Object} [options={}] Options for the cover image url - * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg` - * @param {number} [options.size=128] One of `128`, `256`, `512`, `1024`, `2048` + * @param {ImageURLOptions} [options={}] Options for the Image URL * @returns {?string} URL to the cover image */ coverImage({ format, size } = {}) { diff --git a/src/structures/GroupDMChannel.js b/src/structures/GroupDMChannel.js index 14ceeae5d..d67d33ad2 100644 --- a/src/structures/GroupDMChannel.js +++ b/src/structures/GroupDMChannel.js @@ -116,9 +116,7 @@ class GroupDMChannel extends Channel { /** * Gets the URL to this Group DM's icon. - * @param {Object} [options={}] Options for the icon url - * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg` - * @param {number} [options.size=128] One of `128`, `256`, `512`, `1024`, `2048` + * @param {ImageURLOptions} [options={}] Options for the Image URL * @returns {?string} */ iconURL({ format, size } = {}) { diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 17ceaba89..812250630 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -288,9 +288,7 @@ class Guild extends Base { /** * The URL to this guild's icon. - * @param {Object} [options={}] Options for the icon url - * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg` - * @param {number} [options.size=128] One of `128`, `256`, `512`, `1024`, `2048` + * @param {ImageURLOptions} [options={}] Options for the Image URL * @returns {?string} */ iconURL({ format, size } = {}) { @@ -309,9 +307,7 @@ class Guild extends Base { /** * The URL to this guild's splash. - * @param {Object} [options={}] Options for the splash url - * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg` - * @param {number} [options.size=128] One of `128`, `256`, `512`, `1024`, `2048` + * @param {ImageURLOptions} [options={}] Options for the Image URL * @returns {?string} */ splashURL({ format, size } = {}) { diff --git a/src/structures/User.js b/src/structures/User.js index da36de7bb..e020d288a 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -115,10 +115,7 @@ class User extends Base { /** * A link to the user's avatar. - * @param {Object} [options={}] Options for the avatar url - * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg`, `gif`. If no format is provided, - * it will be `gif` for animated avatars or otherwise `webp` - * @param {number} [options.size=128] One of `128`, `256`, `512`, `1024`, `2048` + * @param {ImageURLOptions} [options={}] Options for the Image URL * @returns {?string} */ avatarURL({ format, size } = {}) { @@ -138,10 +135,7 @@ class User extends Base { /** * A link to the user's avatar if they have one. * Otherwise a link to their default avatar will be returned. - * @param {Object} [options={}] Options for the avatar url - * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg`, `gif`. If no format is provided, - * it will be `gif` for animated avatars or otherwise `webp` - * @param {number} [options.size=128] One of `128`, `256`, `512`, `1024`, `2048` + * @param {ImageURLOptions} [options={}] Options for the Image URL * @returns {string} */ displayAvatarURL(options) { diff --git a/src/util/Constants.js b/src/util/Constants.js index 79f95881b..4c381e4d6 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -111,6 +111,13 @@ function makeImageUrl(root, { format = 'webp', size } = {}) { if (size && !AllowedImageSizes.includes(size)) throw new RangeError('IMAGE_SIZE', size); return `${root}.${format}${size ? `?size=${size}` : ''}`; } +/** + * Options for Image URLs. + * @typedef {Object} ImageURLOptions + * @property {string} [format] One of `webp`, `png`, `jpg`, `gif`. If no format is provided, + * it will be `gif` for animated avatars or otherwise `webp` + * @property {number} [size] One of `16`, `32`, `64`, `128`, `256`, `512`, `1024`, `2048` + */ exports.Endpoints = { CDN(root) {