MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MD / handler

Function handler

plugins/joinrequests.js:9–86  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

7 groupOnly: true,
8 adminOnly: true,
9 async handler(sock, message, args, context) {
10 const chatId = context.chatId || message.key.remoteJid;
11 const channelInfo = context.channelInfo || {};
12 const rawText = (context.rawText || '').toLowerCase();
13 const isApprove = rawText.startsWith('.approvejoin');
14 const isReject = rawText.startsWith('.rejectjoin');
15 // List pending requests
16 if (!isApprove && !isReject) {
17 try {
18 const requests = await sock.groupRequestParticipantsList(chatId);
19 if (!requests || requests.length === 0) {
20 return await sock.sendMessage(chatId, {
21 text: `📋 *Join Requests*\n\n_No pending join requests._`,
22 ...channelInfo
23 }, { quoted: message });
24 }
25 const list = requests.map((r, i) => `${i + 1}. +${r.jid.split('@')[0]}`).join('\n');
26 return await sock.sendMessage(chatId, {
27 text: `╔═══════════════════════╗\n` +
28 `║ 📋 *JOIN REQUESTS* ║\n` +
29 `╚═══════════════════════╝\n\n` +
30 `${list}\n\n` +
31 `──────────────────────────\n` +
32 `*Total:* ${requests.length} pending\n\n` +
33 `• \`.approvejoin all\` — approve all\n` +
34 `• \`.rejectjoin all\` — reject all\n` +
35 `• \`.approvejoin 923001234567\` — approve one`,
36 ...channelInfo
37 }, { quoted: message });
38 }
39 catch (e) {
40 return await sock.sendMessage(chatId, {
41 text: `❌ Failed to fetch requests: ${e.message}`,
42 ...channelInfo
43 }, { quoted: message });
44 }
45 }
46 // Approve or reject
47 const action = isApprove ? 'approve' : 'reject';
48 const input = args[0]?.toLowerCase();
49 try {
50 let targets = [];
51 if (input === 'all') {
52 const requests = await sock.groupRequestParticipantsList(chatId);
53 if (!requests || requests.length === 0) {
54 return await sock.sendMessage(chatId, {
55 text: `⚠️ No pending join requests.`,
56 ...channelInfo
57 }, { quoted: message });
58 }
59 targets = requests.map((r) => r.jid);
60 }
61 else if (input) {
62 const num = input.replace(/[^0-9]/g, '');
63 targets = [`${num}@s.whatsapp.net`];
64 }
65 else {
66 return await sock.sendMessage(chatId, {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected