-
-
Save mistershubhamkumar/2b239906f5a1a69c4d11cb99e62a454b to your computer and use it in GitHub Desktop.
Get Group Members Jid. Plugin by Nabeel XD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { | |
| bot, | |
| getGids, | |
| jidToNum, | |
| isGroup, | |
| getGroupMembers, | |
| getName, | |
| } = require('../lib/') | |
| bot( | |
| { | |
| pattern: 'getjids ?(.*)', | |
| desc: 'Get group member JIDs', | |
| type: 'group', | |
| }, | |
| async (message, match) => { | |
| const groupJid = match.trim(); | |
| if (!isGroup(groupJid)) { | |
| return await message.send('*Give me group jid*'); | |
| } | |
| const groupMetadata = await message.groupMetadata(groupJid, true); | |
| if (!groupMetadata) { | |
| return await message.send('*You are not in the group*'); | |
| } | |
| const { subject: groupName, participants } = groupMetadata; | |
| const memberJids = participants.map((member) => member.id); | |
| const totalMembers = memberJids.length; | |
| if (totalMembers === 0) { | |
| return await message.send('This group has no members.'); | |
| } | |
| const chunkSize = 100; | |
| const jidChunks = []; | |
| for (let i = 0; i < totalMembers; i += chunkSize) { | |
| jidChunks.push(memberJids.slice(i, i + chunkSize)); | |
| } | |
| for (const chunk of jidChunks) { | |
| await message.send(chunk.join('\n')); | |
| } | |
| await message.send(`Total Members in Group: ${totalMembers} in ${groupName}`); | |
| } | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment