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

Function handler

plugins/warnings.js:30–48  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

28 usage: '.warnings [@user]',
29 groupOnly: true,
30 async handler(sock, message, args, context) {
31 const { chatId, channelInfo } = context;
32 const mentionedJidList = message.message?.extendedTextMessage?.contextInfo?.mentionedJid || [];
33 if (mentionedJidList.length === 0) {
34 await sock.sendMessage(chatId, {
35 text: 'Please mention a user to check warnings.',
36 ...channelInfo
37 }, { quoted: message });
38 return;
39 }
40 const userToCheck = mentionedJidList[0];
41 const warnings = await loadWarnings();
42 const warningCount = (warnings[chatId] && warnings[chatId][userToCheck]) || 0;
43 await sock.sendMessage(chatId, {
44 text: `@${userToCheck.split('@')[0]} has ${warningCount} warning(s).\n\nStorage: ${HAS_DB ? 'Database' : 'File System'}`,
45 mentions: [userToCheck],
46 ...channelInfo
47 }, { quoted: message });
48 }
49};

Callers

nothing calls this directly

Calls 1

loadWarningsFunction · 0.85

Tested by

no test coverage detected