Zain-ul-din / whatsapp-ai-bot

This is a WhatsApp AI bot that uses various AI models, including Gemini, GPT, DALL-E, and StabilityAI, to generate responses to user input.
https://wa-ai-seven.vercel.app/
MIT License
161 stars 89 forks source link

TypeError: data.id.id.substring is not a function #7

Closed ColAsTR closed 1 year ago

ColAsTR commented 1 year ago

I encountered an error while running the code that utilizes the this program.

The error message indicates a TypeError at line 91 of the Message.js file.

/workspaces/whatsapp-ai-bot/node_modules/whatsapp-web.js/src/structures/Message.js:91 this.deviceType = data.id.id.length > 21 ? 'android' : data.id.id.substring(0, 2) == '3A' ? 'ios' : 'web'; ^

TypeError: data.id.id.substring is not a function at Message._patch (/workspaces/whatsapp-ai-bot/node_modules/whatsapp-web.js/src/structures/Message.js:91:75) at new Message (/workspaces/whatsapp-ai-bot/node_modules/whatsapp-web.js/src/structures/Message.js:18:24) at Client.sendMessage (/workspaces/whatsapp-ai-bot/node_modules/whatsapp-web.js/src/Client.js:699:16) at processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v19.9.0 error Command failed with exit code 1.

if you can just explain to me ways to solve this issue i will be gratefull.

thank you

Zain-ul-din commented 1 year ago

The error message suggests that there is a TypeError in the Message.js file of the whatsapp-web.js module. Specifically, the error occurs on line 91 of the Message.js file.

The error message states that data.id.id.substring is not a function, which means that the substring method is being called on an object that doesn't have that method.

Possible Solutions from whatsapp-web.js issue.


Make this:

Open this file: \node_modules\whatsapp-web.js\src\structures\Message.js

WhatsApp Web updated something that made that line stop working, but using this code it worked for me again.

image


Other possible Solutions

ColAsTR commented 1 year ago

thanks man