choco-bot
Version:
Whatsapp-bot
23 lines (20 loc) • 593 B
JavaScript
async function getGroups(client, msg) {
try {
const groups = await client.getChats();
const groupsInfo = groups
.filter((chat) => chat.isGroup)
.map((chat) => `Name: ${chat.name}, ID: ${chat.id._serialized}`)
.join('\n');
if (groupsInfo) {
msg.reply(`Groups:\n${groupsInfo}`);
} else {
msg.reply('No groups found.');
}
} catch (error) {
console.error('Error fetching groups:', error);
msg.reply('Error fetching groups.');
}
}
module.exports = {
getGroups,
};