Use alternate API for current user and skip cookie validation

This commit is contained in:
2024-08-27 21:28:33 -05:00
parent 36c4a3d791
commit d1066e2737
3 changed files with 25 additions and 7 deletions

@ -1,7 +1,7 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const noblox = require("noblox.js");
const { cookies, commands, gamePlaces } = require("../config/config.js");
const { getAssetInfo, buyModel, validateMapAsset, getValidationMessage } = require("../common.js");
const { getAssetInfo, buyModel, getCurrentUser, validateMapAsset, getValidationMessage } = require("../common.js");
/**
* @param {import('discord.js').ChatInputCommandInteraction} interaction
@ -15,12 +15,12 @@ async function execute(interaction) {
}
const id = interaction.options.getInteger("asset_id", true);
await noblox.setCookie(cookie);
noblox.setCookie(cookie, false);
let alreadyOwned;
try {
// Check if the bot already owns this asset
alreadyOwned = await noblox.getOwnership(await noblox.getCurrentUser("UserID"), id, "Asset");
alreadyOwned = await noblox.getOwnership(await getCurrentUser(), id, "Asset");
} catch (error) {
if (error.message !== "400 The specified Asset does not exist!") {
throw error;