// code from goatstore // api: https://store.agi.bd module.exports.config = { name: "serverstatus", version: "2.1.0", author: "Zihad", countDown: 5, role: 0, shortDescription: "Animated server status", longDescription: "Shows live animated server status", category: "system", guide: "{pn}" }; module.exports.onStart = async function ({ api, event }) { const os = require("os"); const process = require("process"); const sleep = (ms) => { return new Promise((resolve) => setTimeout(resolve, ms)); }; try { // ───────── LOADING ───────── const msg = await api.sendMessage( `╭━━〔 🖥️ SERVER STATUS 〕━━╮ ┃ ┃ 🔄 Initializing server... ┃ ┃ ▰▱▱▱▱▱▱▱▱▱ 10% ┃ ╰━━━━━━━━━━━━━━━━━━╯`, event.threadID ); await sleep(500); await api.editMessage( `╭━━〔 🖥️ SERVER STATUS 〕━━╮ ┃ ┃ 🔄 Checking CPU... ┃ 🔋 Checking RAM... ┃ ┃ ▰▰▰▱▱▱▱▱▱▱ 30% ┃ ╰━━━━━━━━━━━━━━━━━━╯`, msg.messageID ); await sleep(500); await api.editMessage( `╭━━〔 🖥️ SERVER STATUS 〕━━╮ ┃ ┃ 🔄 Checking storage... ┃ 🌐 Checking system... ┃ ┃ ▰▰▰▰▰▰▱▱▱▱ 60% ┃ ╰━━━━━━━━━━━━━━━━━━╯`, msg.messageID ); await sleep(500); await api.editMessage( `╭━━〔 🖥️ SERVER STATUS 〕━━╮ ┃ ┃ ⚡ Finalizing... ┃ 📡 Checking connection... ┃ ┃ ▰▰▰▰▰▰▰▰▰▱ 90% ┃ ╰━━━━━━━━━━━━━━━━━━╯`, msg.messageID ); await sleep(600); // ───────── UPTIME ───────── const uptime = process.uptime(); const days = Math.floor(uptime / 86400); const hours = Math.floor((uptime % 86400) / 3600); const minutes = Math.floor((uptime % 3600) / 60); const seconds = Math.floor(uptime % 60); const uptimeText = `${days}d ${hours}h ${minutes}m ${seconds}s`; // ───────── CPU ───────── const cpus = os.cpus() || []; const core = cpus.length || 1; const cpuStart = process.cpuUsage(); const timeStart = process.hrtime(); await sleep(300); const timeDiff = process.hrtime(timeStart); const elapsed = timeDiff[0] + timeDiff[1] / 1000000000; const cpuDiff = process.cpuUsage(cpuStart); let cpu = ((cpuDiff.user + cpuDiff.system) / 1000000) / (elapsed * core) * 100; if (!isFinite(cpu)) { cpu = 0; } cpu = Math.max(0, Math.min(100, cpu)); // ───────── RAM ───────── const totalRAM = os.totalmem(); const freeRAM = os.freemem(); const usedRAM = totalRAM - freeRAM; const ramUsed = usedRAM / 1024 / 1024 / 1024; const ramTotal = totalRAM / 1024 / 1024 / 1024; const ramPercent = totalRAM > 0 ? (usedRAM / totalRAM) * 100 : 0; // ───────── PROCESS RAM ───────── const processRAM = process.memoryUsage().rss / 1024 / 1024; // ───────── STATUS ───────── let status = "🟢 ONLINE"; if (cpu >= 90 || ramPercent >= 90) { status = "🟡 HIGH LOAD"; } // ───────── SYSTEM ───────── const platform = os.platform(); const arch = os.arch(); const nodeVersion = process.version; const hostname = os.hostname(); // ───────── PING ───────── const pingStart = Date.now(); await Promise.resolve(); const ping = Date.now() - pingStart; // ───────── FINAL ───────── const finalMessage = `╭━━━〔 ⚡ SERVER STATUS 〕━━━╮ ┃ ┃ 🟢 SERVER ONLINE ┃ ╰─ Bot is running normally ┃ ┣━━━━━━━━━━━━━━━━━━━━━━ ┃ ┃ ⏱️ UPTIME ┃ └ ${uptimeText} ┃ ┃ 📡 PING ┃ └ ${ping} ms ┃ ┃ 🧠 CPU ┃ ├ Usage : ${cpu.toFixed(1)}% ┃ └ Core : ${core} ┃ ┃ 💾 MEMORY ┃ ├ Used : ${ramUsed.toFixed(2)} GB ┃ ├ Total : ${ramTotal.toFixed(2)} GB ┃ └ Load : ${ramPercent.toFixed(1)}% ┃ ┃ 💿 PROCESS RAM ┃ └ ${processRAM.toFixed(1)} MB ┃ ┣━━━━━━━━━━━━━━━━━━━━━━ ┃ ┃ ⚙️ SYSTEM ┃ ├ OS : ${platform} ┃ ├ Arch : ${arch} ┃ └ Node : ${nodeVersion} ┃ ┃ 🖥️ HOST ┃ └ ${hostname} ┃ ┣━━━━━━━━━━━━━━━━━━━━━━ ┃ ┃ ⚡ STATUS : ${status} ┃ 🔥 SERVER : HEALTHY ┃ ╰━━━━━━━━━━━━━━━━━━━━━━╯ ✦ ZIHAD SERVER MONITOR ✦`; await api.editMessage( finalMessage, msg.messageID ); } catch (error) { console.error("SERVER STATUS ERROR:", error); try { return api.sendMessage( `╭━━〔 ❌ SERVER STATUS 〕━━╮ ┃ ┃ Server status পাওয়া যায়নি। ┃ ┃ ⚠️ ${error.message || "Unknown error"} ┃ ╰━━━━━━━━━━━━━━━━━━╯`, event.threadID ); } catch (e) { console.error("SEND ERROR:", e); } } };