File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -210,6 +210,12 @@ declare namespace WAWebJS {
210210 options ?: MessageSendOptions ,
211211 ) : Promise < Message > ;
212212
213+ /** Send a reaction to a specific messageId */
214+ sendReaction (
215+ messageId : string ,
216+ reaction : string ,
217+ ) : Promise < void > ;
218+
213219 /** Sends a channel admin invitation to a user, allowing them to become an admin of the channel */
214220 sendChannelAdminInvite (
215221 chatId : string ,
Original file line number Diff line number Diff line change @@ -1647,6 +1647,33 @@ class Client extends EventEmitter {
16471647 return sentMsg ? new Message ( this , sentMsg ) : undefined ;
16481648 }
16491649
1650+ /**
1651+ * Send an emoji reaction to a specific message
1652+ * @param {string } messageId - Id of the message to add the reaction.
1653+ * @param {string } reaction - Emoji to react with. Send an empty string to remove the reaction.
1654+ * @return {Promise }
1655+ */
1656+ async sendReaction ( messageId , reaction ) {
1657+ await this . pupPage . evaluate (
1658+ async ( messageId , reaction ) => {
1659+ if ( ! messageId ) return null ;
1660+ const msg =
1661+ window . require ( 'WAWebCollections' ) . Msg . get ( messageId ) ||
1662+ (
1663+ await window
1664+ . require ( 'WAWebCollections' )
1665+ . Msg . getMessagesById ( [ messageId ] )
1666+ ) ?. messages ?. [ 0 ] ;
1667+ if ( ! msg ) return null ;
1668+ await window
1669+ . require ( 'WAWebSendReactionMsgAction' )
1670+ . sendReactionToMsg ( msg , reaction ) ;
1671+ } ,
1672+ messageId ,
1673+ reaction ,
1674+ ) ;
1675+ }
1676+
16501677 /**
16511678 * @typedef {Object } SendChannelAdminInviteOptions
16521679 * @property {?string } comment The comment to be added to an invitation
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ class Message extends Base {
103103 * @type {string }
104104 */
105105 this . deviceType =
106- typeof data . id . id === 'string' && data . id . id . length > 21
106+ typeof data . id . id === 'string' && data . id . id . length > 25
107107 ? 'android'
108108 : typeof data . id . id === 'string' &&
109109 data . id . id . substring ( 0 , 2 ) === '3A'
@@ -477,24 +477,7 @@ class Message extends Base {
477477 * @return {Promise }
478478 */
479479 async react ( reaction ) {
480- await this . client . pupPage . evaluate (
481- async ( messageId , reaction ) => {
482- if ( ! messageId ) return null ;
483- const msg =
484- window . require ( 'WAWebCollections' ) . Msg . get ( messageId ) ||
485- (
486- await window
487- . require ( 'WAWebCollections' )
488- . Msg . getMessagesById ( [ messageId ] )
489- ) ?. messages ?. [ 0 ] ;
490- if ( ! msg ) return null ;
491- await window
492- . require ( 'WAWebSendReactionMsgAction' )
493- . sendReactionToMsg ( msg , reaction ) ;
494- } ,
495- this . id . _serialized ,
496- reaction ,
497- ) ;
480+ return this . client . sendReaction ( this . id . _serialized , reaction ) ;
498481 }
499482
500483 /**
You can’t perform that action at this time.
0 commit comments