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

UnhandledPromiseRejectionWarning: TypeError: data.id.id.substring is not a function #2357

Closed jotsamikael closed 1 year ago

jotsamikael commented 1 year ago

Is there an existing issue for this?

Describe the bug

I can't send or reply to messages My code logic is supposed to reply to a hello message coming from a conversation with a hi The whatsapp version of the message sender is: 2.23.14.79 The whatsapp version of the bot is 2.23.13.76

(node:14324) UnhandledPromiseRejectionWarning: TypeError: data.id.id.substring is not a function at Message._patch (D:\Logos\node_modules\whatsapp-web.js\src\structures\Message.js:92:75)
at new Message (D:\Logos\node_modules\whatsapp-web.js\src\structures\Message.js:18:24)
at Client.sendMessage (D:\Logos\node_modules\whatsapp-web.js\src\Client.js:699:16) at processTicksAndRejections (internal/process/task_queues.js:93:5) (Use node --trace-warnings ... to show where the warning was created) (node:14324) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:14324) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:14324) UnhandledPromiseRejectionWarning: TypeError: data.id.id.substring is not a function
at Message._patch (D:\Logos\node_modules\whatsapp-web.js\src\structures\Message.js:92:75)
at new Message (D:\Logos\node_modules\whatsapp-web.js\src\structures\Message.js:18:24) at Client.sendMessage (D:\Logos\node_modules\whatsapp-web.js\src\Client.js:699:16) at processTicksAndRejections (internal/process/task_queues.js:93:5) (node:14324) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

Expected behavior

Message sender receives a "Hi" response

Steps to Reproduce the Bug or Issue

  1. create a node project
  2. Install whatsapp web
  3. connect to your mobile device
  4. add this logic let replyToHello = function () { client.on('message', async (message) => { const userPrompt = message.body let number = message.from; switch (userPrompt) { case 'Hello': console.log("switch works") message.reply('hi'); message.reply("A. Translate from ENGLISH -> FRENCH \n B. Translate from FRENCH -> ENGLISH \n C. ENGLISH word definition \n D. Hand written notes");

            break; ....

Relevant Code

No response

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

os: windows 10 phone os: android whatsapp-web.js version: 1.18.2 Node.js Version: 14.15

Additional context

No response

mancier commented 1 year ago

I am facing the same issue

vishnukaushik commented 1 year ago

@jotsamikael This error is handled in the latest version. Could you check updating to the latest version of this module (1.21.0)?

opssemnik commented 1 year ago

@jotsamikael if the issue is non present in the latest version, could you close this issue? Thanks

jotsamikael commented 1 year ago

Corrected in lastest version

opssemnik commented 1 year ago

Nice to hear! thank you!