diff --git a/src/client/rest/RESTMethods.js b/src/client/rest/RESTMethods.js index 5f0e063ab..b9898016d 100644 --- a/src/client/rest/RESTMethods.js +++ b/src/client/rest/RESTMethods.js @@ -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); } diff --git a/src/structures/Message.js b/src/structures/Message.js index 0f053f324..8831d3f4d 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -340,9 +340,16 @@ class Message { return this.mentions.users.has(data) || this.mentions.channels.has(data) || this.mentions.roles.has(data); } + /** + * Options that can be passed into editMessage + * @typedef {Object} MessageEditOptions + * @property {Object} [embed] An embed to be added/edited + */ + /** * Edit the content of the message * @param {StringResolvable} content The new content for the message + * @param {MessageEditOptions} [options={}] The options to provide * @returns {Promise} * @example * // update the content of a message @@ -350,8 +357,8 @@ class Message { * .then(msg => console.log(`Updated the content of a message from ${msg.author}`)) * .catch(console.error); */ - edit(content) { - return this.client.rest.methods.updateMessage(this, content); + edit(content, options = {}) { + return this.client.rest.methods.updateMessage(this, content, options); } /** diff --git a/src/structures/interface/TextBasedChannel.js b/src/structures/interface/TextBasedChannel.js index fba4442b1..d622dcabe 100644 --- a/src/structures/interface/TextBasedChannel.js +++ b/src/structures/interface/TextBasedChannel.js @@ -28,6 +28,8 @@ class TextBasedChannel { * @typedef {Object} MessageOptions * @property {boolean} [tts=false] Whether or not the message should be spoken aloud * @property {string} [nonce=''] The nonce for the message + * @property {Object} [embed] An embed for the message + * (see [here](https://discordapp.com/developers/docs/resources/channel#embed-object) for more details) * @property {boolean} [disableEveryone=this.client.options.disableEveryone] Whether or not @everyone and @here * should be replaced with plain-text * @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if