Add Guild#nameAcronym and make avatar/iconURLs into functions (#1144)

* Guild#iconURL(format, size);
* OAuth2Application#iconURL(format, size);
* User#iconURL(format, size);
This commit is contained in:
Gus Caplan
2017-05-01 14:37:00 -05:00
committed by Amish Shah
parent 3bab4ec9fd
commit 35ef9cd33d
4 changed files with 82 additions and 21 deletions

View File

@@ -253,13 +253,27 @@ class Guild {
}
/**
* The URL to this guild's icon
* @type {?string}
* Gets the URL to this guild's icon
* @param {string} [format='webp'] One of `webp`, `png`, `jpg`, `gif`
* @param {number} [size=128] One of `128`, '256', `512`, `1024`, `2048`
* @returns {?string}
*/
iconURL(format, size) {
if (!this.icon) return null;
if (typeof format === 'number') {
size = format;
format = 'default';
}
return Constants.Endpoints.Guild(this).Icon(this.client.options.http.cdn, this.icon, format, size);
}
/**
* Gets the acronym that shows up in place of a guild icon
* @type {string}
* @readonly
*/
get iconURL() {
if (!this.icon) return null;
return Constants.Endpoints.Guild(this).Icon(this.client.options.http.cdn, this.icon);
get nameAcronym() {
return this.name.replace(/\w+/g, name => name[0]).replace(/\s/g, '');
}
/**