mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-20 04:29:15 +00:00
feat: star/unstar messages (#494)
This commit is contained in:
committed by
Pedro S. Lopez
parent
71dbe99023
commit
1b946940f4
4
index.d.ts
vendored
4
index.d.ts
vendored
@@ -524,6 +524,10 @@ declare namespace WAWebJS {
|
|||||||
* Forwards this message to another chat
|
* Forwards this message to another chat
|
||||||
*/
|
*/
|
||||||
forward: (chat: Chat | string) => Promise<void>,
|
forward: (chat: Chat | string) => Promise<void>,
|
||||||
|
/** Star this message */
|
||||||
|
star: () => Promise<void>
|
||||||
|
/** Unstar this message */
|
||||||
|
unstar: () => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ID that represents a message */
|
/** ID that represents a message */
|
||||||
|
|||||||
@@ -278,6 +278,32 @@ class Message extends Base {
|
|||||||
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
|
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
|
||||||
}, this.id._serialized, everyone);
|
}, this.id._serialized, everyone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stars this message
|
||||||
|
*/
|
||||||
|
async star() {
|
||||||
|
await this.pupPage.evaluate((msgId) => {
|
||||||
|
let msg = window.Store.Msg.get(msgId);
|
||||||
|
|
||||||
|
if (msg.canStar()) {
|
||||||
|
return msg.chat.sendStarMsgs([msg], true);
|
||||||
|
}
|
||||||
|
}, this.id._serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unstars this message
|
||||||
|
*/
|
||||||
|
async unstar() {
|
||||||
|
await this.pupPage.evaluate((msgId) => {
|
||||||
|
let msg = window.Store.Msg.get(msgId);
|
||||||
|
|
||||||
|
if (msg.canStar()) {
|
||||||
|
return msg.chat.sendStarMsgs([msg], false);
|
||||||
|
}
|
||||||
|
}, this.id._serialized);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Message;
|
module.exports = Message;
|
||||||
|
|||||||
Reference in New Issue
Block a user