2024-04-16 02:15:35 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-17 00:58:24 +00:00
|
|
|
const SubmissionColumnsString = "map_id,unix_timestamp,user_id,username\n";
|
|
|
|
|
|
|
|
const SubmissionColumn = {
|
|
|
|
ModelID: 0,
|
|
|
|
UnixTimestamp: 1,
|
|
|
|
UserID: 2,
|
|
|
|
Username: 3
|
|
|
|
};
|
|
|
|
|
|
|
|
function getSubmissionLine(line) {
|
|
|
|
const modelId = Number(line[SubmissionColumn.ModelID]);
|
|
|
|
const timestamp = Number(line[SubmissionColumn.UnixTimestamp]);
|
|
|
|
let userId = "";
|
|
|
|
let username = "";
|
|
|
|
|
|
|
|
// Backwards compatibility
|
|
|
|
if (line.length > 2) {
|
|
|
|
userId = Number(line[SubmissionColumn.UserID]);
|
|
|
|
username = line[SubmissionColumn.Username];
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
modelId: modelId,
|
|
|
|
timestamp: timestamp,
|
|
|
|
userId: userId,
|
|
|
|
username: username
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function createSubmissionLine(modelId, timestamp, userId, username) {
|
|
|
|
return `${modelId},${timestamp},${userId},${username}\n`;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { AssetType, getAssetInfo, SubmissionColumn, SubmissionColumnsString, getSubmissionLine, createSubmissionLine };
|