(sock, message, args, context)
| 21 | usage: '.perf', |
| 22 | ownerOnly: true, |
| 23 | async handler(sock, message, args, context) { |
| 24 | const chatId = context.chatId || message.key.remoteJid; |
| 25 | try { |
| 26 | const report = CommandHandler.getDiagnostics(); |
| 27 | if (!report || report.length === 0) { |
| 28 | return await sock.sendMessage(chatId, { text: '_No performance data collected yet._' }, { quoted: message }); |
| 29 | } |
| 30 | let text = `📊 *PLUGINS PERFORMANCE*\n\n`; |
| 31 | report.forEach((cmd, index) => { |
| 32 | const errorText = cmd.errors > 0 ? `❗ Errors: ${cmd.errors}` : `✅ Smooth`; |
| 33 | text += `${index + 1}. *${cmd.command.toUpperCase()}*\n`; |
| 34 | text += ` ↳ Calls: ${cmd.usage}\n`; |
| 35 | text += ` ↳ Latency: ${cmd.average_speed}\n`; |
| 36 | text += ` ↳ Status: ${errorText}\n\n`; |
| 37 | }); |
| 38 | await sock.sendMessage(chatId, { |
| 39 | text: text.trim(), |
| 40 | contextInfo: { |
| 41 | forwardingScore: 999, |
| 42 | isForwarded: true, |
| 43 | forwardedNewsletterMessageInfo: { |
| 44 | newsletterJid: '120363319098372999@newsletter', |
| 45 | newsletterName: 'MEGA MD PERFORMANCE', |
| 46 | serverMessageId: -1 |
| 47 | } |
| 48 | } |
| 49 | }, { quoted: message }); |
| 50 | } |
| 51 | catch (error) { |
| 52 | console.error('Error in perf command:', error); |
| 53 | await sock.sendMessage(chatId, { text: '❌ Failed to fetch performance metrics.' }, { quoted: message }); |
| 54 | } |
| 55 | } |
| 56 | }; |
| 57 | /***************************************************************************** |
| 58 | * * |
nothing calls this directly
no test coverage detected