2021-12-23 22:36:13 -05:00
|
|
|
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 {
|
2022-03-01 12:18:21 -05:00
|
|
|
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' });
|
2021-12-23 22:36:13 -05:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|