Initial fix

This commit is contained in:
2024-08-21 16:55:26 -05:00
parent 50e9abe5d2
commit 41affeae6e
2 changed files with 36 additions and 16 deletions

@ -44,24 +44,33 @@ async function execute(interaction) {
await interaction.editReply(`🚫 This asset (id: ${id}) is not a model. Your map must be a model.`);
return;
}
if (assetInfo.price !== 0) {
if (!assetInfo.isFree) {
await interaction.editReply(`🚫 This model (id: ${id}) is not free. Please change the price to be free.`);
return;
}
// Make a "fake" product info object for the Noblox buy method
const productInfo = {
PriceInRobux: assetInfo.price,
ProductId: assetInfo.productId,
Creator: {
Id: assetInfo.creatorId
}
};
// Kick off the buy request
let buyPromise;
if (!alreadyOwned) {
buyPromise = noblox.buy({product: productInfo, price: 0});
const jar = noblox.options.jar;
const xcsrf = await noblox.getGeneralToken(jar);
buyPromise = noblox.http("https://apis.roblox.com/marketplace-fiat-service/v1/product/purchase", {
method: "POST",
resolveWithFullResponse: true,
jar,
headers: {
"X-CSRF-TOKEN": xcsrf,
"Content-Type": "application/json"
},
body: JSON.stringify({
expectedPrice: {currencyCode: "USD", quantity: {significand: 0, exponent: 0}},
productKey: {
productNamespace: "PRODUCT_NAMESPACE_CREATOR_MARKETPLACE_ASSET",
productTargetId: `${id}`,
productType: "PRODUCT_TYPE_MODEL"
}
})
});
}
// Validate and send the validation result
@ -76,7 +85,8 @@ async function execute(interaction) {
}
// Make sure the buy request is done
await buyPromise;
const res = await buyPromise;
console.log(JSON.parse(res.body));
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]}>).