Compare commits
3 Commits
8d5fbdf18e
...
c2683c8890
Author | SHA1 | Date | |
---|---|---|---|
c2683c8890 | |||
b4fe2da92d | |||
daee1c95f3 |
@ -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})](<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