← back to browse
goat command

health

Show bot & server health status

0
views
0
likes
0
installs
raw source
const os = require("os");

module.exports.config = {
  name: "health",
  version: "1.0.0",
  role: 0, // সবাই ব্যবহার করঀে ΰ¦ͺারবে
  author: "π“†©π‘…π‘œπ’·π’Ύπ“ƒπ“†ͺ π’œπ“π’Ύ",
  description: "Show bot & server health status",
  category: "system",
  usages: "/health",
  countDown: 5
};

module.exports.onStart = async function ({ api, event }) {
  try {
    const uptime = process.uptime(); // seconds
    const uptimeH = Math.floor(uptime / 3600);
    const uptimeM = Math.floor((uptime % 3600) / 60);
    const uptimeS = Math.floor(uptime % 60);

    const memory = process.memoryUsage();
    const usedMB = (memory.rss / 1024 / 1024).toFixed(2);
    const heapMB = (memory.heapUsed / 1024 / 1024).toFixed(2);

    const cpuLoad = os.loadavg()[0].toFixed(2);
    const totalMem = (os.totalmem() / 1024 / 1024).toFixed(0);
    const freeMem = (os.freemem() / 1024 / 1024).toFixed(0);

    const statusMsg =
`🩺 BOT HEALTH STATUS

πŸ€– Bot Name: ${global.config?.BOTNAME || "Moyna"}
⚑ Status: ONLINE
πŸ•’ Uptime: ${uptimeH}h ${uptimeM}m ${uptimeS}s

🧠 Memory:
β€’ Used (RSS): ${usedMB} MB
β€’ Heap Used: ${heapMB} MB

πŸ–₯ Server:
β€’ CPU Load: ${cpuLoad}
β€’ RAM: ${freeMem} MB free / ${totalMem} MB total
β€’ Platform: ${process.platform}

🌍 Environment:
β€’ Node: ${process.version}
β€’ PID: ${process.pid}

βœ… All systems operational`;

    api.sendMessage(statusMsg, event.threadID);

  } catch (err) {
    api.sendMessage(
      "❌ Health check failed. Something went wrong.",
      event.threadID
    );
  }
};

View raw file