import { Message } from 'eris'; import { Client, Command, RichEmbed } from '../class'; export default class Stats extends Command { constructor(client: Client) { super(client); this.name = 'stats'; this.description = 'Provides system statistics.'; this.usage = `${this.client.config.prefix}stats`; this.permissions = 0; this.guildOnly = false; this.enabled = true; } public async run(message: Message) { try { const messages = await this.client.db.mongo.Stat.findOne({ name: 'messages' }); const commands = await this.client.db.mongo.Stat.findOne({ name: 'commands' }); const pages = await this.client.db.mongo.Stat.findOne({ name: 'pages' }); const requests = await this.client.db.mongo.Stat.findOne({ name: 'requests' }); const embed = new RichEmbed(); embed.setTitle('Statistics'); embed.setThumbnail(this.client.user.avatarURL); embed.addField('Messages Seen', `${messages.value}`, true); embed.addField('Commands Executed', `${commands.value}`, true); embed.addField('HTTP Requests Served', `${requests.value}`, true); embed.addField('Pages Sent', `${pages.value}`, true); embed.addField('Jobs Processed', `${(await this.client.queue.jobCounts()).completed}`, true); embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setTimestamp(); return message.channel.createMessage({ embed }); } catch (err) { return this.client.util.handleError(err, message, this); } } }