Compare commits

..

No commits in common. "c2683c889094130039c7ce9744eaf92d6391d17c" and "8d5fbdf18e35fd1e492a1beaee43fcb3a2197989" have entirely different histories.

@ -17,10 +17,13 @@ async function execute(interaction) {
const id = interaction.options.getInteger("asset_id", true);
await noblox.setCookie(cookie);
let alreadyOwned;
try {
// Check if the bot already owns this asset
alreadyOwned = await noblox.getOwnership(await noblox.getCurrentUser("UserID"), id, "Asset");
// 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;
}
} catch (error) {
if (error.message !== "400 The specified Asset does not exist!") {
throw error;
@ -59,24 +62,16 @@ async function execute(interaction) {
};
// Kick off the buy request
let buyPromise;
if (!alreadyOwned) {
buyPromise = noblox.buy({product: productInfo, price: 0});
}
const 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})](<https://create.roblox.com/store/asset/${id}/>) has been taken by the bot you can load it into the [${game} maptest place](<${gamePlaces[game]}>).