mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
new application stuff very hype (#1764)
* application stuff, more to come * docstrings * Update Message.js
This commit is contained in:
@@ -126,7 +126,36 @@ class OAuth2Application {
|
||||
*/
|
||||
iconURL({ format, size } = {}) {
|
||||
if (!this.icon) return null;
|
||||
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 });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rich presence assets
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
fetchAssets() {
|
||||
return this.client.api.applications(this.id).assets.get()
|
||||
.then(assets => assets.map(a => ({
|
||||
id: a.id,
|
||||
name: a.name,
|
||||
type: Object.keys(Constants.ClientApplicationAssetTypes)[a.type - 1],
|
||||
})));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a rich presence asset
|
||||
* @param {string} name Name of the asset
|
||||
* @param {Base64Resolvable} data Data of the asset
|
||||
* @param {string} type Type of the asset. `big`, or `small`
|
||||
* @returns {Promise}
|
||||
*/
|
||||
createAsset(name, data, type) {
|
||||
return this.client.resolveBase64(data).then(b64 =>
|
||||
this.client.api.applications(this.id).assets.post({ data: {
|
||||
name,
|
||||
data: b64,
|
||||
type: Constants.ClientApplicationAssetTypes[type.toUpperCase()],
|
||||
} }));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3,6 +3,7 @@ const Attachment = require('./MessageAttachment');
|
||||
const Embed = require('./MessageEmbed');
|
||||
const MessageReaction = require('./MessageReaction');
|
||||
const ReactionCollector = require('./ReactionCollector');
|
||||
const ClientApplication = require('./ClientApplication');
|
||||
const Util = require('../util/Util');
|
||||
const Collection = require('../util/Collection');
|
||||
const Constants = require('../util/Constants');
|
||||
@@ -137,6 +138,21 @@ class Message {
|
||||
*/
|
||||
this.webhookID = data.webhook_id || null;
|
||||
|
||||
/**
|
||||
* Supplimental application information for group activities
|
||||
* @type {?ClientApplication}
|
||||
*/
|
||||
this.application = data.application ? new ClientApplication(this.client, data.application) : null;
|
||||
|
||||
/**
|
||||
* Group activity
|
||||
* @type {?Object}
|
||||
*/
|
||||
this.activiy = data.activity ? {
|
||||
partyID: data.activity.party_id,
|
||||
type: data.activity.type,
|
||||
} : null;
|
||||
|
||||
/**
|
||||
* Whether this message is a hit in a search
|
||||
* @type {?boolean}
|
||||
|
||||
Reference in New Issue
Block a user