#Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'WidFactory')

5 messages · Page 1 of 1 (latest)

rose jewel
#

process.on("message", (data) => {
console.log("message recieved");
switch (data.key) {
case 1: //create a message for groups
const createGMsg = async () => {
try {
task1 = true;
console.log("sendthe message");
await clientMain.sendMessage(Admin, "Envie mensaje Grupal porfavor");
message = await waitForResponse(clientMain, Admin);

      await GmsgModel.addGMsg(message, data.id);

for some reason, client.sendmessage crashes
the client is already ready but it still crashes, the Admin phone number is correct, it uses the @c.us and everything

(solved by encapsuling the sendmessage code on the event client.on(ready). And the process.on needed to be async

nocturne burrow
#

post that admin format that you use

rose jewel
#

I have been investigating the issue by looking at older versions of my proyect, because it did work before. I found out that if the whole logic was encapsuled by the client.on("ready") event the problem is gone.
The thing is, if i encapsulate all my bot logic in client.on("ready", () => { //bot logic })
for some reason, Process.on("message") stops working. I dont understand why

#

process.on(message) never initializes this way.

nocturne burrow
# rose jewel process.on("message", (data) => { console.log("message recieved"); switch (d...

https://github.com/pedroslopez/whatsapp-web.js/issues/330
seems like you have to initialize your client to ready state first then you can send message

GitHub

Is anyone else having this problem when sending a message with image attached? sendMessage::error Error: Evaluation failed: TypeError: Cannot read property 'WidFactory' of undefined at __pu...