Use built-in Noblox 'buy' function
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e8c41bb821
commit
14d57a4561
@ -38,7 +38,7 @@ async function execute(interaction) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await buy(info);
|
await noblox.buy({product: info, price: 0});
|
||||||
await interaction.reply(
|
await interaction.reply(
|
||||||
`
|
`
|
||||||
Now that your map (id: ${id}) has been taken by the ${game} maptest bot you can load it into the ${game} maptest place. To load your map, join the game and say
|
Now that your map (id: ${id}) has been taken by the ${game} maptest bot you can load it into the ${game} maptest place. To load your map, join the game and say
|
||||||
@ -58,39 +58,6 @@ If it did not load successfully, you can expand the chat to view the full error
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function buy (product) {
|
|
||||||
const productId = product.ProductId;
|
|
||||||
const httpOpt = {
|
|
||||||
url: '//economy.roblox.com/v1/purchases/products/' + productId,
|
|
||||||
options: {
|
|
||||||
method: 'POST',
|
|
||||||
jar: undefined,
|
|
||||||
headers: {
|
|
||||||
'X-CSRF-TOKEN': await noblox.getGeneralToken()
|
|
||||||
},
|
|
||||||
json: {
|
|
||||||
expectedCurrency: 1,
|
|
||||||
expectedPrice: 0,
|
|
||||||
expectedSellerId: product.Creator.Id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const json = await noblox.http(httpOpt);
|
|
||||||
console.log(json)
|
|
||||||
|
|
||||||
let err = json.errorMsg
|
|
||||||
if (json.reason === 'InsufficientFunds') {
|
|
||||||
err = 'You need ' + json.shortfallPrice + ' more robux to purchase this item.';
|
|
||||||
} else if (json.errorMsg) {
|
|
||||||
err = json.errorMsg;
|
|
||||||
}
|
|
||||||
if (!err) {
|
|
||||||
return productId;
|
|
||||||
} else {
|
|
||||||
throw new Error(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
Loading…
Reference in New Issue
Block a user