Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ declare namespace WAWebJS {
/** Send a message to a specific chatId */
sendMessage(chatId: string, content: MessageContent, options?: MessageSendOptions): Promise<Message>

/** Send a reaction to a specific messageId */
sendReaction(messageId: string, reaction: string): Promise<void>

/** Sends a channel admin invitation to a user, allowing them to become an admin of the channel */
sendChannelAdminInvite(chatId: string, channelId: string, options?: { comment?: string }): Promise<boolean>

Expand Down
19 changes: 19 additions & 0 deletions src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,25 @@ class Client extends EventEmitter {
}, chatId);
}


/**
* React to a message with an emoji
* @param {string} messageId - Id of the message to add the reaction.
* @param {string} reaction - Emoji to react with. Send an empty string to remove the reaction.
* @return {Promise}
*/
async sendReaction(messageId, reaction){
await this.pupPage.evaluate(async (messageId, reaction) => {
if (!messageId) return null;
const msg =
window.Store.Msg.get(messageId) || (await window.Store.Msg.getMessagesById([messageId]))?.messages?.[0];
if(!msg) return null;

await window.Store.sendReactionToMsg(msg, reaction);
}, messageId, reaction);
}


/**
* An object representing mentions of groups
* @typedef {Object} GroupMention
Expand Down
8 changes: 1 addition & 7 deletions src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,7 @@ class Message extends Base {
* @return {Promise}
*/
async react(reaction){
await this.client.pupPage.evaluate(async (messageId, reaction) => {
if (!messageId) return null;
const msg =
window.Store.Msg.get(messageId) || (await window.Store.Msg.getMessagesById([messageId]))?.messages?.[0];
if(!msg) return null;
await window.Store.sendReactionToMsg(msg, reaction);
}, this.id._serialized, reaction);
return this.client.sendReaction(this.id._serialized, reaction)
}

/**
Expand Down