diff options
| author | Andrew Lee <andrew@alee14.me> | 2025-03-29 22:19:55 -0400 |
|---|---|---|
| committer | Andrew Lee <andrew@alee14.me> | 2025-03-29 22:19:55 -0400 |
| commit | 070825d2b779b114a1c345fbca210d324bf34d53 (patch) | |
| tree | 1a62f7676bc46b8bc799e8b4b486fa0ea2879f6f /bot/src/commands/quote.js | |
| parent | db6df8c2a3817a753a9b903feb6311c620a91a65 (diff) | |
| download | AleeBot-070825d2b779b114a1c345fbca210d324bf34d53.tar.gz AleeBot-070825d2b779b114a1c345fbca210d324bf34d53.tar.bz2 AleeBot-070825d2b779b114a1c345fbca210d324bf34d53.zip | |
Quote submit stats + input validation for author/year; API changes; Use toString for some stuff
Diffstat (limited to 'bot/src/commands/quote.js')
| -rw-r--r-- | bot/src/commands/quote.js | 25 |
1 files changed, 25 insertions, 0 deletions
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, |
