mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user