Add debug messages, Add input sanitation to AddGear

This commit is contained in:
Alexandertp 2024-12-18 00:28:28 +01:00
parent 55d999844b
commit cd5530d6f3

View File

@ -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) {