added stats command

This commit is contained in:
ry 2020-01-20 00:35:54 +01:00
parent 37a08314ea
commit 23ac36c819
5 changed files with 75 additions and 11 deletions

View file

@ -111,10 +111,10 @@ module.exports = {
setTimeout(() => timestamps.delete(msg.author.id), cooldownAmount);
cmd.command(ctx).then(async () => {
ctx.client.channels.find(c => c.id === vars.logs.usage).send(`${ctx.utils.format.bold(ctx.author.tag)} (${ctx.utils.format.code(ctx.author.id)}) used ${ctx.utils.format.code(cmd.name)} in ${ctx.utils.format.bold(ctx.guild.name)} (${ctx.utils.format.code(ctx.guild.id)}) `).catch(e => console.log(e))
if (!ctx.config.type.beta) ctx.client.channels.find(c => c.id === vars.logs.usage).send(`${ctx.utils.format.bold(ctx.author.tag)} (${ctx.utils.format.code(ctx.author.id)}) used ${ctx.utils.format.code(cmd.name)} in ${ctx.utils.format.bold(ctx.guild.name)} (${ctx.utils.format.code(ctx.guild.id)}) `).catch(e => console.log(e))
await ctx.db.backend.add(`usage.${cmd.name}`, 1)
}).catch((err) => {
if (!cmd.name.includes('e926') || !cmd.name.includes('e621')) {
if (!cmd.name === 'e926' || !cmd.name === 'e621') {
trello
.addCard(
cmd.name + ' | ' + err.message,

View file

@ -0,0 +1,63 @@
const Command = require('../../src/structures/Command');
const {
MessageEmbed: Embed
} = require('discord.js')
module.exports = class Statistics extends Command {
constructor() {
super({
name: 'statistics',
description: 'Get in-depth bot Stats',
aliases: ['stats'],
module: 'General',
cooldown: 5,
guildOnly: false,
developerOnly: false,
nsfw: false
});
}
async command(ctx) {
let StatisticsEmbed = new Embed().setTitle(`${ctx.vars.name} v${ctx.vars.version} Statistics`).setColor(ctx.vars.color)
var SortUsage = [];
var SortSL = [];
var SortSF = [];
let usage = ctx.db.backend.get('usage')
let Shortlink = ctx.db.backend.get('Shortlink')
let SourceFynnder = ctx.db.backend.get('SourceFynnder')
// change data value to the one you showed in pic
for (var type in usage) {
SortUsage.push([type, usage[type]]);
}
for (var type in Shortlink) {
SortSL.push([type, Shortlink[type]]);
}
for (var type in SourceFynnder) {
SortSF.push([type, SourceFynnder[type]]);
}
let usages = SortUsage.sort((a, b) => b[1] - a[1])
let SLs = SortSL.sort((a, b) => b[1] - a[1])
let SFs = SortSF.sort((a, b) => b[1] - a[1])
let UsageStats = ''
let SLStats = ''
let SFStats = ''
usages.forEach(use => {
UsageStats += `${ctx.utils.format.bold(use[0])} - \`${use[1]}\`\n`
})
SLs.forEach(SL => {
SLStats += `${ctx.utils.format.bold(SL[0])} - \`${SL[1]}\`\n`
})
SFs.forEach(SF => {
SFStats += `${ctx.utils.format.bold(SF[0]).replace(/found/g,'Found w/')} - \`${SF[1]}\`\n`
})
StatisticsEmbed.addField("Uptime", `${ctx.utils.format.uptime(process.uptime())}`, true)
.addField("Servers", ctx.client.guilds.size, true)
.addField("Users", ctx.client.users.size, true)
.addField('Command Usage', UsageStats, true)
.addField('Shortlink Usage', SLStats, true)
.addField('SourceFynnder Usage', SFStats.replace(/Found w\//, 'Total'), true)
ctx.send(StatisticsEmbed)
}
}

View file

@ -1,5 +0,0 @@
@echo off
title Discord: Thaldrin v3
:start
node index.js
goto start

View file

@ -1,12 +1,17 @@
const { Client, Collection } = require('discord.js');
const { readdirSync: read } = require('fs');
const {
Client,
Collection
} = require('discord.js');
const {
readdirSync: read
} = require('fs');
const server = require('../../Dashboard/server');
module.exports = class Thaldrin extends Client {
constructor(config, shards) {
super({
disableEveryone: true,
disabledEvents: [ 'TYPING_START' ],
disabledEvents: ['TYPING_START'],
shardCount: shards,
totalShardCount: shards
});

View file

@ -72,6 +72,7 @@ module.exports = async function Shortlink(enabled, msg) {
url = ShortLinks[x].replace('$link$', url);
links.push(`<${url}>`);
await backend.add(`Shortlink.${ShortLinkDirs[x]}`, 1);
await backend.add(`Shortlink.total`, 1);
}
}