add embed support! (#894)

* add embed support!

* document message embeds

* make gawdl3y happy

* make edit great again

* make docs better

* Update Message.js

* Update TextBasedChannel.js

* Update TextBasedChannel.js
This commit is contained in:
Gus Caplan
2016-11-13 00:05:13 -06:00
committed by Schuyler Cebulskie
parent ee3a03f707
commit 27270a3bad
3 changed files with 19 additions and 10 deletions

View File

@@ -48,7 +48,7 @@ class RESTMethods {
return this.rest.makeRequest('get', Constants.Endpoints.botGateway, true);
}
sendMessage(channel, content, { tts, nonce, disableEveryone, split } = {}, file = null) {
sendMessage(channel, content, { tts, nonce, embed, disableEveryone, split } = {}, file = null) {
return new Promise((resolve, reject) => {
if (typeof content !== 'undefined') content = this.rest.client.resolver.resolveString(content);
@@ -62,15 +62,15 @@ class RESTMethods {
if (channel instanceof User || channel instanceof GuildMember) {
this.createDM(channel).then(chan => {
this._sendMessageRequest(chan, content, file, tts, nonce, resolve, reject);
this._sendMessageRequest(chan, content, file, tts, nonce, embed, resolve, reject);
}, reject);
} else {
this._sendMessageRequest(channel, content, file, tts, nonce, resolve, reject);
this._sendMessageRequest(channel, content, file, tts, nonce, embed, resolve, reject);
}
});
}
_sendMessageRequest(channel, content, file, tts, nonce, resolve, reject) {
_sendMessageRequest(channel, content, file, tts, nonce, embed, resolve, reject) {
if (content instanceof Array) {
const datas = [];
let promise = this.rest.makeRequest('post', Constants.Endpoints.channelMessages(channel.id), true, {
@@ -83,7 +83,7 @@ class RESTMethods {
promise = promise.then(data => {
datas.push(data);
return this.rest.makeRequest('post', Constants.Endpoints.channelMessages(channel.id), true, {
content: content[i2], tts, nonce,
content: content[i2], tts, nonce, embed,
}, file);
}, reject);
} else {
@@ -95,7 +95,7 @@ class RESTMethods {
}
} else {
this.rest.makeRequest('post', Constants.Endpoints.channelMessages(channel.id), true, {
content, tts, nonce,
content, tts, nonce, embed,
}, file)
.then(data => resolve(this.rest.client.actions.MessageCreate.handle(data).message), reject);
}
@@ -122,10 +122,10 @@ class RESTMethods {
);
}
updateMessage(message, content) {
updateMessage(message, content, { embed } = {}) {
content = this.rest.client.resolver.resolveString(content);
return this.rest.makeRequest('patch', Constants.Endpoints.channelMessage(message.channel.id, message.id), true, {
content,
content, embed,
}).then(data => this.rest.client.actions.MessageUpdate.handle(data).updated);
}