Whatsapp-web.js: Ability to fetch a message by ID

Created on 23 Sep 2020  路  2Comments  路  Source: pedroslopez/whatsapp-web.js

Forgive me if the feature already exists and I just didn't look hard enough, but I'm pretty sure that it doesn't exist yet.
The feature should probably be somewhere inside the Chat structure, similar to how Client has a .getChatById method.

Chat.getMessageById(messageID);

This would be useful for replying to or quoting any given message.

enhancement

Most helpful comment

I think the best approach is improve the fetchMessages()

const chat = await client.getChatById("[email protected]");
const message = await chat.fetchMessages({ where: { ... } });

All 2 comments

You can access the properties and methods of the messages here. https://pedroslopez.me/whatsapp-web.js/Message.html

You can access the id of each message here:

client.on ('message', async msg => {

console.log (msg.id);
/*
{
   fromMe: false,
   remote: '[email protected]',
   id: '17ADF6142476636C9AY9F62BA24D05E9',
   _serialized: '[email protected]_72ADF6632476636C3DA9F62BAC9D05E9'
}
*/
});

You can store the incoming message objects and then return to the replies over those message objects.

msg.reply("content",msg.from);

Likewise, you can access chat features and methods from here.
https://pedroslopez.me/whatsapp-web.js/Chat.html

I think the best approach is improve the fetchMessages()

const chat = await client.getChatById("[email protected]");
const message = await chat.fetchMessages({ where: { ... } });
Was this page helpful?
0 / 5 - 0 ratings

Related issues

fdciabdul picture fdciabdul  路  6Comments

ngekoding picture ngekoding  路  5Comments

dedenhendrap picture dedenhendrap  路  8Comments

riagie picture riagie  路  6Comments

nicolascav picture nicolascav  路  6Comments