mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
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:
@@ -1,4 +1,5 @@
|
||||
const Snowflake = require('../util/Snowflake');
|
||||
const Constants = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents an OAuth2 Application.
|
||||
@@ -41,12 +42,6 @@ class OAuth2Application {
|
||||
*/
|
||||
this.icon = data.icon;
|
||||
|
||||
/**
|
||||
* The app's icon URL
|
||||
* @type {string}
|
||||
*/
|
||||
this.iconURL = `https://cdn.discordapp.com/app-icons/${this.id}/${this.icon}.jpg`;
|
||||
|
||||
/**
|
||||
* The app's RPC origins
|
||||
* @type {?string[]}
|
||||
@@ -122,6 +117,21 @@ class OAuth2Application {
|
||||
return new Date(this.createdTimestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* A link to the application'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} URL to the icon
|
||||
*/
|
||||
iconURL(format, size) {
|
||||
if (!this.icon) return null;
|
||||
if (typeof format === 'number') {
|
||||
size = format;
|
||||
format = 'default';
|
||||
}
|
||||
return Constants.Endpoints.CDN(this.client.options.http.cdn).AppIcon(this.id, this.icon, format, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the app's secret and bot token.
|
||||
* @returns {OAuth2Application}
|
||||
|
||||
Reference in New Issue
Block a user