aboutsummaryrefslogtreecommitdiff
path: root/bot/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'bot/src/commands')
-rw-r--r--bot/src/commands/about.js9
-rw-r--r--bot/src/commands/quote.js25
-rw-r--r--bot/src/commands/serverinfo.js6
-rw-r--r--bot/src/commands/stats.js15
4 files changed, 43 insertions, 12 deletions
diff --git a/bot/src/commands/about.js b/bot/src/commands/about.js
index 22b3441..177ac47 100644
--- a/bot/src/commands/about.js
+++ b/bot/src/commands/about.js
@@ -23,12 +23,13 @@ export default {
{ name: 'License', value: 'GNU General Public License v3.0' },
{ name: 'Contributors', value:
'- <@297201585090723841> (Uptime command from 2.x)\n' +
- '- <@236279900728721409> (Eval command from 2.x)' }
+ '- <@236279900728721409> (Eval command from 2.x)'
+ }
)
.setFooter({ text: '© Copyright 2017-2025 Andrew Lee & contributors' })
.setColor(abEmbedColour);
- let Buttons = new ActionRowBuilder()
+ let aboutButtons = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setStyle(ButtonStyle.Link)
@@ -37,13 +38,13 @@ export default {
new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel('Invite AleeBot')
- .setURL('https://discord.com/oauth2/authorize?client_id=282547024547545109'),
+ .setURL(`https://discord.com/oauth2/authorize?client_id=${interaction.client.user.id}`),
new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel('Join Andrew Lee Projects')
.setURL('https://discord.gg/EFhRDqG')
);
- return await interaction.reply({ embeds: [aboutEmbed], components: [Buttons] });
+ return await interaction.reply({ embeds: [aboutEmbed], components: [aboutButtons] });
}
};
diff --git a/bot/src/commands/quote.js b/bot/src/commands/quote.js
index 55b8cbc..9c409f9 100644
--- a/bot/src/commands/quote.js
+++ b/bot/src/commands/quote.js
@@ -50,6 +50,7 @@ export default {
.setCustomId('authorImage')
.setLabel('Submit the image of the author')
.setMaxLength(100)
+ .setMinLength(4)
.setPlaceholder('Image URL (512x512) or (128x128)')
.setStyle(TextInputStyle.Short);
@@ -57,6 +58,7 @@ export default {
.setCustomId('quote')
.setLabel('Enter the quote')
.setMaxLength(200)
+ .setMinLength(5)
.setPlaceholder('Quote')
.setStyle(TextInputStyle.Paragraph);
@@ -85,6 +87,29 @@ export default {
const quote = modalInteraction.fields.getTextInputValue('quote');
const year = modalInteraction.fields.getTextInputValue('year');
+ try {
+ new URL(authorImage);
+ } catch {
+ return modalInteraction.reply({
+ content: 'Error: Author image must be a valid URL.',
+ flags: MessageFlags.Ephemeral
+ });
+ }
+
+ if (!authorImage.match(/\.(jpeg|jpg|png|webp)$/i)) {
+ return modalInteraction.reply({
+ content: 'Error: Author image URL must end with a valid image extension (jpeg, jpg, png, webp).',
+ flags: MessageFlags.Ephemeral
+ });
+ }
+
+ if (isNaN(year) || year.trim() === '' || !Number.isInteger(Number(year))) {
+ return modalInteraction.reply({
+ content: 'Error: Year must be a number.',
+ flags: MessageFlags.Ephemeral
+ });
+ }
+
await pendingQuote.create({
author: author,
authorImage: authorImage,
diff --git a/bot/src/commands/serverinfo.js b/bot/src/commands/serverinfo.js
index 3f7bd72..7ebf6ea 100644
--- a/bot/src/commands/serverinfo.js
+++ b/bot/src/commands/serverinfo.js
@@ -22,10 +22,10 @@ export default {
.addFields(
{ name: 'Main Information', value: `**Server Name:** ${interaction.guild.name}\n**Server ID:** ${interaction.guild.id}\n**Server Owner:** ${guildOwner.user.username}`},
{ name: 'Join Dates', value: `**Created At:** ${interaction.guild.createdAt.toUTCString()}\n**AleeBot Joined:** ${interaction.guild.joinedAt.toUTCString()}`},
- { name: 'Total Channels (without threads)', value: `${interaction.guild.channels.channelCountWithoutThreads}` },
+ { name: 'Total Channels (without threads)', value: interaction.guild.channels.channelCountWithoutThreads.toString() },
// { name: 'Channels', value: listedChannels.join(' ') },
- { name: 'Total Members (with bots)', value: `${interaction.guild.memberCount}` },
- { name: 'Total Members (without bots)', value: `${memberCountNoBots}` }
+ { name: 'Total Members (with bots)', value: interaction.guild.memberCount.toString() },
+ { name: 'Total Members (without bots)', value: memberCountNoBots.toString() }
)
.setColor(abEmbedColour);
return await interaction.reply({ embeds: [serverEmbed] });
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);