Add more info about the server its running on

This commit is contained in:
Loïc Bersier 2019-07-25 07:49:26 +02:00
parent fc8379d887
commit e300acc0f2

View file

@ -1,6 +1,8 @@
const { Command } = require('discord-akairo'); const { Command } = require('discord-akairo');
const akairoVersion = require('discord-akairo').version; const akairoVersion = require('discord-akairo').version;
const { MessageEmbed, version } = require('discord.js'); const { MessageEmbed, version } = require('discord.js');
const util = require('util');
const exec = util.promisify(require('child_process').exec);
class StatsCommand extends Command { class StatsCommand extends Command {
constructor() { constructor() {
@ -35,6 +37,19 @@ class StatsCommand extends Command {
const used = process.memoryUsage().heapUsed / 1024 / 1024; const used = process.memoryUsage().heapUsed / 1024 / 1024;
// Get cpu model
let cpu;
if (process.platform == 'darwin') {
const { stdout } = await exec('sysctl -n machdep.cpu.brand_string');
cpu = stdout;
} else if (process.platform == 'linux') {
const { stdout } = await exec('grep -m 1 \'model name\' /proc/cpuinfo');
cpu = stdout;
} else if (process.platform == 'win32') {
const { stdout } = await exec('wmic CPU get NAME');
cpu = stdout;
}
const statsEmbed = new MessageEmbed() const statsEmbed = new MessageEmbed()
.setColor('#0099ff') .setColor('#0099ff')
.setTitle('Bot stats') .setTitle('Bot stats')
@ -44,6 +59,8 @@ class StatsCommand extends Command {
.addField('Users', this.client.users.size, true) .addField('Users', this.client.users.size, true)
.addField('Uptime', dateString, true) .addField('Uptime', dateString, true)
.addField('Ram usage', `${Math.round(used * 100) / 100} MB`, true) .addField('Ram usage', `${Math.round(used * 100) / 100} MB`, true)
.addField('CPU', cpu, true)
.addField('OS', process.platform, 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)