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.03k stars 3.57k forks source link

.on('group_join) and .on('group_membership_request') are no longer working #3188

Open jacobbinnie opened 1 month ago

jacobbinnie commented 1 month ago

Is there an existing issue for this?

Describe the bug

Hey there,

I'm working with simple WhatsApp group chats and I've noticed the .on('group_join) and .on('group_membership_request') are not working. Most other listeners seem to be working fine for group chats.

Anyone got a fix for this?

Jacob

Expected behavior

As a user, I expected to be able to log a message or at least see the event being triggered.

Steps to Reproduce the Bug or Issue

  1. Connect and initialize a WhatsApp client that is an admin of your group chat
  2. Request to join the group chat from another WhatsApp number
  3. No event is fired for either of the listeners

Relevant Code

client.on('group_membership_request', (event) => {
              console.log('Group membership request:', event);
            });

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

whatsapp-web.js version: 2.3000.1014748697

Additional context

No response

warleysr commented 1 month ago

Hey @jacobbinnie. I was facing the same issue and realized that it was solved in the last 1.24.0 version with #2813. I updated my module but it started to break, so I downgraded to version 1.23.1-alpha.5 and edited the Client.js file applying the same one line change of the PR and it is working fine.

My code looks like this:

const wwebVersion = '2.3000.1015010030-alpha';
const client = new Client({
    puppeteer: {
        args: ['--no-sandbox', '--disable-setuid-sandbox'],
    },
    authStrategy: new LocalAuth(
        {dataPath: 'wppSessionData'}
    ),
   webVersionCache: {
       type: 'remote',
       remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
   }
});

client.on('group_membership_request', async (notification) => {
    console.log('NEW REQUEST: ' + notification.chatId);
    client.approveGroupMembershipRequests(notification.chatId);
});