From daee1c95f3035d180c582953e926566cc3114273 Mon Sep 17 00:00:00 2001 From: Carter Penterman Date: Mon, 29 Apr 2024 15:38:51 -0500 Subject: [PATCH 1/2] Allow retaking models --- commands/take.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/commands/take.js b/commands/take.js index 2800c82..1035980 100644 --- a/commands/take.js +++ b/commands/take.js @@ -17,13 +17,10 @@ async function execute(interaction) { const id = interaction.options.getInteger("asset_id", true); await noblox.setCookie(cookie); + let alreadyOwned; try { - // Check that the bot doesn't already own this asset - if (await noblox.getOwnership(await noblox.getCurrentUser("UserID"), id, "Asset")) { - const msg = `🚫 The ${game} maptest bot already has this model (id: ${id})`; - await interaction.editReply(msg); - return; - } + // Check if the bot already owns this asset + alreadyOwned = await noblox.getOwnership(await noblox.getCurrentUser("UserID"), id, "Asset"); } catch (error) { if (error.message !== "400 The specified Asset does not exist!") { throw error; @@ -62,16 +59,25 @@ async function execute(interaction) { }; // Kick off the buy request - const buyPromise = noblox.buy({product: productInfo, price: 0}); + let buyPromise; + if (!alreadyOwned) { + buyPromise = noblox.buy({product: productInfo, price: 0}); + } // Validate and send the validation result const validation = await validateMapAsset(id, game); const msg = getValidationMessage(validation, game, false); await interaction.editReply(msg); + + if (alreadyOwned) + { + // Unicode is for the information emoji [i] + await interaction.followUp(`\u2139\uFE0F The ${game} maptest bot already has this model, so no action was taken.`); + return; + } // Make sure the buy request is done await buyPromise; - await interaction.followUp( ` Now that your [map (id: ${id})]() has been taken by the bot you can load it into the [${game} maptest place](<${gamePlaces[game]}>). -- 2.45.2 From b4fe2da92d39521da821206616bf28ad0ae46136 Mon Sep 17 00:00:00 2001 From: Carter Penterman Date: Mon, 29 Apr 2024 15:42:01 -0500 Subject: [PATCH 2/2] Consistency... --- commands/take.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/commands/take.js b/commands/take.js index 1035980..4c0fdc1 100644 --- a/commands/take.js +++ b/commands/take.js @@ -69,8 +69,7 @@ async function execute(interaction) { const msg = getValidationMessage(validation, game, false); await interaction.editReply(msg); - if (alreadyOwned) - { + if (alreadyOwned) { // Unicode is for the information emoji [i] await interaction.followUp(`\u2139\uFE0F The ${game} maptest bot already has this model, so no action was taken.`); return; -- 2.45.2