feat: Pin and unpin Chats (#166)

* Added Pinning
- chat.pin() to pin
- chat.unpin() to unpin

Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
This commit is contained in:
Aliyss Snow
2020-10-11 21:50:12 +02:00
committed by GitHub
parent bf2775d1f0
commit aedf41b762
4 changed files with 74 additions and 2 deletions

View File

@@ -57,6 +57,12 @@ class Chat extends Base {
*/
this.archived = data.archive;
/**
* Indicates if the Chat is pinned
* @type {boolean}
*/
this.pinned = !!data.pin;
/**
* Indicates if the chat is muted or not
* @type {number}
@@ -124,6 +130,22 @@ class Chat extends Base {
return this.client.unarchiveChat(this.id._serialized);
}
/**
* Pins this chat
* @returns {Promise<boolean>} New pin state. Could be false if the max number of pinned chats was reached.
*/
async pin() {
return this.client.pinChat(this.id._serialized);
}
/**
* Unpins this chat
* @returns {Promise<boolean>} New pin state
*/
async unpin() {
return this.client.unpinChat(this.id._serialized);
}
/**
* Mutes this chat until a specified date
* @param {Date} unmuteDate Date at which the Chat will be unmuted