added stats command

This commit is contained in:
ry 2020-01-20 00:35:54 +01:00
父節點 37a08314ea
當前提交 23ac36c819
共有 5 個文件被更改,包括 75 次插入11 次删除

查看文件

@ -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,

查看文件

@ -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)
}
}

查看文件

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

查看文件

@ -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 {
});
});
}
};
};

查看文件

@ -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);
}
}