Quality of life changes (#968)

* + Added function to get a user's default avatar
+ Added HOST constant to Constants
+ Added assets endpoint
+ Added quality of life function to get a user's avatar or default avatar
+ Added quality of life function to get member's nickname or username

* * Fixed invocation of a getter.

* Fixed lint issue

* Made the API constant use the HOST constant for DRY-ness
Changed DOC comment to be more descriptive

* Update GuildMember.js
This commit is contained in:
Cole
2016-12-12 21:34:19 -06:00
committed by Schuyler Cebulskie
parent 3193df792e
commit 586d652c16
3 changed files with 40 additions and 1 deletions

View File

@@ -104,6 +104,26 @@ class User {
return Constants.Endpoints.avatar(this.id, this.avatar);
}
/**
* A link to the user's default avatar
* @type {string}
* @readonly
*/
get defaultAvatarURL() {
let defaultAvatars = Object.values(Constants.DefaultAvatars);
let defaultAvatar = this.discriminator % defaultAvatars.length;
return Constants.endpoints.assets(`${defaultAvatars[defaultAvatar]}.png`);
}
/**
* A link to the user's avatar if they have one. Otherwise a link to their default avatar will be returned
* @type {string}
* @readonly
*/
get displayAvatarURL() {
return this.avatarURL || this.defaultAvatarURL;
}
/**
* The note that is set for the user
* <warn>This is only available when using a user account.</warn>