forked from AyGemuy/Taylor-V2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot-info.js
More file actions
75 lines (75 loc) · 2.77 KB
/
Copy pathbot-info.js
File metadata and controls
75 lines (75 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import {
cpus as _cpus,
totalmem,
freemem
} from "os";
import {
performance
} from "perf_hooks";
import {
sizeFormatter
} from "human-readable";
import {
join
} from "path";
import {
promises
} from "fs";
import {
clockString
} from "../../lib/other-function.js";
import moment from "moment-timezone";
const more = String.fromCharCode(8206),
readMore = more.repeat(4001),
format = sizeFormatter({
std: "JEDEC",
decimalPlaces: 2,
keepTrailingZeroes: !1,
render: (literal, symbol) => `${literal} ${symbol}B`
}),
handler = async (m, {
conn,
__dirname
}) => {
try {
let date = moment.tz("Asia/Jakarta").format("dddd, Do MMMM, YYYY"),
time = moment.tz("Asia/Jakarta").format("HH:mm:ss"),
_package = JSON.parse(await promises.readFile(join(__dirname, "../package.json")).catch(_ => "{}")) || {},
uptime = clockString(1e3 * process.uptime()),
totalreg = Object.keys(db.data.users).length,
rtotalreg = Object.values(db.data.users).filter(user => user.registered).length;
const chats = Object.entries(conn.chats).filter(([id, data]) => id && data.isChats),
groupsIn = chats.filter(([id]) => id.endsWith("@g.us")),
cpus = (process.memoryUsage(), _cpus().map(cpu => (cpu.total = Object.values(cpu.times).reduce((last, type) => last + type, 0), cpu)));
cpus.reduce((last, cpu, _, {
length
}) => ({
total: last.total + cpu.total,
speed: last.speed + cpu.speed / length,
times: {
user: last.times.user + cpu.times.user,
nice: last.times.nice + cpu.times.nice,
sys: last.times.sys + cpu.times.sys,
idle: last.times.idle + cpu.times.idle,
irq: last.times.irq + cpu.times.irq
}
}), {
speed: 0,
total: 0,
times: {
user: 0,
nice: 0,
sys: 0,
idle: 0,
irq: 0
}
});
let speed = performance.now() - performance.now(),
capti = `🤖 Nama: ${_package.name || "N/A"}\n🔢 Versi: ${_package.version || "N/A"}\n📚 Library: ${_package.description || "N/A"}\n\n⏳ Waktu Aktif: ${uptime}\n📈 Pengguna Terdaftar: ${totalreg} (${rtotalreg} terverifikasi)\n\n📅 Tanggal: ${date}\n⌚ Waktu: ${time} (GMT +7)\n\n💻 Info Server:\n⮕ Ping: ${speed.toFixed(2)} ms\n⮕ RAM: ${format(totalmem() - freemem())} / ${format(totalmem())}\n\n💬 Status WhatsApp:\n⮕ ${groupsIn.length} Grup Chat\n⮕ ${groupsIn.length} Grup Bergabung\n⮕ ${chats.length - groupsIn.length} Chat Pribadi\n⮕ ${chats.length} Total Chat`.trim();
m.reply(capti);
} catch (error) {
console.error(error);
}
};
handler.help = ["botinfo"], handler.tags = ["info"], handler.command = /^(bot(info)?|infobot)$/i;
export default handler;