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

Function handler

plugins/staff.js:8–44  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

6 usage: '.staff',
7 groupOnly: true,
8 async handler(sock, message, args, context) {
9 const { chatId, channelInfo } = context;
10 try {
11 const groupMetadata = await sock.groupMetadata(chatId);
12 let pp;
13 try {
14 pp = await sock.profilePictureUrl(chatId, 'image');
15 }
16 catch {
17 pp = 'https://i.imgur.com/2wzGhpF.jpeg';
18 }
19 const participants = groupMetadata.participants;
20 const groupAdmins = participants.filter((p) => p.admin);
21 const listAdmin = groupAdmins.map((v, i) => `${i + 1}. @${v.id.split('@')[0]}`).join('\n▢ ');
22 const owner = groupMetadata.owner || groupAdmins.find((p) => p.admin === 'superadmin')?.id || `${chatId.split('-')[0] }@s.whatsapp.net`;
23 const text = `
24≡ *GROUP ADMINS* _${groupMetadata.subject}_
25
26┌─⊷ *ADMINS*
27▢ ${listAdmin}
28└───────────
29`.trim();
30 await sock.sendMessage(chatId, {
31 image: { url: pp },
32 caption: text,
33 mentions: [...groupAdmins.map((v) => v.id), owner],
34 ...channelInfo
35 });
36 }
37 catch (error) {
38 console.error('Error in staff command:', error);
39 await sock.sendMessage(chatId, {
40 text: 'Failed to get admin list!',
41 ...channelInfo
42 }, { quoted: message });
43 }
44 }
45};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected