whatsapp-web.js
whatsapp-web.js copied to clipboard
Evaluation failed: TypeError: chat.forwardMessages is at __puppeteer_evaluation_script__:5:31
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
Not forwarding messages
Expected behavior
Not forwarding messages
Steps to Reproduce the Bug or Issue
Forwarding messages
Relevant Code
No response
Browser Type
Chromium
WhatsApp Account Type
WhatsApp Business
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
Is there an existing issue for this? I have searched the existing issues Describe the bug the bot is just displays the message: Evaluation failed: TypeError: chat.forwardMessages is at puppeteer_evaluation_script:5:31
Expected behavior should respond
Steps to Reproduce the Bug or Issue on message and on ready not working
Relevant Code No response
Browser Type Google Chrome
WhatsApp Account Type Standard
Does your WhatsApp account have multidevice enabled? Yes, I am using Multi Device
Environment no hwencements
Additional context No response
Additional context
No response
estou com o mesmo problema
Try replacing 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);
}
Try replacing 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); }
Works!!!!! Thanks!!!
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 () => { console.log("Conexão feita!"); const userGroups = await client.getChats(); const groupEnvios = userGroups.find((chat) => chat.name === "name1"); const groupPechinchou = userGroups.find( (chat) => chat.name === "name2" );
const message = groupEnvios.lastMessage; console.log(message); message.forward(groupPechinchou.id._serialized); });
client.initialize();
C:\Users\Lucas\Documents\testeForward\node_modules\whatsapp-web.js\src\structures\Message.js:385 await this.client.pupPage.evaluate(async (msgId, chatId) => { ^
TypeError: Cannot read properties of undefined (reading 'pupPage')
at Message.forward (C:\Users\Lucas\Documents\testeForward\node_modules\whatsapp-web.js\src\structures\Message.js:385:27)
at Client.
Node.js v19.9.0
Try replacing 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); }
it works!! thank you my friend
Work for me install independent "puppeteer": "^22.6.4". Try it.
const waClient = new Client({ restartOnAuthFail: true, authStrategy: new LocalAuth({ clientId: "LaraNoti222", dataPath: "./WWebJ", }), webVersionCache: { type: "remote", remotePath: "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2410.1.html" }, puppeteer: { headless: true, args: [ "--no-sandbox", "--disable-extensions", "--disable-setuid-sandbox", "--disable-dev-shm-usage", "--disable-accelerated-2d-canvas", "--no-first-run", "--no-zygote", "--single-process", "--disable-gpu", ], }, });