(sock, message, args, context)
| 8 | usage: '.alive', |
| 9 | isPrefixless: true, |
| 10 | async handler(sock, message, args, context) { |
| 11 | const { chatId, config } = context; |
| 12 | try { |
| 13 | let uptime = Math.floor(process.uptime()); |
| 14 | const days = Math.floor(uptime / 86400); |
| 15 | uptime %= 86400; |
| 16 | const hours = Math.floor(uptime / 3600); |
| 17 | uptime %= 3600; |
| 18 | const minutes = Math.floor(uptime / 60); |
| 19 | const seconds = (Number(uptime) % Number(60)); |
| 20 | const uptimeParts = []; |
| 21 | if (days) |
| 22 | uptimeParts.push(`${days}d`); |
| 23 | if (hours) |
| 24 | uptimeParts.push(`${hours}h`); |
| 25 | if (minutes) |
| 26 | uptimeParts.push(`${minutes}m`); |
| 27 | if (seconds || uptimeParts.length === 0) |
| 28 | uptimeParts.push(`${seconds}s`); |
| 29 | const uptimeText = uptimeParts.join(' '); |
| 30 | const totalMem = (os.totalmem() / 1024 / 1024).toFixed(2); |
| 31 | const freeMem = (os.freemem() / 1024 / 1024).toFixed(2); |
| 32 | const usedMem = (Number(totalMem) - Number(freeMem)).toFixed(2); |
| 33 | const cpuLoad = os.loadavg()[0].toFixed(2); |
| 34 | const platform = os.platform(); |
| 35 | const arch = os.arch(); |
| 36 | const nodeVersion = process.version; |
| 37 | const text = `*🤖 ${config.botName} IS ACTIVE!*\n\n` + |
| 38 | `*Version:* ${config.version}\n` + |
| 39 | `*Uptime:* ${uptimeText}\n` + |
| 40 | `*RAM Usage:* ${usedMem} MB / ${totalMem} MB\n` + |
| 41 | `*CPU Load:* ${cpuLoad}\n` + |
| 42 | `*Platform:* ${platform} (${arch})\n` + |
| 43 | `*Node.js:* ${nodeVersion}\n`; |
| 44 | await sock.sendMessage(chatId, { |
| 45 | text, |
| 46 | contextInfo: { |
| 47 | forwardingScore: 999, |
| 48 | isForwarded: true, |
| 49 | forwardedNewsletterMessageInfo: { |
| 50 | newsletterJid: '120363319098372999@newsletter', |
| 51 | newsletterName: 'GlobalTechInc', |
| 52 | serverMessageId: -1 |
| 53 | } |
| 54 | } |
| 55 | }, { quoted: message }); |
| 56 | } |
| 57 | catch (error) { |
| 58 | console.error('Error in alive command:', error); |
| 59 | await sock.sendMessage(chatId, { text: '✅ Bot is alive and running!' }, { quoted: message }); |
| 60 | } |
| 61 | } |
| 62 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected