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

Function handler

plugins/tagnotadmin.js:9–39  ·  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, channelInfo } = context;
11 try {
12 const groupMetadata = await sock.groupMetadata(chatId);
13 const participants = groupMetadata.participants || [];
14 const nonAdmins = participants.filter((p) => !p.admin).map((p) => p.id);
15 if (nonAdmins.length === 0) {
16 await sock.sendMessage(chatId, {
17 text: 'No non-admin members to tag.',
18 ...channelInfo
19 }, { quoted: message });
20 return;
21 }
22 let text = '🔊 *Hello Everyone:*\n\n';
23 nonAdmins.forEach((jid) => {
24 text += `@${jid.split('@')[0]}\n`;
25 });
26 await sock.sendMessage(chatId, {
27 text,
28 mentions: nonAdmins,
29 ...channelInfo
30 }, { quoted: message });
31 }
32 catch (error) {
33 console.error('Error in tagnotadmin command:', error);
34 await sock.sendMessage(chatId, {
35 text: 'Failed to tag non-admin members.',
36 ...channelInfo
37 }, { quoted: message });
38 }
39 }
40};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected