From 6ee679ffd499c0267dff285bfc790e05f85b1d8e Mon Sep 17 00:00:00 2001 From: Alexandertp Date: Wed, 20 Nov 2024 22:24:30 +0100 Subject: [PATCH] Fix scoreboard update to work with new display. --- src/index.js | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index bf0b13a..2f6c566 100644 --- a/src/index.js +++ b/src/index.js @@ -114,16 +114,48 @@ client.on('interactionCreate', async(interaction) => { }; }; if (updateOrDisplay == 'update') { - const messagesInGearchannel = await gearchannel.messages.fetch() - const gearMessage = await messagesInGearchannel.find(msg => msg.author.id === '1306647733490290809') + gearchannel.messages.fetch().then((messages) => { + let replyMessage = ""; + for (const message of messages) { + if(message[1].content.includes("# Beastboss") && message[1].editable) { + message[1].edit(scoreBoardMessageBeastboss); + replyMessage += "Updated Beastboss \n" + } + if (message[1].content.includes("# Manager") && message[1].editable ) { + message[1].edit(scoreBoardMessageManager); + replyMessage += "Updated Manager \n" + } + if (message[1].content.includes("# Muscle") && message[1].editable) { + message[1].edit(scoreBoardMessageMuscle); + replyMessage += "Updated Muscle \n" + } + if (message[1].content.includes("# Moneymaker") && message[1].editable) { + message[1].edit(scoreBoardMessageMuscle); + replyMessage += "Updated Moneymaker \n" + } + if (message[1].content.includes("# Mystic") && message[1].editable) { + message[1].edit(scoreBoardMessageMuscle); + replyMessage += "Updated Mystic \n" + } + if (message[1].content.includes("# Intern") && message[1].editable) { + message[1].edit(scoreBoardMessageMuscle); + 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(scoreBoardMessage); + 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})