mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 13:03:31 +01:00
Fixed acknowledging of channels (#1411)
* Fixed acknowledging of channels * using channel#lastMessageID and resolve when it's not present
This commit is contained in:
@@ -159,7 +159,9 @@ class RESTMethods {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ackTextChannel(channel) {
|
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;
|
if (res.token) this._ackToken = res.token;
|
||||||
return channel;
|
return channel;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -385,7 +385,8 @@ class TextBasedChannel {
|
|||||||
* @returns {Promise<TextChannel|GroupDMChannel|DMChannel>}
|
* @returns {Promise<TextChannel|GroupDMChannel|DMChannel>}
|
||||||
*/
|
*/
|
||||||
acknowledge() {
|
acknowledge() {
|
||||||
return this.client.rest.methods.ackTextMessage(this);
|
if (!this.lastMessageID) return Promise.resolve(this);
|
||||||
|
return this.client.rest.methods.ackTextChannel(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
_cacheMessage(message) {
|
_cacheMessage(message) {
|
||||||
@@ -480,6 +481,7 @@ exports.applyToClass = (structure, full = false, ignore = []) => {
|
|||||||
if (full) {
|
if (full) {
|
||||||
props.push(
|
props.push(
|
||||||
'_cacheMessage',
|
'_cacheMessage',
|
||||||
|
'acknowledge',
|
||||||
'fetchMessages',
|
'fetchMessages',
|
||||||
'fetchMessage',
|
'fetchMessage',
|
||||||
'search',
|
'search',
|
||||||
|
|||||||
@@ -155,7 +155,6 @@ const Endpoints = exports.Endpoints = {
|
|||||||
permissions: `${base}/permissions`,
|
permissions: `${base}/permissions`,
|
||||||
webhooks: `${base}/webhooks`,
|
webhooks: `${base}/webhooks`,
|
||||||
search: `${base}/messages/search`,
|
search: `${base}/messages/search`,
|
||||||
ack: `${base}/ack`,
|
|
||||||
pins: `${base}/pins`,
|
pins: `${base}/pins`,
|
||||||
Pin: messageID => `${base}/pins/${messageID}`,
|
Pin: messageID => `${base}/pins/${messageID}`,
|
||||||
Recipient: recipientID => `${base}/recipients/${recipientID}`,
|
Recipient: recipientID => `${base}/recipients/${recipientID}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user