Allow retaking models
This commit is contained in:
parent
8d5fbdf18e
commit
daee1c95f3
@ -17,13 +17,10 @@ async function execute(interaction) {
|
|||||||
const id = interaction.options.getInteger("asset_id", true);
|
const id = interaction.options.getInteger("asset_id", true);
|
||||||
await noblox.setCookie(cookie);
|
await noblox.setCookie(cookie);
|
||||||
|
|
||||||
|
let alreadyOwned;
|
||||||
try {
|
try {
|
||||||
// Check that the bot doesn't already own this asset
|
// Check if the bot already owns this asset
|
||||||
if (await noblox.getOwnership(await noblox.getCurrentUser("UserID"), id, "Asset")) {
|
alreadyOwned = 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) {
|
} catch (error) {
|
||||||
if (error.message !== "400 The specified Asset does not exist!") {
|
if (error.message !== "400 The specified Asset does not exist!") {
|
||||||
throw error;
|
throw error;
|
||||||
@ -62,16 +59,25 @@ async function execute(interaction) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Kick off the buy request
|
// 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
|
// Validate and send the validation result
|
||||||
const validation = await validateMapAsset(id, game);
|
const validation = await validateMapAsset(id, game);
|
||||||
const msg = getValidationMessage(validation, game, false);
|
const msg = getValidationMessage(validation, game, false);
|
||||||
await interaction.editReply(msg);
|
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
|
// Make sure the buy request is done
|
||||||
await buyPromise;
|
await buyPromise;
|
||||||
|
|
||||||
await interaction.followUp(
|
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]}>).
|
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]}>).
|
||||||
|
Loading…
Reference in New Issue
Block a user