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

Function handler

plugins/invitelink.js:9–44  ·  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 isBotAdmin = context.isBotAdmin || false;
14 const isRevoke = rawText.startsWith('.revokeinvite') || rawText.startsWith('.resetlink') || args[0]?.toLowerCase() === 'revoke';
15 if (isRevoke && !isBotAdmin) {
16 return await sock.sendMessage(chatId, {
17 text: `❌ Bot needs to be an admin to revoke the invite link.`,
18 ...channelInfo
19 }, { quoted: message });
20 }
21 try {
22 if (isRevoke) {
23 const newCode = await sock.groupRevokeInvite(chatId);
24 return await sock.sendMessage(chatId, {
25 text: `🔄 *Invite link reset!*\n\n*New Link:*\nhttps://chat.whatsapp.com/${newCode}`,
26 ...channelInfo
27 }, { quoted: message });
28 }
29 else {
30 const code = await sock.groupInviteCode(chatId);
31 return await sock.sendMessage(chatId, {
32 text: `🔗 *Group Invite Link*\n\nhttps://chat.whatsapp.com/${code}\n\n_Use \`.revokeinvite\` to reset this link._`,
33 ...channelInfo
34 }, { quoted: message });
35 }
36 }
37 catch (e) {
38 console.error('[INVITELINK] Error:', e.message);
39 await sock.sendMessage(chatId, {
40 text: `❌ Failed: ${e.message}`,
41 ...channelInfo
42 }, { quoted: message });
43 }
44 }
45};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected