feat: pin/unpin messages (#2692)
* feat: add Message.pin and Message.unpin methods * feat: added usage example * docs: clarifications
This commit is contained in:
parent
2100853727
commit
8d683a668b
1 changed files with 56 additions and 1 deletions
|
|
@ -522,6 +522,27 @@ class Message extends Base {
|
|||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pins the message (group admins can pin messages of all group members)
|
||||
* @param {number} duration The duration in seconds the message will be pinned in a chat
|
||||
* @returns {Promise<boolean>} Returns true if the operation completed successfully, false otherwise
|
||||
*/
|
||||
async pin(duration) {
|
||||
return await this.client.pupPage.evaluate(async (msgId, duration) => {
|
||||
return await window.WWebJS.pinUnpinMsgAction(msgId, 1, duration);
|
||||
}, this.id._serialized, duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpins the message (group admins can unpin messages of all group members)
|
||||
* @returns {Promise<boolean>} Returns true if the operation completed successfully, false otherwise
|
||||
*/
|
||||
async unpin() {
|
||||
return await this.client.pupPage.evaluate(async (msgId) => {
|
||||
return await window.WWebJS.pinUnpinMsgAction(msgId, 2);
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Message Info
|
||||
* @typedef {Object} MessageInfo
|
||||
|
|
|
|||
Loading…
Reference in a new issue