From 9d1c6ecfb62cab6f8eb3a986908167ddd103caf0 Mon Sep 17 00:00:00 2001 From: baz Date: Thu, 28 Dec 2023 23:47:03 +0000 Subject: [PATCH] Add checks to beatgame to see if user has finished the challenge --- commands/100-games/beatGame.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/commands/100-games/beatGame.js b/commands/100-games/beatGame.js index ae0796e..ec5df6d 100644 --- a/commands/100-games/beatGame.js +++ b/commands/100-games/beatGame.js @@ -13,6 +13,9 @@ module.exports = { const userDatabaseEntry = await getUserRegistration(interaction.user); if (!userDatabaseEntry) return interaction.reply({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true }); + const oldnum = await getBeatenGameCount(userDatabaseEntry); + if (oldnum >= 100) return interaction.reply({ content: 'You have already completed the 100 Games Challenge.', ephemeral: true }); + const gamename = interaction.options.getString('gamename'); const gameid = interaction.options.getNumber('gameid'); @@ -53,6 +56,18 @@ module.exports = { .setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }) .setTimestamp(); - return interaction.reply({ embeds: [embed] }); + await interaction.reply({ embeds: [embed] }); + + if (num == 100) { + const challengeCompletedEmbed = new EmbedBuilder() + .setColor(0xFFD700) + .setAuthor({ name: `${interaction.user.displayName} has completed the 100 Game Challenge!`, iconURL: interaction.user.avatarURL() }) + .setTitle(`Congratulations ${interaction.user.displayName}, you have completed the 100 Game Challenge!`) + .setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }) + .setTimestamp() + .setImage('https://c.tenor.com/82zAqfFm7OMAAAAC/tenor.gif'); + + await interaction.followUp({ embeds: [challengeCompletedEmbed] }); + } }, }; \ No newline at end of file