made it better
This commit is contained in:
parent
859ba207c3
commit
f7af6745ca
1 changed files with 11 additions and 20 deletions
|
@ -1,8 +1,7 @@
|
||||||
const { Command } = require('discord-akairo');
|
const { Command } = require('discord-akairo');
|
||||||
const akairoVersion = require('discord-akairo').version;
|
const akairoVersion = require('discord-akairo').version;
|
||||||
const { version } = require('discord.js');
|
const { version } = require('discord.js');
|
||||||
const util = require('util');
|
const os = require('os');
|
||||||
const exec = util.promisify(require('child_process').exec);
|
|
||||||
|
|
||||||
class StatsCommand extends Command {
|
class StatsCommand extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -36,20 +35,12 @@ class StatsCommand extends Command {
|
||||||
if (seconds > 0) segments.push(seconds + ' second' + ((seconds == 1) ? '' : 's'));
|
if (seconds > 0) segments.push(seconds + ' second' + ((seconds == 1) ? '' : 's'));
|
||||||
const dateString = segments.join(', ');
|
const dateString = segments.join(', ');
|
||||||
|
|
||||||
const used = process.memoryUsage().heapUsed / 1024 / 1024;
|
const bytesToSize = (bytes) => {
|
||||||
|
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
||||||
// Get cpu model
|
if (bytes == 0) return '0 Byte';
|
||||||
let cpu;
|
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
|
||||||
if (process.platform == 'darwin') {
|
return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
|
||||||
const { stdout } = await exec('sysctl -n machdep.cpu.brand_string');
|
};
|
||||||
cpu = stdout;
|
|
||||||
} else if (process.platform == 'linux') {
|
|
||||||
const { stdout } = await exec('lscpu | grep "Model name:" | sed -r \'s/Model name:\\s{1,}//g\'');
|
|
||||||
cpu = stdout;
|
|
||||||
} else if (process.platform == 'win32') {
|
|
||||||
const { stdout } = await exec('wmic CPU get NAME');
|
|
||||||
cpu = stdout.replace('Name', '');
|
|
||||||
}
|
|
||||||
|
|
||||||
const statsEmbed = this.client.util.embed()
|
const statsEmbed = this.client.util.embed()
|
||||||
.setColor(message.member ? message.member.displayHexColor : 'NAVY')
|
.setColor(message.member ? message.member.displayHexColor : 'NAVY')
|
||||||
|
@ -58,10 +49,10 @@ class StatsCommand extends Command {
|
||||||
.addField('Servers', this.client.guilds.cache.size, true)
|
.addField('Servers', this.client.guilds.cache.size, true)
|
||||||
.addField('Channels', this.client.channels.cache.size, true)
|
.addField('Channels', this.client.channels.cache.size, true)
|
||||||
.addField('Users', this.client.users.cache.size, true)
|
.addField('Users', this.client.users.cache.size, true)
|
||||||
.addField('Uptime', dateString, true)
|
.addField('Uptime', dateString)
|
||||||
.addField('Ram usage', `${Math.round(used * 100) / 100} MB`, true)
|
.addField('Ram usage', `${bytesToSize(process.memoryUsage().heapUsed)}/${bytesToSize(os.totalmem)}`, true)
|
||||||
.addField('CPU', cpu, true)
|
.addField('CPU', `${os.cpus()[0].model} (${os.cpus().length} core)`, true)
|
||||||
.addField('OS', process.platform, true)
|
.addField('OS', `${os.platform()} ${os.release()}`, true)
|
||||||
.addField('Nodejs version', process.version, true)
|
.addField('Nodejs version', process.version, true)
|
||||||
.addField('Discord.js version', version, true)
|
.addField('Discord.js version', version, true)
|
||||||
.addField('Discord-Akairo version', akairoVersion, true)
|
.addField('Discord-Akairo version', akairoVersion, true)
|
||||||
|
|
Loading…
Reference in a new issue