From 577ab37a2b5adedaa31e8896a96d0a540f8de726 Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Wed, 7 Jun 2017 23:47:17 +0200 Subject: [PATCH] make User#displayAvatarURL a method and make it and avatarURL accept an options object (#1569) * make User#displayAvatarURL a method * make avatarURL and displayAvatarURL accept an object as options --- src/structures/User.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/structures/User.js b/src/structures/User.js index 08056184c..9faae8d88 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -105,12 +105,13 @@ class User { /** * A link to the user's avatar - * @param {string} [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} [size=128] One of `128`, '256', `512`, `1024`, `2048` - * @returns {?string} avatarURL + * @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` + * @returns {?string} */ - avatarURL(format, size) { + avatarURL({ format, size } = {}) { if (!this.avatar) return null; if (typeof format === 'number') { size = format; @@ -130,11 +131,14 @@ class User { /** * A link to the user's avatar if they have one. Otherwise a link to their default avatar will be returned - * @type {string} - * @readonly + * @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` + * @returns {string} */ - get displayAvatarURL() { - return this.avatarURL() || this.defaultAvatarURL; + displayAvatarURL(options) { + return this.avatarURL(options) || this.defaultAvatarURL; } /**