From 669c379a62d7edea0a5c0c559c40431030a5ab1b Mon Sep 17 00:00:00 2001 From: hydrabolt Date: Wed, 26 Aug 2015 13:05:13 +0100 Subject: [PATCH] Fixed self resolveDestination Allows much better message sending from different methods, less bloaty --- lib/Client.js | 6 ++---- src/Client.js | 7 ++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/Client.js b/lib/Client.js index 467651f1e..c11c5a19c 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -543,11 +543,9 @@ var Client = (function () { message = premessage + resolveMessage(message); var mentions = resolveMentions(); - destination = self.resolveDestination(destination); + self.resolveDestination(destination).then(send)["catch"](reject); - if (destination) send(); - - function send() { + function send(destination) { request.post(Endpoints.CHANNELS + "/" + destination + "/messages").set("authorization", self.token).send({ content: message, diff --git a/src/Client.js b/src/Client.js index 5cfd2e44a..bcaad81a7 100644 --- a/src/Client.js +++ b/src/Client.js @@ -555,12 +555,9 @@ class Client { message = premessage + resolveMessage(message); var mentions = resolveMentions(); - destination = self.resolveDestination(destination); + self.resolveDestination(destination).then(send).catch(reject); - if (destination) - send(); - - function send() { + function send(destination) { request .post(`${Endpoints.CHANNELS}/${destination}/messages`)