mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
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:
committed by
Schuyler Cebulskie
parent
ee3a03f707
commit
27270a3bad
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user