pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.53k stars 3.7k forks source link

sendMessage with quote will raise an exception #3259

Closed alwinlubbers closed 2 months ago

alwinlubbers commented 2 months ago

Is there an existing issue for this?

Describe the bug

Hi there,

Sending a message with a quotedMessageId will result in the following exception:

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'unsafe')
    at window.WWebJS.sendMessage (pptr://__puppeteer_evaluation_script__:54:67)
    at pptr://__puppeteer_evaluation_script__:10:45
    at ExecutionContext._ExecutionContext_evaluate (/node_modules/whatsapp-web.js/node_modules/puppeteer-core/lib/cjs/puppeteer/common/ExecutionContext.js:229:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (/node_modules/whatsapp-web.js/node_modules/puppeteer-core/lib/cjs/puppeteer/common/ExecutionContext.js:107:16)
    at async Client.sendMessage (/node_modules/whatsapp-web.js/src/Client.js:947:28)

Caused by (/src/util/injected/Utils.js)

https://github.com/pedroslopez/whatsapp-web.js/blob/066d8fa75ebc13b9cc74cfcd18ffd847b79be998/src/util/Injected/Utils.js#L45-L58

Expected behavior

N/A

Steps to Reproduce the Bug or Issue

  1. Send a message using client.sendMessage() with a valid quotedMessageId in the MessageSendOptions object.

Relevant Code

client.sendMessage(chatId, body, { quotedMessageId: "false_3XXXXXXXXXX@c.us_3ACXXXXXXXXXXXXXXX98" });

Browser Type

Google Chrome

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

Additional context

No response