← back to browse
goat command

upt

Check bot uptime, memory & CPU

0
views
0
likes
0
installs

Aliases: upt, rtm, runtime

raw source
module.exports = {
 config: {
 name: "upt",
 aliases: ["upt", "rtm", "runtime"],
 version: "1.7",
 author: "๐—ง๐—  ^ใ€ฒ๐— ๐—”๐— ๐—จ๐—กใƒ„เฟ โฐโฐโท",
 countDown: 5,
 role: 0,
 shortDescription: {
 en: "Check bot uptime, memory & CPU",
 vi: "Xem uptime, bแป™ nhแป› vร  CPU"
 },
 description: {
 en: "Shows bot uptime, memory and CPU usage",
 vi: "Hiแปƒn thแป‹ thแปi gian, bแป™ nhแป› vร  CPU cแปงa bot"
 },
 category: "info",
 guide: {
 en: "{pn}",
 vi: "{pn}"
 }
 },

 onStart: async function ({ message }) {
 // Uptime
 const time = process.uptime();
 const hours = Math.floor(time / (60 * 60));
 const minutes = Math.floor((time % (60 * 60)) / 60);
 const seconds = Math.floor(time % 60);
 const uptimeStr = `${hours}h ${minutes}m ${seconds}s`;

 // Start time
 const startTime = new Date(Date.now() - process.uptime() * 1000);
 const startStr = startTime.toLocaleString("en-BD", {
 timeZone: "Asia/Dhaka",
 hour12: true
 });

 // Memory
 const memory = process.memoryUsage();
 const usedMB = (memory.heapUsed / 1024 / 1024).toFixed(2);
 const totalMB = (memory.heapTotal / 1024 / 1024).toFixed(2);
 const freeMB = (totalMB - usedMB).toFixed(2);

 // CPU
 const cpuUsage = process.cpuUsage();
 const totalCPU = (cpuUsage.user + cpuUsage.system) / 1000;
 const cpuPercent = ((totalCPU / (process.uptime() * 1000)) * 100).toFixed(2);

 // Prefix (safe way)
 let prefix = "/";
 try {
 prefix = global.GoatBot?.config?.prefix || "/";
 } catch (e) {
 prefix = "/";
 }

 const msg = 
`โฐ ๐—•๐—ข๐—ง ๐—ฆ๐—ง๐—”๐—ง๐—จ๐—ฆ

โณ ๐—จ๐—ฝ๐˜๐—ถ๐—บ๐—ฒ
โžค ๐—ฅ๐˜‚๐—ป๐—ป๐—ถ๐—ป๐—ด: ${uptimeStr}
โžค ๐—ฆ๐˜๐—ฎ๐—ฟ๐˜๐—ฒ๐—ฑ: ${startStr}
โžค ๐—ฃ๐—ฟ๐—ฒ๐—ณ๐—ถ๐˜…: ${prefix}

๐Ÿ’พ ๐— ๐—ฒ๐—บ๐—ผ๐—ฟ๐˜†
โžค ๐—จ๐˜€๐—ฒ๐—ฑ: ${usedMB} ๐— ๐—•
โžค ๐—ง๐—ผ๐˜๐—ฎ๐—น: ${totalMB} ๐— ๐—•
โžค ๐—™๐—ฟ๐—ฒ๐—ฒ: ${freeMB} ๐— ๐—•

๐Ÿ–ฅ๏ธ ๐—–๐—ฃ๐—จ
โžค ๐—จ๐˜€๐—ฎ๐—ด๐—ฒ: ${cpuPercent}%`;

 return message.reply(msg);
 }
};

View raw file