whatsapp-web.js icon indicating copy to clipboard operation
whatsapp-web.js copied to clipboard

Evaluation failed: TypeError: chat.forwardMessages is at __puppeteer_evaluation_script__:5:31

Open cpetrag opened this issue 1 year ago • 6 comments

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

cpetrag avatar Aug 22 '23 10:08 cpetrag

estou com o mesmo problema

Todpig avatar Aug 23 '23 11:08 Todpig

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);
}

yajuj avatar Aug 24 '23 13:08 yajuj

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!!!

cpetrag avatar Aug 24 '23 14:08 cpetrag

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. (C:\Users\Lucas\Documents\testeForward\app.js:25:11) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v19.9.0

Todpig avatar Aug 24 '23 16:08 Todpig

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

Todpig avatar Aug 24 '23 17:08 Todpig

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", ], }, });

DukazzCruz avatar Apr 12 '24 20:04 DukazzCruz