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

Function handler

plugins/joinrequests.ts:11–96  ·  view source on GitHub ↗
(sock: any, message: any, args: any[], context: BotContext)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected