Haha-Yes/commands/utility/stats.js

52 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-12-30 01:20:24 +01:00
const { Command } = require('discord-akairo');
2019-01-02 18:45:53 +01:00
const { MessageEmbed } = require('discord.js');
const reload = require('auto-reload');
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',
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) {
const autoresponse = reload('../../json/autoresponse.json');
2019-01-02 22:36:29 +01:00
let autoresponseStatus;
if (autoresponse[message.channel.id] == undefined || autoresponse[message.channel.id] == 'disable')
autoresponseStatus = 'disabled';
else if (autoresponse[message.channel.id] == 'enable')
autoresponseStatus = 'enabled';
2019-01-02 08:09:45 +01:00
let totalSeconds = (this.client.uptime / 1000);
let days = Math.floor(totalSeconds / 86400);
let hours = Math.floor(totalSeconds / 3600);
totalSeconds %= 3600;
let minutes = Math.floor(totalSeconds / 60);
let seconds = totalSeconds.toFixed(0) % 60;
let uptime = `${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds`;
2019-01-02 18:45:53 +01:00
const used = process.memoryUsage().heapUsed / 1024 / 1024;
const statsEmbed = new MessageEmbed()
.setColor('#0099ff')
.setTitle('Bot stats')
.setAuthor('Haha yes')
.addField('Servers', this.client.guilds.size, true)
.addField('Channels', this.client.channels.size, true)
.addField('Users', this.client.users.size, true)
.addField('Uptime', uptime, true)
.addField('Ram usage', `${Math.round(used * 100) / 100} MB`, true)
.addField('Autoresponse in this channel',autoresponseStatus,true)
2019-01-02 18:45:53 +01:00
.setTimestamp()
.setFooter('Powered by Yandex.Translate ');
return message.channel.send(statsEmbed);
2019-01-02 08:09:45 +01:00
}
2018-12-30 01:20:24 +01:00
}
module.exports = StatsCommand;