maptest-bot/common.js

55 lines
1.3 KiB
JavaScript

const axios = require("axios").default;
// https://create.roblox.com/docs/reference/engine/enums/AssetType
const AssetType = {
Image: 1,
TShirt: 2,
Audio: 3,
Mesh: 4,
Lua: 5,
Hat: 8,
Place: 9,
Model: 10,
Shirt: 11,
Pants: 12,
Decal: 13,
Head: 17,
Face: 18,
Gear: 19,
Badge: 21,
Animation: 24,
GamePass: 34,
Plugin: 38,
MeshPart: 40
};
async function getAssetInfo(assetId) {
const res = await axios.get("https://apis.roblox.com/toolbox-service/v1/items/details", {
params: {
assetIds: assetId
},
validateStatus: (status) => status === 403 || status === 404 || (status >= 200 && status < 300) // Allow 403/404 as a valid status (don't throw an error)
});
if (res.status < 200 || res.status > 300) {
return {
status: res.status
}
}
const data = res.data.data;
const assetInfo = data[0];
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
}
}
module.exports = { AssetType, getAssetInfo };