Initial fix
This commit is contained in:
parent
50e9abe5d2
commit
41affeae6e
@ -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]}>).
|
||||
|
18
common.js
18
common.js
@ -40,16 +40,26 @@ async function getAssetInfo(assetId) {
|
||||
|
||||
const data = res.data.data;
|
||||
const assetInfo = data[0];
|
||||
|
||||
let isFree, forSale;
|
||||
if (assetInfo.fiatProduct) {
|
||||
const quantity = assetInfo.fiatProduct.purchasePrice.quantity;
|
||||
isFree = quantity.significand === 0 && quantity.exponent === 0;
|
||||
forSale = assetInfo.fiatProduct.published && assetInfo.fiatProduct.purchasable;
|
||||
}
|
||||
else {
|
||||
isFree = assetInfo.product.price === 0;
|
||||
forSale = assetInfo.product.isForSaleOrIsPublicDomain;
|
||||
}
|
||||
console.log(assetInfo);
|
||||
|
||||
return {
|
||||
status: res.status,
|
||||
id: assetId,
|
||||
name: assetInfo.asset.name,
|
||||
typeId: assetInfo.asset.typeId,
|
||||
creatorId: assetInfo.creator.id,
|
||||
price: assetInfo.product.price,
|
||||
productId: assetInfo.product.productId,
|
||||
forSale: assetInfo.product.isForSaleOrIsPublicDomain
|
||||
isFree: isFree,
|
||||
forSale: forSale
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user