Giter Site home page Giter Site logo

Comments (6)

pedroslopez avatar pedroslopez commented on May 17, 2024

I've just tested it and it's working for me. Are you sure this is the correct chatId and the client is a part of the chat?

Also, where/when are you calling this? Can you post a more complete example?

from whatsapp-web.js.

ThiagoCarmona avatar ThiagoCarmona commented on May 17, 2024

The client is part of the group and is also an administrator.

The "participants" property successfully returns the list of participants but I am unable to use the removeParticipants () method. Can you show me how you did it?

This is my code

const { Client} = require("whatsapp-web.js")
const client = new Client();

client.on('qr', (qr) => {
    // Generate and scan this code with your phone
    console.log('QR RECEIVED', qr);
});

client.on('ready', () => {
    console.log('Client is ready!');
});

client.on('message', async msg => {
    if (msg.body == '!remove') {
        let group = await client.getChatById("[email protected]");
        await group.removeParticipants(["[email protected]"])
    }
});

client.initialize();

from whatsapp-web.js.

pedroslopez avatar pedroslopez commented on May 17, 2024

That example looks good to me. I copied the exact same code and changed the IDs and it worked.

Can you print and post the result of group as well as the result of removeParticipants? Also, I'm pretty sure ids for participants should end in "@c.us", not "@g.us".

from whatsapp-web.js.

ThiagoCarmona avatar ThiagoCarmona commented on May 17, 2024

Group result:

GroupChat {
  groupMetadata: {
    id: {
      server: 'g.us',
      user: '556181491358-1555784193',
      _serialized: '[email protected]'
    },
    creation: 1555784193,
    owner: {
      server: 'c.us',
      user: '556181491358',
      _serialized: '[email protected]'
    },
    desc: '🇫 🇮 🇬 🇺 🇷 🇮 🇳 🇭 🇦 🇸 \n'           +
      '\n' +
      'O GRUPO É NOVO, POR FAVOR FIQUEI POR AI :)\n' +
      '\n' +
      '1 - Somente usar figurinhas✅\n' +
      '2 - Não postar pornografia (explícita)🔞\n' +
      '3 - Não divulgar outros grupos\n' +
      '4 - Não chamar no pv se não tiver sido convidado 🤫\n' +
      '5 - Seja legal🙂\n' +
      '6 - Mande figurinhas🤩\n' +
      '7 - Se entrar no grupo e não mandar figurinha, será banido por inatividade⚠\n' +
      '\n' +
      '💥Link do grupo💥\n' +
      'https://chat.whatsapp.com/LcQwtbnT7WZL2hpyGiD594\n' +
      '👍',
    descId: '3EB0EA1105CE479D646A',
    descTime: 1572818368,
    descOwner: {
      server: 'c.us',
      user: '553588765808',
      _serialized: '[email protected]'
    },
    restrict: true,
    participants: [
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object],
      ... 131 more items
    ],
    pendingParticipants: []
  },
  id: {
    server: 'g.us',
    user: '556181491358-1555784193',
    _serialized: '[email protected]'
  },
  name: '🇫 🇮 🇬 🇺 🇷 🇮 🇳 🇭 🇦 🇸'          ,
  isGroup: true,
  isReadOnly: false,
  unreadCount: 19,
  timestamp: 1581293438
}

removeParticipants result:

(node:3228) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read property 'removeParticipants' of undefined
    at __puppeteer_evaluation_script__:2:30
    at ExecutionContext._evaluateInternal (C:\Users\xboxt\Desktop\node\UDF Whatsapp\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\ExecutionContext.js:122:13)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at async ExecutionContext.evaluate (C:\Users\xboxt\Desktop\node\UDF Whatsapp\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\ExecutionContext.js:48:12)
    at async GroupChat.removeParticipants (C:\Users\xboxt\Desktop\node\UDF Whatsapp\node_modules\whatsapp-web.js\src\structures\GroupChat.js:58:16)
    at async Client.<anonymous> (C:\Users\xboxt\Desktop\node\UDF Whatsapp\teste.js:17:9)
  -- ASYNC --
    at ExecutionContext.<anonymous> (C:\Users\xboxt\Desktop\node\UDF Whatsapp\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\helper.js:111:15)
    at DOMWorld.evaluate (C:\Users\xboxt\Desktop\node\UDF Whatsapp\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\DOMWorld.js:112:20)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
  -- ASYNC --
    at Frame.<anonymous> (C:\Users\xboxt\Desktop\node\UDF Whatsapp\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\helper.js:111:15)
    at Page.evaluate (C:\Users\xboxt\Desktop\node\UDF Whatsapp\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\Page.js:833:43)
    at Page.<anonymous> (C:\Users\xboxt\Desktop\node\UDF Whatsapp\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\helper.js:112:23)
    at GroupChat.removeParticipants (C:\Users\xboxt\Desktop\node\UDF Whatsapp\node_modules\whatsapp-web.js\src\structures\GroupChat.js:58:42)
    at Client.<anonymous> (C:\Users\xboxt\Desktop\node\UDF Whatsapp\teste.js:17:21)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)

from whatsapp-web.js.

pedroslopez avatar pedroslopez commented on May 17, 2024

What version of the library are you running? It seems it's not able to get Store.Wap, which was an issue before but has since been fixed.

from whatsapp-web.js.

ThiagoCarmona avatar ThiagoCarmona commented on May 17, 2024

The problem was solved, I started a new project by installing the package again.

from whatsapp-web.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.