-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
70 lines (62 loc) · 2.26 KB
/
index.js
File metadata and controls
70 lines (62 loc) · 2.26 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
const Discord = require("discord.js");
const client = new Discord.Client()
const prefix = ("-");
const osu = require('node-os-utils')
const mem = osu.mem
const drive = osu.drive
const cpu = osu.cpu
const os = osu.os
client.on("ready",()=>{
client.user.setActivity("type -usage to get the resource usage of the machine");
console.log("=+=+=+=+=+=+=+=+=+=+=+=");
console.log("Name: Machine-Usage");
console.log("Version: 1.0.0");
console.log("Loaded: true");
console.log("=+=+=+=+=+=+=+=+=+=+=+=");
});
client.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (command === 'usage') {
mem.info().then(Ram => {
drive.info().then(Disk => {
cpu.usage().then(Cpu => {
let time = os.uptime();
let hours = secondsToHms(time);
let DeviceIP = os.ip();
let embed = new Discord.MessageEmbed()
.setAuthor("Falixnodes DE14 Information")
.setThumbnail("https://cdn.glitch.com/6edec68b-6816-4250-9325-b720fb913050%2F0x0.png?v=1601738282858")
.setFooter("💕CodeCannibals Development")
.setColor("00B5FF")
.setDescription("**__Node Statistics:__**```" + `Memory Usage: ${Ram.usedMemMb}MB/${Ram.totalMemMb}MB\nDisk Usage: ${Disk.usedGb}GB/${Disk.totalGb}GB\nNode: Online\nCpu Usage: ${Cpu}%\nUptime: ${hours}\nIp: ${DeviceIP}`+"```**__Physical Statistics:__**```" + `Cpu: ${cpu.count()}Cores | ${cpu.model()}` + "```")
message.channel.send(embed);
})
})
})
}
})
client.login("BOT TOKEN");
function secondsToHms(seconds) {
if (!seconds) return '';
let duration = seconds;
let hours = duration / 3600;
duration = duration % (3600);
let min = parseInt(duration / 60);
duration = duration % (60);
let sec = parseInt(duration);
if (sec < 10) {
sec = `0${sec}`;
}
if (min < 10) {
min = `0${min}`;
}
if (parseInt(hours, 10) > 0) {
return `${parseInt(hours, 10)}h ${min}m ${sec}s`
} else if (min == 0) {
return `${sec}s`
} else {
return `${min}m ${sec}s`
}
}