37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
|
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.Stat.findOne({ name: 'messages' });
|
||
|
const commands = await this.client.db.Stat.findOne({ name: 'commands' });
|
||
|
const pages = await this.client.db.Stat.findOne({ name: 'pages' });
|
||
|
const requests = await this.client.db.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('Command Executed', `${commands.value}`, true);
|
||
|
embed.addField('HTTP Requests Served', `${requests.value}`, true);
|
||
|
embed.addField('Pages Sent', `${pages.value}`, 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);
|
||
|
}
|
||
|
}
|
||
|
}
|