(sock, message, args, context)
| 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 | }; |
nothing calls this directly
no test coverage detected