UNPKG

choco-bot

Version:

Whatsapp-bot

34 lines (30 loc) 1.08 kB
function echoGroupMetadata(msg) { const chat = msg.getChat(); if (!chat.isGroup) { const metadata = chat.groupMetadata; if (metadata) { const groupName = metadata.subject; const groupId = metadata.id; const groupDescription = metadata.desc; const groupCreationTime = new Date(metadata.creation * 1000).toUTCString(); const groupParticipantCount = metadata.participants.length; // Construct the metadata message const metadataMessage = ` Group Name: ${groupName} Group ID: ${groupId} Group Description: ${groupDescription} Creation Time: ${groupCreationTime} Participant Count: ${groupParticipantCount} `; // Send the metadata message as a reply msg.reply(metadataMessage); } else { msg.reply("Group metadata is not available."); } } else { msg.reply("This command can only be used in a group chat."); } } module.exports = { echoGroupMetadata, }