new application stuff very hype (#1764)

* application stuff, more to come

* docstrings

* Update Message.js
This commit is contained in:
Gus Caplan
2017-08-11 10:09:06 -07:00
committed by Crawl
parent 3c7869c1b7
commit 3ba224900f
5 changed files with 65 additions and 24 deletions

View File

@@ -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()],
} }));
}
/**

View File

@@ -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}