Skip to content

Instantly share code, notes, and snippets.

@mistershubhamkumar
Forked from nabeelxdd/getjids.js
Created March 5, 2025 13:46
Show Gist options
  • Select an option

  • Save mistershubhamkumar/2b239906f5a1a69c4d11cb99e62a454b to your computer and use it in GitHub Desktop.

Select an option

Save mistershubhamkumar/2b239906f5a1a69c4d11cb99e62a454b to your computer and use it in GitHub Desktop.
Get Group Members Jid. Plugin by Nabeel XD
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