goat
command
rtm
Show system & bot stats
0
views
0
likes
0
installs
raw source
const os = require("os");
const pidusage = require("pidusage");
const { execSync } = require("child_process");
module.exports = {
config: {
name: "rtm",
version: "1.6",
author: "๐๐ฟ๐ถ๐๐ฎ๐ป ๐ฏ๐ฏ'๐",
countDown: 10,
role: 0,
shortDescription: {
en: "Show system & bot stats",
bn: "เฆธเฆฟเฆธเงเฆเงเฆฎ เฆเฆฌเฆ เฆฌเฆเงเฆฐ เฆธเงเฆเงเฆฏเฆพเฆเฆพเฆธ เฆฆเงเฆเงเฆจ"
},
longDescription: {
en: "Display CPU, RAM, disk usage, uptime, users, groups etc.",
bn: "CPU, RAM, Disk, Uptime, User, Group เฆเฆคเงเฆฏเฆพเฆฆเฆฟ เฆฆเงเฆเฆพเฆฌเง"
},
category: "system"
},
onStart: async function ({ message, api, event, threadsData, usersData, commands }) {
let sent;
try {
sent = await message.reply(">๐ ๐๐จ๐๐๐ข๐ง๐ ..\nโโ");
const bar = ["โโโโโโ", "โโโโโโโโโโ", "โโโโโโโโโโ"];
for (let i = 0; i < bar.length; i++) {
await new Promise(r => setTimeout(r, 500));
await api.editMessage(`โจ ๐๐จ๐๐๐ข๐ง๐ ...\n${bar[i]}`, sent.messageID);
}
// CPU & Memory usage
const stats = await pidusage(process.pid);
const cpuUsage = stats.cpu.toFixed(2);
const usedMem = stats.memory / 1024 / 1024;
const totalMem = os.totalmem() / 1024 / 1024;
const freeMem = os.freemem() / 1024 / 1024;
// Disk usage
let diskTotal = 0, diskUsed = 0, diskFree = 0;
try {
const df = execSync("df -k --total").toString().split("\n");
const totalLine = df[df.length - 2].trim().split(/\s+/);
diskTotal = (parseInt(totalLine[1]) / 1024 / 1024).toFixed(2);
diskUsed = (parseInt(totalLine[2]) / 1024 / 1024).toFixed(2);
diskFree = (parseInt(totalLine[3]) / 1024 / 1024).toFixed(2);
} catch {
diskTotal = totalMem.toFixed(2);
diskUsed = usedMem.toFixed(2);
diskFree = freeMem.toFixed(2);
}
// Uptime
const botUptime = formatTime(process.uptime() * 1000);
const sysUptime = formatTime(os.uptime() * 1000);
// System info
const cpuModel = os.cpus()[0].model;
const nodeVersion = process.version;
const osVersion = os.version ? os.version() : os.type() + " " + os.release();
const platform = os.platform();
const hostname = os.hostname();
// Bot info
const totalUsers = (await usersData.getAll()).length;
const totalGroups = (await threadsData.getAll()).length;
const totalCommands = commands?.size || 0;
const botName = "๐๐ฟ๐ถ๐๐ฎ๐ป ๐ฏ๐ฏ'๐ ๐๐ผ๐"; // <-- tor bot er nam
const ping = ((Date.now() - event.timestamp) / 1000).toFixed(2);
// Version check
let botVersion = "unknown";
try {
botVersion = require(process.cwd() + "/package.json").version || "unknown";
} catch { }
const info = `
>๐ ๐๐๐๐๐ & ๐๐๐๐๐๐
โข Total Users : ${totalUsers}
โข Total Groups : ${totalGroups}
โข Commands : ${totalCommands}
๐๐๐ ๐๐๐
๐
โข Total RAM : ${totalMem.toFixed(2)} MB
โข Free RAM : ${freeMem.toFixed(2)} MB
โข Used RAM : ${usedMem.toFixed(2)} MB
๐๐๐๐ ๐๐๐๐๐
โข Total Disk : ${diskTotal} GB
โข Used Disk : ${diskUsed} GB
โข Free Disk : ${diskFree} GB
๐๐๐ ๐๐๐๐๐๐
โข Bot Uptime : ${botUptime}
โข Server Uptime : ${sysUptime}
โข Ping : ${ping}s
โข Bot Name : ${botName}
โข Bot Version : ${botVersion}
โข Hostname : ${hostname}
โข Author : ๐๐ฟ๐ถ๐๐ฎ๐ป ๐ฏ๐ฏ'๐
๐๐๐ & ๐๐๐๐๐๐
โข CPU Model : ${cpuModel}
โข CPU Usage : ${cpuUsage}%
โข Platform : ${platform}
โข OS Version : ${osVersion}
โข Node.js : ${nodeVersion}
`.trim();
await new Promise(r => setTimeout(r, 600));
await api.editMessage(info, sent.messageID);
} catch (err) {
if (sent?.messageID) {
api.editMessage("๐
๐๐ข๐ฅ๐๐: " + err.message, sent.messageID);
} else {
message.reply("๐
๐๐ข๐ฅ๐๐: " + err.message);
}
}
}
};
function formatTime(ms) {
const d = Math.floor(ms / (1000 * 60 * 60 * 24));
const h = Math.floor(ms / (1000 * 60 * 60)) % 24;
const m = Math.floor(ms / (1000 * 60)) % 60;
const s = Math.floor(ms / 1000) % 60;
return `${d}d ${h}h ${m}m ${s}s`;
}