Open Todpig opened 1 year ago
I don't think the problem is in forwarding messages, looks like a problem accessing the Puppeteer instance.
Take a look at this PR, make sure you implement this fix and see if your problem will be solved. #2434
I don't think the problem is in forwarding messages, looks like a problem accessing the Puppeteer instance.
Take a look at this PR, make sure you implement this fix and see if your problem will be solved. #2434
Not solved....
for me it worked: whatsapp-web.js/src/structures/Message.js : 387 async forward(chat) { const chatId = typeof chat === 'string' ? chat : chat.id._serialized;
await this.client.pupPage.evaluate(async (msgId, chatId) => {
let msg = window.Store.Msg.get(msgId);
let chat = window.Store.Chat.get(chatId);
window.Store.Chat.forwardMessagesToChats([msg],[chat]);
}, this.id._serialized, chatId);
}
for me it worked: whatsapp-web.js/src/structures/Message.js : 387 async forward(chat) { const chatId = typeof chat === 'string' ? chat : chat.id._serialized;
await this.client.pupPage.evaluate(async (msgId, chatId) => { let msg = window.Store.Msg.get(msgId); let chat = window.Store.Chat.get(chatId); window.Store.Chat.forwardMessagesToChats([msg],[chat]); }, this.id._serialized, chatId); }
Media forwarding stopped working
UPD: Adding one second delay for sending photos solved the problem, apparently Whatsapp does not have time to process photos (With other types of files everything works without delay)
for me it worked: whatsapp-web.js/src/structures/Message.js : 387 async forward(chat) { const chatId = typeof chat === 'string' ? chat : chat.id._serialized;
await this.client.pupPage.evaluate(async (msgId, chatId) => { let msg = window.Store.Msg.get(msgId); let chat = window.Store.Chat.get(chatId); window.Store.Chat.forwardMessagesToChats([msg],[chat]); }, this.id._serialized, chatId); }
however, when I try to forward it through the GroupChat.lastMessage attribute, the same error returns 😥😔
for me it worked: whatsapp-web.js/src/structures/Message.js : 387 async forward(chat) { const chatId = typeof chat === 'string' ? chat : chat.id._serialized;
await this.client.pupPage.evaluate(async (msgId, chatId) => { let msg = window.Store.Msg.get(msgId); let chat = window.Store.Chat.get(chatId); window.Store.Chat.forwardMessagesToChats([msg],[chat]); }, this.id._serialized, chatId); }
this works for me! the only part i needed to change was window.Store.Chat.forwardMessagesToChats([msg],[chat]);
Is there an existing issue for this?
Describe the bug
After whatsapp update I can't forward messages
Expected behavior
forwad message
Steps to Reproduce the Bug or Issue
1- conection 2- get message 3 - forward message 4 - errror
TypeError: Cannot read properties of undefined (reading 'pupPage') at Message.forward (C:\Users\Lucas\Documents\teste\node_modules\whatsapp-web.js\src\structures\Message. js:387:27) at Client. (C:\Users\Lucas\Documents\teste\app.js:21:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Relevant Code
const { Client, LocalAuth } = require("whatsapp-web.js"); const qrcode = require("qrcode-terminal");
const client = new Client({ puppeteer: { headless: false, }, authStrategy: new LocalAuth({ clientId: "test" }), });
client.on("qr", (qr) => { qrcode.generate(qr, { small: true }); });
client.on("ready", async () => { try { console.log("Conexão feita! Valeu boy."); const userGroups = await client.getChats(); const groupsPechin = userGroups.filter((chat) => chat.name === "Envios"); const message = groupsPechin[0].lastMessage; await message.forward(chatId); } catch (err) { console.log(err); } });
client.initialize();
Browser Type
Google Chrome
WhatsApp Account Type
WhatsApp Business
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
whatsapp-web.js
Additional context
No response