Browse Source

added stats command

master
ry 4 months ago
parent
commit
23ac36c819
5 changed files with 75 additions and 11 deletions
  1. +2
    -2
      DiscordEvents/message.js
  2. +63
    -0
      DiscordModules/General/stats.js
  3. +0
    -5
      run.bat
  4. +9
    -4
      src/client/Client.js
  5. +1
    -0
      utils/src/shortlinks.js

+ 2
- 2
DiscordEvents/message.js 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,


+ 63
- 0
DiscordModules/General/stats.js 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)
}
}

+ 0
- 5
run.bat View File

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

+ 9
- 4
src/client/Client.js 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
});
@@ -53,4 +58,4 @@ module.exports = class Thaldrin extends Client {
});
});
}
};
};

+ 1
- 0
utils/src/shortlinks.js 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);
}
}



Loading…
Cancel
Save