whatsapp-web.js icon indicating copy to clipboard operation
whatsapp-web.js copied to clipboard

chat.addParticipants Always report errors

Open Gethin0321 opened this issue 2 years ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

chat.addParticipants Always report errors

addParticipants Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'id') at https://web.whatsapp.com/main.6ce9d02486f0affed52c.js:2:200232 at Array.some () at https://web.whatsapp.com/main.6ce9d02486f0affed52c.js:2:200215 at Generator.next () at t (https://web.whatsapp.com/vendor1~app.0c8e960e5dfd7020f562.js:2:66483) at s (https://web.whatsapp.com/vendor1~app.0c8e960e5dfd7020f562.js:2:66694) at https://web.whatsapp.com/vendor1~app.0c8e960e5dfd7020f562.js:2:66753 at Y (https://web.whatsapp.com/app.a8429b8147f1b90a2f71.js:5:153273) at new y (https://web.whatsapp.com/app.a8429b8147f1b90a2f71.js:5:145840) at https://web.whatsapp.com/vendor1~app.0c8e960e5dfd7020f562.js:2:66634 at ExecutionContext._evaluateInternal (/opt/wa-control/src/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:97:5) at async ExecutionContext.evaluate (/opt/wa-control/src/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16) at async GroupChat.addParticipants (/opt/wa-control/src/node_modules/whatsapp-web.js/src/structures/GroupChat.js:62:16)

Expected behavior

.

Steps to Reproduce the Bug or Issue

.

Relevant Code

let chat_id = '1203630302*****@g.us'; let participants = [ "55949***@c.us", "55649***@c.us" ]; client.getChatById(chat_id).then(function (chat) { if (!chat) {

                        return;
                    }
                    chat.addParticipants(participants).then(function (res) {
                        if (!res) {
                           
                            return;
                        }
                      console.log(res);
                    }).catch(function (err) {
                        
                    });
                }).catch(function (err) {
                   
                });

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

default

Additional context

No response

Gethin0321 avatar Jan 19 '23 10:01 Gethin0321

You should problably get all contacts from the chip, and then filter by the id.

Nypat avatar Jan 19 '23 14:01 Nypat

did you check:

  1. If the person you are trying to add is a contact of yours?
  2. Maybe set let participants = ["55949***"] without the "@g.us"?

sharon846 avatar Jan 20 '23 23:01 sharon846

Any news about this?

tinyCoder32 avatar Jan 30 '23 22:01 tinyCoder32