diff --git a/commands/take.js b/commands/take.js index 2800c82..4c0fdc1 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,24 @@ 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]}>).