aboutsummaryrefslogtreecommitdiff
path: root/bot/src
diff options
context:
space:
mode:
Diffstat (limited to 'bot/src')
-rw-r--r--bot/src/commands/stats.js24
-rw-r--r--bot/src/events/InteractionCreate.js2
-rw-r--r--bot/src/events/MessageDelete.js3
-rw-r--r--bot/src/events/MessageUpdate.js3
4 files changed, 27 insertions, 5 deletions
diff --git a/bot/src/commands/stats.js b/bot/src/commands/stats.js
new file mode 100644
index 0000000..9504386
--- /dev/null
+++ b/bot/src/commands/stats.js
@@ -0,0 +1,24 @@
+import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
+import { commandUsages } from '../models/command-usages.js';
+import { abEmbedColour } from '../storage/consts.js';
+
+export default {
+ data: new SlashCommandBuilder()
+ .setName('stats')
+ .setDescription('Shows how many times you executed a command.'),
+ async execute(interaction) {
+ let cmdUsage = await commandUsages.findAll({ where: { userID: interaction.user.id } });
+ const totalCommands = cmdUsage.length;
+ const guildCommands = cmdUsage.filter(cmd => cmd.guildID === interaction.guild.id).length;
+
+ const statsEmbed = new EmbedBuilder()
+ .setAuthor({ name: `Stats for ${interaction.user.username}`, iconURL: interaction.client.user.avatarURL() })
+ .addFields(
+ { name: 'Total Commands Executed', value: totalCommands.toString() },
+ { name: 'Total Commands Executed in this Guild', value: guildCommands.toString() }
+ )
+ .setColor(abEmbedColour);
+
+ return await interaction.reply({ embeds: [statsEmbed] });
+ }
+};
diff --git a/bot/src/events/InteractionCreate.js b/bot/src/events/InteractionCreate.js
index 777ce39..5143594 100644
--- a/bot/src/events/InteractionCreate.js
+++ b/bot/src/events/InteractionCreate.js
@@ -15,7 +15,7 @@ export default {
if (!command) return;
try {
- console.log(`[i] ${interaction.user.username} has executed ${command.data.name}`);
+ console.log(`[i] ${interaction.user.username} has executed ${command.data.name} at ${interaction.guild.name}`);
await Analytics(command, interaction);
await command.execute(interaction);
} catch (e) {
diff --git a/bot/src/events/MessageDelete.js b/bot/src/events/MessageDelete.js
index 2f929d2..1823c09 100644
--- a/bot/src/events/MessageDelete.js
+++ b/bot/src/events/MessageDelete.js
@@ -33,8 +33,7 @@ export default {
await deleteMessage.send({
embeds: [logEmbed],
- files: [attachment],
- content: 'Message content was too long to display in an embed.'
+ files: [attachment]
});
}
} catch (e) {
diff --git a/bot/src/events/MessageUpdate.js b/bot/src/events/MessageUpdate.js
index fa20b63..5bbee20 100644
--- a/bot/src/events/MessageUpdate.js
+++ b/bot/src/events/MessageUpdate.js
@@ -43,8 +43,7 @@ export default {
await editMessage.send({
embeds: [logEmbed],
- files: [attachment],
- content: 'Message content was too long to display in an embed.'
+ files: [attachment]
});
}
} catch (e) {