Update Noblox to 6.0.2 #25
@ -4,7 +4,7 @@ const fs = require('node:fs');
|
|||||||
const noblox = require("noblox.js");
|
const noblox = require("noblox.js");
|
||||||
const axios = require("axios").default;
|
const axios = require("axios").default;
|
||||||
const { submissions, commands, cookies } = require("../config/config.js");
|
const { submissions, commands, cookies } = require("../config/config.js");
|
||||||
const { getAssetInfo, getCurrentUser, SubmissionColumnsString, createSubmissionLine, getSubmissionLine, validateMapAsset, getValidationMessage } = require("../common.js");
|
const { getAssetInfo, SubmissionColumnsString, createSubmissionLine, getSubmissionLine, validateMapAsset, getValidationMessage } = require("../common.js");
|
||||||
|
|
||||||
async function robloxUserFromDiscord(id) {
|
async function robloxUserFromDiscord(id) {
|
||||||
if (isNaN(id)) return undefined;
|
if (isNaN(id)) return undefined;
|
||||||
@ -52,7 +52,8 @@ async function execute(interaction) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Check that the bot owns this model
|
// Check that the bot owns this model
|
||||||
if (!(await noblox.getOwnership(await getCurrentUser(), id, "Asset"))) {
|
const robloxUser = await noblox.getAuthenticatedUser();
|
||||||
|
if (!(await noblox.getOwnership(robloxUser.id, id, "Asset"))) {
|
||||||
const msg = `🚫 The ${game} maptest bot's inventory does not contain this asset (id: \`${id}\`). You must use the /take command first.`;
|
const msg = `🚫 The ${game} maptest bot's inventory does not contain this asset (id: \`${id}\`). You must use the /take command first.`;
|
||||||
await interaction.editReply(msg);
|
await interaction.editReply(msg);
|
||||||
return;
|
return;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||||
const noblox = require("noblox.js");
|
const noblox = require("noblox.js");
|
||||||
const { cookies, commands, gamePlaces } = require("../config/config.js");
|
const { cookies, commands, gamePlaces } = require("../config/config.js");
|
||||||
const { getAssetInfo, buyModel, getCurrentUser, validateMapAsset, getValidationMessage } = require("../common.js");
|
const { getAssetInfo, buyModel, validateMapAsset, getValidationMessage } = require("../common.js");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import('discord.js').ChatInputCommandInteraction} interaction
|
* @param {import('discord.js').ChatInputCommandInteraction} interaction
|
||||||
@ -20,7 +20,8 @@ async function execute(interaction) {
|
|||||||
let alreadyOwned;
|
let alreadyOwned;
|
||||||
try {
|
try {
|
||||||
// Check if the bot already owns this asset
|
// Check if the bot already owns this asset
|
||||||
alreadyOwned = await noblox.getOwnership(await getCurrentUser(), id, "Asset");
|
const robloxUser = await noblox.getAuthenticatedUser();
|
||||||
|
alreadyOwned = await noblox.getOwnership(robloxUser.id, id, "Asset");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.message !== "400 The specified Asset does not exist!") {
|
if (error.message !== "400 The specified Asset does not exist!") {
|
||||||
throw error;
|
throw error;
|
||||||
|
20
common.js
20
common.js
@ -90,24 +90,6 @@ async function buyModel(modelId) {
|
|||||||
return res.statusCode >= 200 && res.statusCode < 300 && resJson.purchaseTransactionStatus === "PURCHASE_TRANSACTION_STATUS_SUCCESS";
|
return res.statusCode >= 200 && res.statusCode < 300 && resJson.purchaseTransactionStatus === "PURCHASE_TRANSACTION_STATUS_SUCCESS";
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCurrentUser() {
|
|
||||||
const jar = noblox.options.jar;
|
|
||||||
const xcsrf = await noblox.getGeneralToken(jar);
|
|
||||||
|
|
||||||
const res = await noblox.http("https://users.roblox.com/v1/users/authenticated", {
|
|
||||||
method: "GET",
|
|
||||||
resolveWithFullResponse: true,
|
|
||||||
jar: jar,
|
|
||||||
headers: {
|
|
||||||
"X-CSRF-TOKEN": xcsrf,
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const resJson = JSON.parse(res.body);
|
|
||||||
return resJson.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
const SubmissionColumnsString = "map_id,unix_timestamp,user_id,username,display_name,creator\n";
|
const SubmissionColumnsString = "map_id,unix_timestamp,user_id,username,display_name,creator\n";
|
||||||
|
|
||||||
const SubmissionColumn = {
|
const SubmissionColumn = {
|
||||||
@ -366,4 +348,4 @@ function getValidationMessage(validation, game, errorOnFail) {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { AssetType, getAssetInfo, buyModel, getCurrentUser, SubmissionColumn, SubmissionColumnsString, getSubmissionLine, createSubmissionLine, validateMapAsset, getValidationMessage, safeCsvFormat };
|
module.exports = { AssetType, getAssetInfo, buyModel, SubmissionColumn, SubmissionColumnsString, getSubmissionLine, createSubmissionLine, validateMapAsset, getValidationMessage, safeCsvFormat };
|
@ -6,7 +6,7 @@
|
|||||||
"csv-parse": "^5.0.4",
|
"csv-parse": "^5.0.4",
|
||||||
"discord-api-types": "^0.37.81",
|
"discord-api-types": "^0.37.81",
|
||||||
"discord.js": "^14.14.1",
|
"discord.js": "^14.14.1",
|
||||||
"noblox.js": "^4.15.1",
|
"noblox.js": "^6.0.2",
|
||||||
"node-csv": "^0.1.2",
|
"node-csv": "^0.1.2",
|
||||||
"rbxm-parser": "^1.1.0",
|
"rbxm-parser": "^1.1.0",
|
||||||
"sugar-date": "^2.0.6"
|
"sugar-date": "^2.0.6"
|
||||||
|
Loading…
Reference in New Issue
Block a user