From cd5530d6f3b3730f781db96523d71f67fbe3e7a4 Mon Sep 17 00:00:00 2001 From: Alexandertp Date: Wed, 18 Dec 2024 00:28:28 +0100 Subject: [PATCH] Add debug messages, Add input sanitation to AddGear --- src/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 8bae1a6..44eedab 100644 --- a/src/index.js +++ b/src/index.js @@ -145,8 +145,10 @@ client.on('interactionCreate', async(interaction) => { message[1].edit(scoreBoardMessageIntern); replyMessage += "Updated Intern \n" } + replyMessage += "Finished updating, it may take a few seconds to become visible." }; interaction.reply({content: replyMessage, ephemeral: true}); + console.log("Finished updating scoreboard data, it may take a few seconds to display in the client.") }) } } else if (interaction.commandName === 'scoreboard' && !isManager) { @@ -167,13 +169,18 @@ function PromoteEmployee(Name, rank) { }; function AddGear(Type,Employee) { + Type = Type.trim(); + Type = Type.toLowerCase(); if (Type == "copper" || Type == "silver" || Type == "gold" || Type == "purple"){ Type += "gear"; } Type = Type.toLowerCase(); - if (Type != "coppergear" && Type != "silvergear" && Type != "goldgear" && Type != "purplegear") return "Nothing"; + if (Type != "coppergear" && Type != "silvergear" && Type != "goldgear" && Type != "purplegear") { + console.log("User wrote an invalid gear type: " + Type) + return "Nothing"; + } db.run(`UPDATE Employees SET ${Type} = ${Type} + 1 WHERE name = \'${Employee}\' `); - + console.log("A gear of type: " + Type + " was added to " + Employee); return Type; }; function RemoveGear(Type, Employee) {