Skip to content

Commit

Permalink
Merge pull request #839 from Regalijan/fix-configureitem
Browse files Browse the repository at this point in the history
Handle itemconfiguration error codes 37 and 40
  • Loading branch information
Regalijan authored Nov 15, 2024
2 parents bc7ba73 + f2eecd6 commit 897833d
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions lib/develop/configureItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,65 @@ function configureRobux (args) {
} else if (json.errors[0].code === 20) { // "Cannot set the associated asset type to remove-from-release" - caused by copyable asset using sellForRobux: 0
// Continue and ignore the error as the intended outcome makes the asset private; set sellForRobux from 0 to false
return configure(args.jar, args.token, args.id, args.name, args.description, args.enableComments, args.sellForRobux, args.genreSelection, !!args.sellForRobux)
} else if (json.errors[0].code === 37) { // "AssetIsLimited" - Use the newer endpoint to update price and sale status
return http({
url: '//catalog.roblox.com/v1/catalog/items/details',
options: {
method: 'POST',
jar: args.jar,
json: {
items: [
{
id: args.id,
itemType: 1
}
]
},
resolveWithFullResponse: true
}
}).then((response) => {
if (!response.ok) throw new Error(response.body)

const { collectibleItemId, price } = JSON.parse(response.body)

if (!collectibleItemId) throw new Error(`The publishing fee for asset ${args.id} has not been paid, you must do this in order to change or set the price.`)

return http({
url: `//itemconfiguration.roblox.com/v1/collectibles/${collectibleItemId}`,
options: {
method: 'PATCH',
jar: args.jar,
headers: {
'X-CSRF-Token': args.token
},
json: {
isFree: false,
priceInRobux: args.sellForRobux || price,
priceOffset: 0,
quantityLimitPerUser: 0,
resaleRestriction: 2,
saleLocationConfiguration: {
places: [],
saleLocationType: 1
},
saleStatus: args.sellForRobux > 0 ? 0 : 1
},
resolveWithFullResponse: true
}
}).then((response) => {
if (!response.ok) throw new Error(response.body)

return {
name: args.name,
assetId: args.id,
description: args.description,
price: args.sellForRobux,
isCopyingAllowed: null
}
})
})
} else if (json.errors[0].code === 40) { // "Use collecibles publishing endpoint." - Publishing fee has not been paid for this asset
throw new Error(`The publishing fee for asset ${args.id} has not been paid, you must pay the fee before setting or updating the price.`)
}
throw new Error(`An unknown error occurred: [${json.errors[0].code}] ${json.errors[0].message}`)
}
Expand Down

0 comments on commit 897833d

Please sign in to comment.