diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js index 6e00c654e..adf0356b8 100644 --- a/src/structures/ClientApplication.js +++ b/src/structures/ClientApplication.js @@ -2,13 +2,13 @@ const Snowflake = require('../util/Snowflake'); const Constants = require('../util/Constants'); /** - * Represents an OAuth2 Application. + * Represents a Client OAuth2 Application. */ -class OAuth2Application { +class ClientApplication { constructor(client, data) { /** * The client that instantiated the application - * @name OAuth2Application#client + * @name ClientApplication#client * @type {Client} * @readonly */ @@ -42,6 +42,12 @@ class OAuth2Application { */ this.icon = data.icon; + /** + * The app's cover image hash + * @type {?string} + */ + this.cover = data.cover_image; + /** * The app's RPC origins * @type {?string[]} @@ -129,6 +135,20 @@ class OAuth2Application { return Constants.Endpoints.CDN(this.client.options.http.cdn).AppIcon(this.id, this.icon, { format, size }); } + /** + * A link to this application's cover image + * @param {Object} [options={}] Options for the cover image url + * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg` + * @param {number} [options.size=128] One of `128`, '256', `512`, `1024`, `2048` + * @returns {?string} URL to the cover image + */ + coverImage({ format, size } = {}) { + if (!this.cover) return null; + return Constants.Endpoints + .CDN(this.client.options.http.cdn) + .AppIcon(this.id, this.cover, { format, size }); + } + /** * Get rich presence assets * @returns {Promise} @@ -165,7 +185,7 @@ class OAuth2Application { */ resetSecret() { return this.client.api.oauth2.applications[this.id].reset.post() - .then(app => new OAuth2Application(this.client, app)); + .then(app => new ClientApplication(this.client, app)); } /** @@ -175,7 +195,7 @@ class OAuth2Application { */ resetToken() { return this.client.api.oauth2.applications[this.id].bot.reset.post() - .then(app => new OAuth2Application(this.client, Object.assign({}, this, { bot: app }))); + .then(app => new ClientApplication(this.client, Object.assign({}, this, { bot: app }))); } /** @@ -187,4 +207,4 @@ class OAuth2Application { } } -module.exports = OAuth2Application; +module.exports = ClientApplication;