From 909b825c94e4872b1f766b570bae384dc494a266 Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Tue, 25 Apr 2017 23:29:08 +0200 Subject: [PATCH] Fixed acknowledging of channels (#1411) * Fixed acknowledging of channels * using channel#lastMessageID and resolve when it's not present --- src/client/rest/RESTMethods.js | 4 +++- src/structures/interfaces/TextBasedChannel.js | 4 +++- src/util/Constants.js | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/client/rest/RESTMethods.js b/src/client/rest/RESTMethods.js index 15d65d67f..d40e9aa3a 100644 --- a/src/client/rest/RESTMethods.js +++ b/src/client/rest/RESTMethods.js @@ -159,7 +159,9 @@ class RESTMethods { } ackTextChannel(channel) { - return this.rest.makeRequest('post', Endpoints.Channel(channel).ack, true, { token: this._ackToken }).then(res => { + return this.rest.makeRequest('post', Endpoints.Channel(channel).Message(channel.lastMessageID).ack, true, { + token: this._ackToken, + }).then(res => { if (res.token) this._ackToken = res.token; return channel; }); diff --git a/src/structures/interfaces/TextBasedChannel.js b/src/structures/interfaces/TextBasedChannel.js index 79ba34b1e..8eec647db 100644 --- a/src/structures/interfaces/TextBasedChannel.js +++ b/src/structures/interfaces/TextBasedChannel.js @@ -385,7 +385,8 @@ class TextBasedChannel { * @returns {Promise} */ acknowledge() { - return this.client.rest.methods.ackTextMessage(this); + if (!this.lastMessageID) return Promise.resolve(this); + return this.client.rest.methods.ackTextChannel(this); } _cacheMessage(message) { @@ -480,6 +481,7 @@ exports.applyToClass = (structure, full = false, ignore = []) => { if (full) { props.push( '_cacheMessage', + 'acknowledge', 'fetchMessages', 'fetchMessage', 'search', diff --git a/src/util/Constants.js b/src/util/Constants.js index db3892600..3230ea612 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -155,7 +155,6 @@ const Endpoints = exports.Endpoints = { permissions: `${base}/permissions`, webhooks: `${base}/webhooks`, search: `${base}/messages/search`, - ack: `${base}/ack`, pins: `${base}/pins`, Pin: messageID => `${base}/pins/${messageID}`, Recipient: recipientID => `${base}/recipients/${recipientID}`,