Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data.id.id.substring is not a function #2211

Closed
1 task done
Eonus opened this issue May 19, 2023 · 52 comments
Closed
1 task done

data.id.id.substring is not a function #2211

Eonus opened this issue May 19, 2023 · 52 comments
Labels
bug Something isn't working

Comments

@Eonus
Copy link

Eonus commented May 19, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Today I started receiving this error on many connected accoubts

Expected behavior

Message needs to be sended

Steps to Reproduce the Bug or Issue

  1. Install wweb
  2. Authorise account
  3. Try to send message
  4. Receive an error

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

Node v16
WWEb latest

Additional context

No response

@Eonus Eonus added the bug Something isn't working label May 19, 2023
@minnigagustin
Copy link

I have the same problem. help

@AdrianoRobson
Copy link

I'm having this problem too

@MasterMarques
Copy link

MasterMarques commented May 19, 2023

@AdrianoRobson @minnigagustin @Eonus
Make this:

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

Go to line 91 and change this:
this.deviceType = data.id.id.length > 21 ? 'android' : data.id.id.substring(0, 2) == '3A' ? 'ios' : 'web';

for this:
this.deviceType = typeof data.id.id === 'string' && data.id.id.length > 21 ? 'android' : typeof data.id.id === 'string' && data.id.id.substring(0, 2) === '3A' ? 'ios' : 'web';

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

@rober-tm
Copy link

@MasterMarques @Eonus @AdrianoRobson @minnigagustin @tegila

Probe la solución de MasterMarques y así no da error, pero el mensaje no se manda, queda pendiente de envio.

Lo que veo es que en la respuesta del metodo sendMessage, el objeto id retorna una promesa sin resolver.

Probe abrir la ventana con chrome y mandarlo manualmente tipeando el mensaje y enviando, y este objeto si responde con el id resuelto.

@minnigagustin
Copy link

esto no envia el mensaje. @MasterMarques

@wilsinho8
Copy link

@AdrianoRobson @minnigagustin @Eonus Make this:

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

Go to line 91 and change this: this.deviceType = data.id.id.length > 21 ? 'android' : data.id.id.substring(0, 2) == '3A' ? 'ios' : 'web';

for this: this.deviceType = typeof data.id.id === 'string' && data.id.id.length > 21 ? 'android' : typeof data.id.id === 'string' && data.id.id.substring(0, 2) === '3A' ? 'ios' : 'web';

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

After changed the line 91 i sent a message but doenst appear.

@luiscuriel
Copy link

luiscuriel commented May 19, 2023

Take a look the Chrome Dev Tools, you will see a: DuplicateMessageError

@CSFelix
Copy link

CSFelix commented May 19, 2023

Consider the solution at #2196

https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files

@IsraelDeAraujo
Copy link

IsraelDeAraujo commented May 19, 2023

I'm having the same issue. Sometimes the message is sent, but sometimes this error occurs.

I tried to replace the this.deviceType = data.id.id.length > 21 ? 'android' : data.id.id.substring(0, 2) == '3A' ? 'ios' : 'web'; to this.deviceType = typeof data.id.id === 'string' && data.id.id.length > 21 ? 'android' : typeof data.id.id === 'string' && data.id.id.substring(0, 2) === '3A' ? 'ios' : 'web'; The error is gone, but the message is not sending.

Edit:
It is important to update the other file too.

open this link https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files and change both files are there.

Thanks for the guys who bring to us the solution.

@cpetrag
Copy link

cpetrag commented May 19, 2023

Consider the solution at #2196

https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files

Works!

@claudiocassimiro
Copy link

Do I need to update my dependencies to work here?

@facundogodixital
Copy link

https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files

It works!!

@yourlogo2018
Copy link

Com isso vcs conseguem ajustar, fiz aqui e funcionou
https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files

@claudiocassimiro
Copy link

Também fiz no localhost e funcionou, mas eu tenho 6 instancias online e teria que fazer manualmente em todas. Quando vai vim uma solução diretamente no npm install?

@yourlogo2018
Copy link

yourlogo2018 commented May 19, 2023

Se vc usa multi sessão amigo não precisa fazer em cada, aqui tenho 90 instancias online e fiz so no codigo e ja rodou normal pra todas

@Shoomec74
Copy link

https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files

It works!!

thank you! you're the best

@alfredopuertacl
Copy link

alfredopuertacl commented May 19, 2023

Também fiz no localhost e funcionou, mas eu tenho 6 instancias online e teria que fazer manualmente em todas. Quando vai vim uma solução diretamente no npm install? @claudiocassimiro

Hello Claudio, excuse me, but I have a question, how are you running your 6 instances online? are you using aws or what service?

@postix
Copy link

postix commented May 19, 2023

funciona !!!! ....

@mflps
Copy link

mflps commented May 20, 2023

Same problem here: /Users/miguels/Documents/Projects/whatsapp-chatgpt/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

nmp install doesn't solve..
^

@merlox
Copy link

merlox commented May 20, 2023

Why is such a clear error not checked before pushing new changes? This should've been tested and detected way before this point

@postix
Copy link

postix commented May 20, 2023

this only happend yesterday to me, not happend before ...i supone that the issue happend in whatsapp not in the module ... but .. with the modification informed the problem is fixed ...and ver quickly .. :D

@EdgarCrz
Copy link

Entiendo que esto es un hotfix https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files pero lo unico que soluciona es que no me rompa la aplicación, los mensajes siguen sin enviarse es correcto? o a alguien le soluciono la parte del envío?
No encontré la siguiente ruta del hotfix que proponen
src/util/Injected.js

@AnasTawfeek
Copy link

Consider the solution at #2196

https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files

Works perfectly, used https://www.npmjs.com/package/patch-package to apply the patch

@totallynotdavid
Copy link

Entiendo que esto es un hotfix https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files pero lo unico que soluciona es que no me rompa la aplicación, los mensajes siguen sin enviarse es correcto? o a alguien le soluciono la parte del envío? No encontré la siguiente ruta del hotfix que proponen src/util/Injected.js

English: Both changes need to be made! If one of these files is missing I'd suggest to delete the node_modules folder and run npm i again. If it still doesn't work, maybe delete .wwebjs_auth and try to log in again.

Spanish: Ambos cambios son necesarios. Si uno de los archivos no está presente, te sugiero eliminar la carpeta de node_modules y ejecutar npm i de nuevo. Si aún no funciona, intenta eliminar .wwebjs_auth e intenta iniciar de nuevo.

@totallynotdavid
Copy link

Why is such a clear error not checked before pushing new changes? This should've been tested and detected way before this point

Sometimes WhatsApp makes these changes. I didn't update to the last version and found the same error. Maybe that's the case.

@EdgarCrz
Copy link

Gracias @totallynotdavid hasta el momento solo intente remover la carpeta node_modules intentare tambien eliminar la carpeta de la sesion

@postix
Copy link

postix commented May 21, 2023

Gracias @totallynotdavid hasta el momento solo intente remover la carpeta node_modules intentare tambien eliminar la carpeta de la sesion

ojo .. eso de eliminar las carpetas de sesiones no es necesario ... por lo menos yo no las he tocado y después de hacer el hotfix ...todo volvió a la normalidad .. enviando y recibiendo ...

@yordanb
Copy link

yordanb commented May 21, 2023

Consider the solution at #2196

https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files

its work

@mdtausifiqbal
Copy link

Same error with me

@chornato
Copy link

Hello, in addition to the code change, it worked for me deleting .wwebjs_auth, now it works perfect! Thanks to all for the help!!!

@wendrahartanto
Copy link

Hello, in addition to the code change, it worked for me deleting .wwebjs_auth, now it works perfect! Thanks to all for the help!!!

Thanks a lot, this worked for me

@claudiocassimiro
Copy link

Também fiz no localhost e funcionou, mas eu tenho 6 instancias online e teria que fazer manualmente em todas. Quando vai vim uma solução diretamente no npm install? @claudiocassimiro

Hello Claudio, excuse me, but I have a question, how are you running your 6 instances online? are you using aws or what service?

I using contabo to run all instances

@alfredopuertacl
Copy link

Também fiz no localhost e funcionou, mas eu tenho 6 instancias online e teria que fazer manualmente em todas. Quando vai vim uma solução diretamente no npm install? @claudiocassimiro

Hello Claudio, excuse me, but I have a question, how are you running your 6 instances online? are you using aws or what service?

I using contabo to run all instances

@claudiocassimiro Thank you very much, but you use only one vps and how much ram memory? What happens is that I have a vps in aws light with a processor and a 1 gb of ram and only let me use an instance!

@0bamboo
Copy link

0bamboo commented May 23, 2023

Consider the solution at #2196

https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files

it Worked 💯

@yokowasis
Copy link

instead of changing the files manually, you can always install the package from the github instead of from the npm

npm install https://github.com/pedroslopez/whatsapp-web.js

@lukas102000
Copy link

Fiz a instalação usando npm install https://github.com/pedroslopez/whatsapp-web.js
Porém, ele não envia os botões....

@Megaapi
Copy link

Megaapi commented May 24, 2023

Fiz a instalação usando npm install https://github.com/pedroslopez/whatsapp-web.js Porém, ele não envia os botões....

Amigo, botões até o momento, o whatsapp removeu das api não oficiais

@lukas102000
Copy link

Que saco, agora eles tornaram tudo mais chato ainda..
Eu tou querendo automatizar o meu whatsapp, porém estava precisando desses botões,
ao em vez de utilizar, menu numérica de teclado...

Séra que existe uma plataforma que dê isso de graça?

@Megaapi
Copy link

Megaapi commented May 24, 2023

Que saco, agora eles tornaram tudo mais chato ainda.. Eu tou querendo automatizar o meu whatsapp, porém estava precisando desses botões, ao em vez de utilizar, menu numérica de teclado...

Séra que existe uma plataforma que dê isso de graça?

Plataforma gratuita desconheço, mas da pra você fazer de varias maneiras seu bot amigo, ou com opções númericas, o criar um esquema de gerenciamento de intenções, em node tem até um npm que ajuda nisso, podendo integrar com IA ficará melhor ainda.

@lukas102000
Copy link

Pelo visto, acho melhor trabalhar com opções numéricas,
Vou dar um check no NodeJS..

Valeu pela ajuda...

@Oladapodaniel
Copy link

https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files

It works!!

Yes this works. Thanks for the solution.
What can be done prevent future updates that might break what is currently working??

@Megaapi
Copy link

Megaapi commented May 24, 2023

https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files
It works!!

Yes this works. Thanks for the solution. What can be done prevent future updates that might break what is currently working??

Com a whatsapp-web.js não tem como evitar amigo pois como ela roda em cima do whatsapp web, se houver atualização no w-web vai afetar a lib, ja vi varios falando que tem como, e todas que tentei nenhuma deu certo.

@Oladapodaniel
Copy link

https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files
It works!!

Yes this works. Thanks for the solution. What can be done prevent future updates that might break what is currently working??

Com a whatsapp-web.js não tem como evitar amigo pois como ela roda em cima do whatsapp web, se houver atualização no w-web vai afetar a lib, ja vi varios falando que tem como, e todas que tentei nenhuma deu certo.

Alright thanks.

This solution mentioned above seemed to just work temporarily. Now messages are not sending again for me, but there isn't any error in the terminal. Anyone experiencing this?

@ajayhit
Copy link

ajayhit commented May 25, 2023

I'm having the same issue. Sometimes the message is sent, but sometimes this error occurs.

I tried to replace the this.deviceType = data.id.id.length > 21 ? 'android' : data.id.id.substring(0, 2) == '3A' ? 'ios' : 'web'; to this.deviceType = typeof data.id.id === 'string' && data.id.id.length > 21 ? 'android' : typeof data.id.id === 'string' && data.id.id.substring(0, 2) === '3A' ? 'ios' : 'web'; The error is gone, but the message is not sending.

Edit: It is important to update the other file too.

open this link https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files and change both files are there.

Thanks for the guys who bring to us the solution.

Thank you Soo Soo Much Now It's Working Fine

@alpeshl
Copy link

alpeshl commented May 26, 2023

This can be closed as fixed with PR #2196

Also, released with v1.20.0

@denysurquilla
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Today I started receiving this error on many connected accoubts

Expected behavior

Message needs to be sended

Steps to Reproduce the Bug or Issue

  1. Install wweb
  2. Authorise account
  3. Try to send message
  4. Receive an error

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

Node v16 WWEb latest

Additional context

No response

con estas intrucciones
npm install -g npm@9.6.3 to update
npm update whatsapp-web.js
npm audit
npm audit fix
npm audit fix --force

@denysurquilla
Copy link

Tengo el mismo problema. ayuda

prueba con esto
npm install -g npm@9.6.3 to update
npm update whatsapp-web.js
npm audit
npm audit fix
npm audit fix --force

@ingenieria12
Copy link

Same error... but fixed
This worked for me:

  1. Removed node_modules and .wwebjs_auth directories
  2. npm update
  3. npm run

I didn't modified any files, just updated dependencies and restart app.

@reinaldomml
Copy link

Consider the solution at #2196

https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files

Thanks!

Works for me, 1 instance in NodeJS + Digital Ocean + Ubuntu

@diogo-karma
Copy link

@irfanandratama
Copy link

Same error... but fixed This worked for me:

  1. Removed node_modules and .wwebjs_auth directories
  2. npm update
  3. npm run

I didn't modified any files, just updated dependencies and restart app.

I just did the first step and it worked.

@filipesr
Copy link

Consider the solution at #2196

https://github.com/pedroslopez/whatsapp-web.js/pull/2196/files

funcionou pra mim...

@alechkos alechkos closed this as completed Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests