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 @@ -1540,6 +1540,33 @@ class Client extends EventEmitter {
15401540 return sentMsg ? new Message ( this , sentMsg ) : undefined ;
15411541 }
15421542
1543+ /**
1544+ * Send an emoji reaction to a specific message
1545+ * @param {string } messageId - Id of the message to add the reaction.
1546+ * @param {string } reaction - Emoji to react with. Send an empty string to remove the reaction.
1547+ * @return {Promise }
1548+ */
1549+ async sendReaction ( messageId , reaction ) {
1550+ await this . pupPage . evaluate (
1551+ async ( messageId , reaction ) => {
1552+ if ( ! messageId ) return null ;
1553+ const msg =
1554+ window . require ( 'WAWebCollections' ) . Msg . get ( messageId ) ||
1555+ (
1556+ await window
1557+ . require ( 'WAWebCollections' )
1558+ . Msg . getMessagesById ( [ messageId ] )
1559+ ) ?. messages ?. [ 0 ] ;
1560+ if ( ! msg ) return null ;
1561+ await window
1562+ . require ( 'WAWebSendReactionMsgAction' )
1563+ . sendReactionToMsg ( msg , reaction ) ;
1564+ } ,
1565+ messageId ,
1566+ reaction ,
1567+ ) ;
1568+ }
1569+
15431570 /**
15441571 * @typedef {Object } SendChannelAdminInviteOptions
15451572 * @property {?string } comment The comment to be added to an invitation
Original file line number Diff line number Diff line change @@ -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