Comments (6)
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.
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.
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.
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.
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.
The problem was solved, I started a new project by installing the package again.
from whatsapp-web.js.
Related Issues (20)
- message send success but not delivered
- Error: Evaluation failed: TypeError: Cannot read properties of null (reading 'rotateKey')
- TypeError: Cannot read properties of null (reading 'rotateKey') HOT 1
- The whatsapp notifications not popup on mobile when the number run on the server HOT 1
- Filter by unread chats
- Import chrome profiles via local auth HOT 2
- 200 status but messags HOT 1
- forward messages don't working
- get all message chat since previous session breaking HOT 2
- Support for Electron? HOT 1
- npm WARN deprecated [email protected]: < 21.5.0 is no longer supported
- Downgrading npm to version 6.14.18 worked for me: npm install -g [email protected] not working
- client.sendMessage MP4 - Error: Evaluation failed: u
- WhatsApp is out of date HOT 1
- npm WARN deprecated [email protected]: < 21.5.0 is no longer supported
- how to get a invite to group via link, get a group join qrcode display HOT 1
- Group Messages - "Waiting for this message. This may take a while." HOT 4
- getNumberId HOT 1
- Events Call
- unable to reproduce ptt downloaded file (message voice) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from whatsapp-web.js.