From 070825d2b779b114a1c345fbca210d324bf34d53 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sat, 29 Mar 2025 22:19:55 -0400 Subject: Quote submit stats + input validation for author/year; API changes; Use toString for some stuff --- bot/src/commands/stats.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'bot/src/commands/stats.js') diff --git a/bot/src/commands/stats.js b/bot/src/commands/stats.js index 9504386..6924874 100644 --- a/bot/src/commands/stats.js +++ b/bot/src/commands/stats.js @@ -1,21 +1,26 @@ import { EmbedBuilder, SlashCommandBuilder } from 'discord.js'; import { commandUsages } from '../models/command-usages.js'; import { abEmbedColour } from '../storage/consts.js'; +import { quote } from '../models/quote.js'; export default { data: new SlashCommandBuilder() .setName('stats') - .setDescription('Shows how many times you executed a command.'), + .setDescription('Shows statistics of your interaction with AleeBot.'), async execute(interaction) { - let cmdUsage = await commandUsages.findAll({ where: { userID: interaction.user.id } }); + 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: `Stats for ${interaction.user.username}`, iconURL: interaction.client.user.avatarURL() }) + .setAuthor({ name: `AleeBot Stats for ${interaction.user.displayName}`, iconURL: interaction.client.user.avatarURL() }) .addFields( - { name: 'Total Commands Executed', value: totalCommands.toString() }, - { name: 'Total Commands Executed in this Guild', value: guildCommands.toString() } + { 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); -- cgit v1.2.3