blob: a9612454387a307a98c07061ee7e40712c50cbff (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import { commandUsages } from '../db/models/command-usages.js';
import { abEmbedColour } from '../storage/consts.js';
import { quote } from '../db/models/quote.js';
export default {
data: new SlashCommandBuilder()
.setName('stats')
.setDescription('Shows statistics of your interaction with AleeBot.'),
async execute(interaction) {
const cmdUsage = await commandUsages.findAll({ where: { userID: interaction.user.id } });
const quoteSubmitted = await quote.findAll({ where: { submitter: interaction.user.id } });
const totalCommands = cmdUsage.length;
const guildCommands = cmdUsage.filter(cmd => cmd.guildID === interaction.guild.id).length;
const totalQuotes = quoteSubmitted.length;
const statsEmbed = new EmbedBuilder()
.setAuthor({ name: `AleeBot Stats for ${interaction.user.displayName}`, iconURL: interaction.client.user.avatarURL() })
.addFields(
{ name: 'Total Commands Executed (Global)', value: totalCommands.toString() },
{ name: 'Total Commands Executed (Guild)', value: guildCommands.toString() },
{ name: 'Total Quotes Submitted', value: totalQuotes.toString() }
)
.setColor(abEmbedColour);
return await interaction.reply({ embeds: [statsEmbed] });
}
};
|