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.05k stars 3.58k forks source link

Delete Message got error #2136

Closed reinforcers closed 1 year ago

reinforcers commented 1 year ago

Is there an existing issue for this?

Describe the bug

error while performing Message.delete(true)

Expected behavior

-

Steps to Reproduce the Bug or Issue

run Message.delete(true)

Relevant Code

Evaluation failed: TypeError: Cannot read properties of undefined (reading 'promises') at t.sendRevokeMsgs (https://web.whatsapp.com/main.33e0cec8c08487151f54.js:6:951254) at Object.current (https://web.whatsapp.com/main.33e0cec8c08487151f54.js:5:815377) at https://web.whatsapp.com/app.0067e3224e6db3ee85de.js:72:339493 at f.<anonymous> (https://web.whatsapp.com/app.0067e3224e6db3ee85de.js:72:335664) at f._triggerEvents (https://web.whatsapp.com/app.0067e3224e6db3ee85de.js:50:443685) at f.trigger (https://web.whatsapp.com/app.0067e3224e6db3ee85de.js:50:442257) at f.sendRevokeMsgs (https://web.whatsapp.com/app.0067e3224e6db3ee85de.js:72:790166) at __puppeteer_evaluation_script__:6:41

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

Linux

Additional context

No response

reinforcers commented 1 year ago

I just found about #2131 and try delete package-lock and node_modules then do npm update but it still error

Evaluation failed: TypeError: Cannot read properties of undefined (reading 'isNewsletter') at Object.current (https://web.whatsapp.com/main.7aadda7941c4b97033c5.js:5:710986) at https://web.whatsapp.com/app.598a85f21f1302dc2af5.js:73:358851 at _.<anonymous> (https://web.whatsapp.com/app.598a85f21f1302dc2af5.js:73:355022) at _triggerEvents (https://web.whatsapp.com/app.598a85f21f1302dc2af5.js:51:452561) at _.trigger (https://web.whatsapp.com/app.598a85f21f1302dc2af5.js:51:451133) at _.sendRevokeMsgs (https://web.whatsapp.com/app.598a85f21f1302dc2af5.js:73:810459) at __puppeteer_evaluation_script__:6:41

smilingOrange commented 1 year ago

Reinstall the library. It should work after the update.

aithmid commented 1 year ago

I still have the same error:

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'isNewsletter')
    at Object.current (https://web.whatsapp.com/main.051b347d194f13989838.js:5:807908)
    at https://web.whatsapp.com/app.dd48bf31ed0975cb26f7.js:89:375657
    at f.<anonymous> (https://web.whatsapp.com/app.dd48bf31ed0975cb26f7.js:89:371828)
    at f._triggerEvents (https://web.whatsapp.com/app.dd48bf31ed0975cb26f7.js:51:459205)
    at f.trigger (https://web.whatsapp.com/app.dd48bf31ed0975cb26f7.js:51:457777)
    at f.sendRevokeMsgs (https://web.whatsapp.com/app.dd48bf31ed0975cb26f7.js:89:830850)
    at __puppeteer_evaluation_script__:9:41
    at ExecutionContext._evaluateInternal (/Users/Twelve/Desktop/projects/tiit/backend/node_modules/puppeteer/src/common/ExecutionContext.ts:273:13)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (/Users/Twelve/Desktop/projects/tiit/backend/node_modules/puppeteer/src/common/ExecutionContext.ts:140:12)
    at async Message.delete (/Users/Twelve/Desktop/projects/tiit/backend/node_modules/whatsapp-web.js/src/structures/Message.js:441:9)
    at async Client.<anonymous> (/Users/Twelve/Desktop/projects/tiit/backend/src/whatsappBot/initWhatsappBot.ts:25:2)

my code:

const qrcode = require("qrcode-terminal");
const { Client, LocalAuth } = require("whatsapp-web.js");

export const client = new Client({
    authStrategy: new LocalAuth({
        clientId: "moderator",
        // dataPath: "./src/whatsappBot",
        dataPath: "./savedSession",
        saveLogin: true,
    }),
});

client.initialize();

client.on("qr", (qr: any) => {
    qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
    console.log("Whatsapp Bot is ready!");
});

client.on("message", async (message) => {
    console.log("MESSAGE RECEIVED", message);
    await message.delete(true);
});

whatsapp js version:

    "whatsapp-web.js": "^1.19.5"

Browser Type Chromium

WhatsApp Account Type Business

Does your WhatsApp account have multidevice enabled? Yes, I am using Multi-Device

Environment macOS

can someone help please

telmedola commented 1 year ago

Same here. I receiving that message too: TypeError: Cannot read properties of undefined (reading 'pendingDeleteForMeCount'.....

ric-h commented 1 year ago

fix is here: #2116 (specific)... or here #2139

telmedola commented 1 year ago

fix is here: #2116 (specific)... or here #2139

Thanks