refactor: remove duplicate send checks (#2790)

* re-direct pr code to master

* fix Webhook send docs

* requested changes

* typings: Updated to latest commit

* requested change

* requested change
This commit is contained in:
bdistin
2018-09-21 03:59:58 -05:00
committed by SpaceEEC
parent 8a6d029c00
commit 6d184257b3
5 changed files with 92 additions and 50 deletions

View File

@@ -359,7 +359,7 @@ class Message extends Base {
/**
* Edits the content of the message.
* @param {StringResolvable} [content=''] The new content for the message
* @param {StringResolvable|APIMessage} [content=''] The new content for the message
* @param {MessageEditOptions|MessageEmbed} [options] The options to provide
* @returns {Promise<Message>}
* @example
@@ -369,7 +369,9 @@ class Message extends Base {
* .catch(console.error);
*/
edit(content, options) {
const data = APIMessage.create(this, content, options).resolveData();
const { data } = content instanceof APIMessage ?
content.resolveData() :
APIMessage.create(this, content, options).resolveData();
return this.client.api.channels[this.channel.id].messages[this.id]
.patch({ data })
.then(d => {
@@ -458,7 +460,7 @@ class Message extends Base {
/**
* Replies to the message.
* @param {StringResolvable} [content=''] The content for the message
* @param {StringResolvable|APIMessage} [content=''] The content for the message
* @param {MessageOptions|MessageAdditions} [options={}] The options to provide
* @returns {Promise<Message|Message[]>}
* @example
@@ -468,7 +470,10 @@ class Message extends Base {
* .catch(console.error);
*/
reply(content, options) {
return this.channel.send(APIMessage.transformOptions(content, options, { reply: this.member || this.author }));
return this.channel.send(content instanceof APIMessage ?
content :
APIMessage.transformOptions(content, options, { reply: this.member || this.author })
);
}
/**