mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
add cover image (#1780)
* add cover image * Update ClientApplication.js
This commit is contained in:
@@ -2,13 +2,13 @@ const Snowflake = require('../util/Snowflake');
|
|||||||
const Constants = require('../util/Constants');
|
const Constants = require('../util/Constants');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an OAuth2 Application.
|
* Represents a Client OAuth2 Application.
|
||||||
*/
|
*/
|
||||||
class OAuth2Application {
|
class ClientApplication {
|
||||||
constructor(client, data) {
|
constructor(client, data) {
|
||||||
/**
|
/**
|
||||||
* The client that instantiated the application
|
* The client that instantiated the application
|
||||||
* @name OAuth2Application#client
|
* @name ClientApplication#client
|
||||||
* @type {Client}
|
* @type {Client}
|
||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
@@ -42,6 +42,12 @@ class OAuth2Application {
|
|||||||
*/
|
*/
|
||||||
this.icon = data.icon;
|
this.icon = data.icon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The app's cover image hash
|
||||||
|
* @type {?string}
|
||||||
|
*/
|
||||||
|
this.cover = data.cover_image;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The app's RPC origins
|
* The app's RPC origins
|
||||||
* @type {?string[]}
|
* @type {?string[]}
|
||||||
@@ -129,6 +135,20 @@ class OAuth2Application {
|
|||||||
return Constants.Endpoints.CDN(this.client.options.http.cdn).AppIcon(this.id, this.icon, { format, size });
|
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
|
* Get rich presence assets
|
||||||
* @returns {Promise<Object>}
|
* @returns {Promise<Object>}
|
||||||
@@ -165,7 +185,7 @@ class OAuth2Application {
|
|||||||
*/
|
*/
|
||||||
resetSecret() {
|
resetSecret() {
|
||||||
return this.client.api.oauth2.applications[this.id].reset.post()
|
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() {
|
resetToken() {
|
||||||
return this.client.api.oauth2.applications[this.id].bot.reset.post()
|
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user