/** * πŸ“ PING COMMAND - Tag All Group Members * ======================================= * * Purpose: Tags all active members in a group chat (mentions everyone) * * How it works: * 1. Gets list of all members in the group (participantIDs) * 2. Filters out the bot itself and command sender * 3. Filters out AFK users (if AFK module is active) * 4. Creates invisible mention tags for each member * 5. Sends message with typing indicator (looks natural) * * Usage: * - /ping β†’ Tags everyone with empty message * - /ping Hello everyone! β†’ Tags everyone with custom message * * Note: Only works in group chats. In DM, returns "Pong! Bot is active πŸ’™" * * Features: * βœ… Smart AFK detection (skips users who are AFK) * βœ… Typing indicator before sending (human-like behavior) * βœ… Custom message support with @mentions * βœ… Error handling for non-group chats */ module.exports.config = { name: "ping", version: "1.0.5", role: 0, author: "π“†©π‘…π‘œπ’·π’Ύπ“ƒπ“†ͺ π’œπ“π’Ύ", description: "Tag all members", category: "system", usages: "[Text]", countDown: 80, }; module.exports.onStart = async function ({ api, event, args }) { try { const botID = api.getCurrentUserID(); var listAFK, listUserID; // Initialize moduleData if not exists and get AFK list safely if (!global.moduleData) global.moduleData = {}; const afkData = global.moduleData["afk"]; listAFK = afkData && afkData.afkList ? Object.keys(afkData.afkList) : []; // Check if participantIDs exists (works in groups only) if (!event.participantIDs || event.participantIDs.length === 0) { return global.sendMessageWithTyping( "πŸ“ Pong! Bot is active πŸ’™", event.threadID, null, event.messageID ); } listUserID = event.participantIDs.filter( (ID) => ID != botID && ID != event.senderID ); listUserID = listUserID.filter((item) => !listAFK.includes(item)); // Default message if no custom text provided var body = args.length != 0 ? args.join(" ") : "πŸ“’ Everyone, attention please!", mentions = [], index = 0; for (const idUser of listUserID) { body = "β€Ž" + body; mentions.push({ id: idUser, tag: "β€Ž", fromIndex: index - 1 }); index -= 1; } return global.sendMessageWithTyping( { body, mentions }, event.threadID, null, event.messageID ); } catch (e) { console.error("Ping command error:", e); return global.sendMessageWithTyping( "πŸ“ Pong! Bot is active πŸ’™", event.threadID, null, event.messageID ); } };