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

Function handler

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected