2018-12-30 01:20:24 +01:00
|
|
|
const { Command } = require('discord-akairo');
|
2019-06-15 21:54:01 +02:00
|
|
|
const akairoVersion = require('discord-akairo').version;
|
2019-11-22 12:30:20 +01:00
|
|
|
const { version } = require('discord.js');
|
2020-04-29 17:08:07 +02:00
|
|
|
const os = require('os');
|
2018-12-25 19:17:07 +01:00
|
|
|
|
2018-12-30 01:20:24 +01:00
|
|
|
class StatsCommand extends Command {
|
2019-01-02 08:09:45 +01:00
|
|
|
constructor() {
|
|
|
|
super('stats', {
|
|
|
|
aliases: ['stats'],
|
|
|
|
category: 'utility',
|
2019-11-09 12:04:01 +01:00
|
|
|
clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'],
|
2019-01-02 08:09:45 +01:00
|
|
|
description: {
|
2018-12-30 01:20:24 +01:00
|
|
|
content: 'Show some stats about the bot',
|
|
|
|
usage: '',
|
|
|
|
examples: ['']
|
|
|
|
}
|
2019-01-02 08:09:45 +01:00
|
|
|
});
|
|
|
|
}
|
2018-09-08 16:10:28 +02:00
|
|
|
|
2019-01-02 08:09:45 +01:00
|
|
|
async exec(message) {
|
2019-06-26 01:38:06 +02:00
|
|
|
var uptime = process.uptime();
|
|
|
|
const date = new Date(uptime*1000);
|
|
|
|
const days = date.getUTCDate() - 1,
|
|
|
|
hours = date.getUTCHours(),
|
|
|
|
minutes = date.getUTCMinutes(),
|
|
|
|
seconds = date.getUTCSeconds();
|
|
|
|
|
|
|
|
|
|
|
|
let segments = [];
|
|
|
|
|
|
|
|
// Format the uptime string.
|
|
|
|
if (days > 0) segments.push(days + ' day' + ((days == 1) ? '' : 's'));
|
|
|
|
if (hours > 0) segments.push(hours + ' hour' + ((hours == 1) ? '' : 's'));
|
|
|
|
if (minutes > 0) segments.push(minutes + ' minute' + ((minutes == 1) ? '' : 's'));
|
|
|
|
if (seconds > 0) segments.push(seconds + ' second' + ((seconds == 1) ? '' : 's'));
|
|
|
|
const dateString = segments.join(', ');
|
|
|
|
|
2020-04-29 17:08:07 +02:00
|
|
|
const bytesToSize = (bytes) => {
|
|
|
|
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
|
|
if (bytes == 0) return '0 Byte';
|
|
|
|
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
|
|
|
|
return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
|
|
|
|
};
|
2019-07-25 07:49:26 +02:00
|
|
|
|
2019-11-22 12:30:20 +01:00
|
|
|
const statsEmbed = this.client.util.embed()
|
2020-03-22 21:54:19 +01:00
|
|
|
.setColor(message.member ? message.member.displayHexColor : 'NAVY')
|
2019-01-02 18:45:53 +01:00
|
|
|
.setTitle('Bot stats')
|
|
|
|
.setAuthor('Haha yes')
|
2020-03-04 02:08:04 +01:00
|
|
|
.addField('Servers', this.client.guilds.cache.size, true)
|
|
|
|
.addField('Channels', this.client.channels.cache.size, true)
|
|
|
|
.addField('Users', this.client.users.cache.size, true)
|
2020-04-29 17:08:07 +02:00
|
|
|
.addField('Uptime', dateString)
|
|
|
|
.addField('Ram usage', `${bytesToSize(process.memoryUsage().heapUsed)}/${bytesToSize(os.totalmem)}`, true)
|
|
|
|
.addField('CPU', `${os.cpus()[0].model} (${os.cpus().length} core)`, true)
|
|
|
|
.addField('OS', `${os.platform()} ${os.release()}`, true)
|
2019-06-15 21:54:01 +02:00
|
|
|
.addField('Nodejs version', process.version, true)
|
|
|
|
.addField('Discord.js version', version, true)
|
|
|
|
.addField('Discord-Akairo version', akairoVersion, true)
|
2019-01-03 17:28:31 +01:00
|
|
|
.setTimestamp();
|
|
|
|
|
2019-01-02 18:45:53 +01:00
|
|
|
return message.channel.send(statsEmbed);
|
2019-01-02 08:09:45 +01:00
|
|
|
}
|
2018-12-30 01:20:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = StatsCommand;
|