From c0507dc981da70f881f83221ed0ca89841749b7d Mon Sep 17 00:00:00 2001
From: Supositware <sup@libtar.de>
Date: Thu, 11 Jul 2024 07:32:14 +0200
Subject: [PATCH] Show a message instead of error when an argument is required
 (for real this time)

---
 events/client/messageCreate.js | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/events/client/messageCreate.js b/events/client/messageCreate.js
index 5781c3a..979e54f 100644
--- a/events/client/messageCreate.js
+++ b/events/client/messageCreate.js
@@ -294,7 +294,7 @@ export default {
 
 		if (globalBlacklist) {
 			return message.reply({ content: `You are globally blacklisted for the following reason: \`${globalBlacklist.reason}\``, ephemeral: true });
-		}		
+		}
 		else if (commandBlacklist) {
 			return message.reply({ content: `You are blacklisted for the following reason: \`${commandBlacklist.reason}\``, ephemeral: true });
 		}
@@ -305,7 +305,7 @@ export default {
 		let isOptOut = await db.optout.findOne({ where: { userID: message.author.id } });
 
 		if (commandName === 'optout') {
-			isOptOut = true
+			isOptOut = true;
 		}
 
 		const timestamp = new Date();
@@ -402,11 +402,17 @@ export default {
 			});
 
 			const argsLength = command.data.options.length - argsToDelete;
+			const missingRequired = [];
 
 			for (let i = 0, j = 0; i < argsLength; i++, j++) {
-				if (!messageArgs[i]) continue;
 				const arg = command.data.options[j];
 
+				if (arg.required && !messageArgs[i]) {
+					missingRequired.push({ name: arg.name, description: arg.description });
+				}
+
+				if (!messageArgs[i]) continue;
+
 				if (arg.type === ApplicationCommandOptionType.Attachment) continue;
 
 				let payloadName = arg.name;
@@ -437,6 +443,14 @@ export default {
 				console.log(`[${timestamp.toISOString()}] \x1b[33m⤷\x1b[0m with args ${JSON.stringify(args)}`);
 			}
 
+			if (missingRequired.length > 0) {
+				let missingMsg = '';
+				missingRequired.forEach(arg => {
+					missingMsg += `${arg.name} | ${arg.description}\n`;
+				});
+				return message.reply(`You are missing a required argument!\n\`${missingMsg}\``);
+			}
+
 			await command.execute(message, args, client)
 				.then(async () => {
 					const hasPrallelLimit = await ratelimiter.checkParallel(message.author, commandName, command);