2021-05-05 12:57:42 +00:00
|
|
|
import Command from '../../handler/structures/Command';
|
|
|
|
import { Context, Usage } from '../../utils/types';
|
|
|
|
import lingua from '../../utils/lingua';
|
2021-05-07 23:57:48 +00:00
|
|
|
import { MessageEmbed } from 'discord.js';
|
2021-05-05 12:57:42 +00:00
|
|
|
import CommandUsage from '../../utils/command.usage';
|
2021-05-23 03:59:25 +00:00
|
|
|
import { commitHash } from "../../utils/git"
|
|
|
|
|
|
|
|
function uptime(ms: number) {
|
|
|
|
function pad(s: number) {
|
|
|
|
return (s < 10 ? '0' : '') + s;
|
|
|
|
}
|
|
|
|
var days = Math.floor(ms / (24 * ((60 * 60))));
|
|
|
|
var hours = Math.floor(ms / (60 * 60));
|
|
|
|
var minutes = Math.floor((ms % (60 * 60)) / 60);
|
|
|
|
var seconds = Math.floor(ms % 60);
|
|
|
|
return `${pad(days)}d ${pad(hours)}h ${pad(minutes)}m ${pad(seconds)}s`
|
|
|
|
// return pad(hours) + 'h ' + pad(minutes) + 'm ' + pad(seconds) + 's';
|
|
|
|
}
|
2021-05-05 12:57:42 +00:00
|
|
|
|
|
|
|
export = class Stats extends Command {
|
|
|
|
constructor() {
|
|
|
|
super({
|
|
|
|
name: "stats",
|
|
|
|
description: "See the Bot's Stats",
|
|
|
|
aliases: ["statistics"],
|
|
|
|
cooldown: 1,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
async command(ctx: Context) {
|
2021-05-23 03:59:25 +00:00
|
|
|
// @ts-ignore
|
|
|
|
const guilds = (await ctx.client.shard?.fetchClientValues(`guilds.cache.size`)).reduce((a, b) => a + b, 0)
|
|
|
|
const shards = ctx.client.shard?.count
|
|
|
|
const users = (await ctx.client.shard?.fetchClientValues(`users.cache.size`))?.reduce((a, b) => a + b, 0)
|
|
|
|
|
|
|
|
let MiscValues = [
|
|
|
|
`Uptime: **${uptime(process.uptime())}**`,
|
|
|
|
`Guilds: **${guilds}**`,
|
|
|
|
`Shards: **${shards}**`,
|
|
|
|
`Users: **${users}**`
|
|
|
|
]
|
|
|
|
|
|
|
|
let embed = new MessageEmbed().setColor(ctx.config.variables.color).setFooter(`${ctx.config.variables.name} v${ctx.config.pkg.version} [${commitHash}]`, ctx.config.variables.avatar)
|
|
|
|
.setTitle(`Statistics`)
|
|
|
|
.setDescription(`Visit [our System Dashboard](https://system.thaldr.in) for more in-depth stats`)
|
|
|
|
.addField(`Misc`, MiscValues.map((value) => `${value}`))
|
|
|
|
|
2021-05-05 12:57:42 +00:00
|
|
|
|
2021-05-23 03:59:25 +00:00
|
|
|
ctx.channel.send(embed)
|
2021-05-05 12:57:42 +00:00
|
|
|
}
|
|
|
|
}
|