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);
}
};