From 55d999844b29d268d2db650874e8ec6b97e26677 Mon Sep 17 00:00:00 2001 From: Alexandertp Date: Wed, 27 Nov 2024 15:48:31 +0100 Subject: [PATCH] Finish Gear Removal Implementation --- src/index.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/index.js b/src/index.js index 2f6c566..8bae1a6 100644 --- a/src/index.js +++ b/src/index.js @@ -52,6 +52,10 @@ client.on('interactionCreate', async(interaction) => { const gearAdded = AddGear(gearType, employee) interaction.reply({content: `Added a ${gearAdded} to ${employee}`, ephemeral: true}) }; + if (addRemove == 'remove') { + const gearRemoved = RemoveGear(gearType, employee) + interaction.reply({content: `Removed a ${gearRemoved} from ${employee}`, ephemeral: true}) + } } else if (interaction.commandName === 'gear' && !isManager) { interaction.reply({content:"You aren't a manager! Get back to work.", ephemeral: true}) @@ -130,32 +134,20 @@ client.on('interactionCreate', async(interaction) => { replyMessage += "Updated Muscle \n" } if (message[1].content.includes("# Moneymaker") && message[1].editable) { - message[1].edit(scoreBoardMessageMuscle); + message[1].edit(scoreBoardMessageMoneymaker); replyMessage += "Updated Moneymaker \n" } if (message[1].content.includes("# Mystic") && message[1].editable) { - message[1].edit(scoreBoardMessageMuscle); + message[1].edit(scoreBoardMessageMystic); replyMessage += "Updated Mystic \n" } if (message[1].content.includes("# Intern") && message[1].editable) { - message[1].edit(scoreBoardMessageMuscle); + message[1].edit(scoreBoardMessageIntern); replyMessage += "Updated Intern \n" } }; interaction.reply({content: replyMessage, ephemeral: true}); }) - /* - const gearMessage = await messagesInGearchannel.find(msg => msg.author.id === '1306647733490290809' && msg.content.includes("#Beastboss")); - - if (gearMessage === undefined) { - interaction.reply({content: "Could not find a message to update, did you remember to display it first?", ephemeral: true}); - console.log(messagesInGearchannel); - console.log(messagesInGearchannel.length()) - } - else { - gearMessage.edit(scoreBoardMessageBeastboss); - interaction.reply("Updated scoreboard.") - } */ } } else if (interaction.commandName === 'scoreboard' && !isManager) { interaction.reply({content:"You aren't a manager! Get back to work.", ephemeral: true}) @@ -178,14 +170,20 @@ function AddGear(Type,Employee) { 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"; db.run(`UPDATE Employees SET ${Type} = ${Type} + 1 WHERE name = \'${Employee}\' `); return Type; }; function RemoveGear(Type, Employee) { - if (Type != "coppergear" && Type != "silvergear" && Type != "goldgear" && Type != "purplegear") return + if (Type == "copper" || Type == "silver" || Type == "gold" || Type == "purple"){ + Type += "gear"; + } + if (Type != "coppergear" && Type != "silvergear" && Type != "goldgear" && Type != "purplegear") return "Nothing"; db.run(`UPDATE Employees SET ${Type} = ${Type} - 1 WHERE name = \'${Employee}\'`) + + return Type; }; function RenameEmployee(oldName, newName) { db.run(`UPDATE Employees SET name = \'${newName}\' WHERE name = \'${oldName}\'`);