### Install noblox.js Locally Source: https://github.com/noblox/noblox.js/blob/master/README.md Run this command to install noblox.js locally to your repository. Ensure Node.js v18.18 or later is installed. ```bash # Run this to install noblox.js locally to your repository. $ npm install noblox.js ``` -------------------------------- ### Install noblox.js with Yarn Source: https://github.com/noblox/noblox.js/blob/master/README.md Alternatively, if you are using yarn, run this command to install noblox.js locally. ```bash # Alternatively, if you are using yarn: $ yarn add noblox.js ``` -------------------------------- ### Install noblox.js Globally Source: https://github.com/noblox/noblox.js/blob/master/README.md To use noblox.js anywhere on your system, run this command to install the package globally. Node.js v18.18 or later is required. ```bash # To use noblox.js anywhere, run this code to install the package globally: $ npm install noblox.js -g ``` -------------------------------- ### Start SSH Tunnel Source: https://github.com/noblox/noblox.js/blob/master/tutorials/VPS Authentication.md Initiate an SSH tunnel that forwards local traffic through your VPS. This command should be run from your local machine after whitelisting the port on the VPS. The tunnel will run on the specified port (e.g., 1234). ```console ssh -D 1234 your_user@your_server_ip ``` -------------------------------- ### Creating and Handling a Custom Promise Source: https://github.com/noblox/noblox.js/blob/master/tutorials/Promises.md Demonstrates how to create a custom Promise using the `new Promise()` constructor, which can either resolve with a value or reject with an error. The example shows how to handle both outcomes using .then() and .catch(). ```javascript const isCool = false; function amICool() { //Create a new Promise return new Promise(function(resolve, reject) { if (isCool) { //Resolve that isCool is true. resolve(true) } else { //Reject the Promise because only cool people can call this. reject("You aren't cool, don't call this function!") } }) } amICool().then(function(cool) { console.log("Am I cool?", cool) }).catch(function(err) { console.log("There was an error while checking if I'm cool", err) }) ``` -------------------------------- ### Get Product Information Source: https://github.com/noblox/noblox.js/wiki/Asset-Functions Retrieves detailed information about a specific Roblox asset, including its ID, product ID, name, creator, price, and sale status. The information is cached based on current settings. ```javascript rbx.getProductInfo(asset) ``` -------------------------------- ### Demote User with async/await in noblox.js Source: https://github.com/noblox/noblox.js/blob/master/tutorials/Promises.md Use async/await to asynchronously get a user's ID and then demote them. The await keyword pauses execution until the Promise resolves or rejects, and .catch handles potential errors during ID retrieval. ```javascript const noblox = require("noblox.js"); //await can only be used in async functions! async function DemoteUser (groupId, username) { //await will yield the code until a value is returned. const userId = await noblox.getIdFromUsername(username).catch(function(error) { console.log("There was an error getting the id!", error) }); //Handle the rejection accordingly. if (!userId) return console.log("No id was returned."); noblox.demote(groupId, userId); //Use the value returned to demote the user. } DemoteUser(1, "popeeyy"); ``` -------------------------------- ### getVerification Source: https://github.com/noblox/noblox.js/wiki/Utility-Functions Retrieves verification inputs from a given URL, with options to ignore cache, get the response body, and use a specific cookie jar. ```APIDOC ## getVerification ### Description Gets verification inputs off of `url` using `jar` and caches them. If `getBody` is true, the body and inputs will both be returned in an object. The `header` is the value of the `__RequestVerificationToken` cookie if it exists. If `ignoreCache` is enabled, the resulting tokens will not be cached. ### Method Signature `getVerification(url[, ignoreCache, getBody, jar])` ### Parameters - **url** (string) - The URL to fetch verification inputs from. - **ignoreCache** (boolean, optional) - Defaults to `false`. If true, cached tokens will not be used. - **getBody** (boolean, optional) - Defaults to `false`. If true, the response body will also be returned. - **jar** (CookieJar, optional) - The cookie jar to use for the request. ### Returns (Promise) - An object containing: - **body** (string, optional) - The response body if `getBody` is true. - **inputs** (Object) - An object where keys are input names and values are input values. - **header** (string) - The value of the `__RequestVerificationToken` cookie. ``` -------------------------------- ### Get Group Wall Posts Source: https://github.com/noblox/noblox.js/wiki/Group-Functions Retrieves posts from a group's wall. Supports pagination and streaming for large walls. The `getStatus` function on the returned promise provides operation progress. ```javascript rbx.getWall(18, { page: 1 }).then(function (wall) { console.log(wall.posts); }); ``` -------------------------------- ### Connect to VPS via SSH Source: https://github.com/noblox/noblox.js/blob/master/tutorials/VPS Authentication.md Use this command to establish an SSH connection to your VPS. Replace 'your_user' and 'your_server_ip' with your actual credentials. ```console ssh your_user@your_server_ip ``` -------------------------------- ### Get User Status - Noblox.js Source: https://github.com/noblox/noblox.js/wiki/User-Functions Fetches the status message of a specific user identified by their user ID. ```javascript rbx.getStatus(userId).then(function (status) { console.log(status); }); ``` -------------------------------- ### Get Username from ID - Noblox.js Source: https://github.com/noblox/noblox.js/wiki/User-Functions Retrieves a user's username using their unique user ID. The result is cached based on the library's settings. ```javascript rbx.getUsernameFromId(id).then(function (username) { console.log(username); }); ``` -------------------------------- ### Get a Module-Managed Cookie Jar Source: https://github.com/noblox/noblox.js/wiki/Usage Obtain a cookie jar managed by the noblox.js module. This jar respects the 'session_only' setting and simplifies cookie management for single-user scenarios. ```javascript var rbx = require('noblox.js'); var jar = rbx.jar(); ``` -------------------------------- ### Initialize and Authenticate with noblox.js Source: https://github.com/noblox/noblox.js/blob/master/README.md This snippet demonstrates how to initialize the noblox.js library and authenticate using a .ROBLOSECURITY cookie. Ensure you replace the placeholder cookie with your actual cookie. Authentication is required for methods marked with 🔐. ```javascript const noblox = require('noblox.js') async function startApp () { // You MUST call setCookie() before using any authenticated methods [marked by 🔐] // Replace the parameter in setCookie() with your .ROBLOSECURITY cookie. const currentUser = await noblox.setCookie('_|WARNING:-DO-NOT-SHARE-THIS.--Sharing-this-will-allow-someone-to-log-in-as-you-and-to-steal-your-ROBUX-and-items.|_6E6F626C6F782E6A73') console.log(`Logged in as ${currentUser.UserName} [${currentUser.UserID}]`) // Do everything else, calling functions and the like. const groupInfo = await noblox.getGroup(9997719) console.log(groupInfo) } startApp() ``` -------------------------------- ### Login with Options Object Source: https://github.com/noblox/noblox.js/wiki/Usage An alternative login method using an options object for username and password. This is useful for cleaner code when dealing with multiple credentials or configurations. ```javascript var rbx = require('noblox.js'); var options = { username: 'shedletsky', password: 'hunter2' } rbx.login(options) .then(function () { console.log('Logged in') }) .catch(function (err) { console.error(err.stack); }); ``` -------------------------------- ### configureItem Source: https://github.com/noblox/noblox.js/wiki/Asset-Functions Configures an existing item (shirt, pants, decal, etc.) by updating its name, description, and sale status. It can also enable or disable comments and set the price for sale. ```APIDOC ## configureItem ### Description Configures an item (shirt, pants, decal, etc.) with the id `id` to have `name` and `description`. If `enableComments` is true comments will be allowed and if `sellForRobux` is set it will be put on sale for that amount of robux. ### Method ``` configureItem(id: number, name: string, description: string, enableComments?: boolean, sellForRobux?: number, genreSelection?: number, jar?: CookieJar) ``` ### Parameters #### Arguments - `id` (number): The ID of the item to configure. - `name` (string): The new name for the item. - `description` (string): The new description for the item. - `enableComments` (boolean, optional): Whether to allow comments on the item. Defaults to `false`. - `sellForRobux` (number, optional): The price in Robux to sell the item for. Defaults to `false` (not for sale). - `genreSelection` (number, optional): The genre selection for the item. Defaults to `1`. - `jar` (CookieJar, optional): The cookie jar to use for authentication. ### Returns (Promise) ``` -------------------------------- ### Get Specific Group Wall Post Source: https://github.com/noblox/noblox.js/wiki/Group-Functions Fetches a single post from a group's wall by its ID. Optionally, a page number can be provided to optimize the search. View information can also be returned if needed. ```javascript rbx.getWallPost(18, 12345).then(function (post) { console.log(post); }); ``` -------------------------------- ### Create a Custom CookieJar with request-promise Source: https://github.com/noblox/noblox.js/wiki/Usage Instantiate a CookieJar using the 'request-promise' library. This jar will contain all cookies, including the session, and is suitable for advanced cookie management. ```javascript var request = require('request-promise'); var jar = request.jar(); ``` -------------------------------- ### generalRequest Source: https://github.com/noblox/noblox.js/wiki/Utility-Functions Fetches verification inputs from a URL and sends a POST request with event data. It can return the original body and respect caching. ```APIDOC ## generalRequest ### Description Gets the verification inputs from `url` and sends a post request with data from `events`, returning the original body before the post request according to `getBody` and obeying the cache based on `ignoreCache`. Use `http` for custom request options for the post request; if url is contained, it will not replace the main url but the url used for getting verification tokens. This function is used for primitive site functions that involve ASP viewstates. ### Method (Implicitly a function call in a JavaScript context) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Arguments - url (string) - The URL to fetch verification inputs from. - events (Object) - An object containing data for the POST request. - _optional_ ignoreCache (boolean) - If true, cache is ignored. Defaults to false. - _optional_ getBody (boolean) - If true, the original response body is returned. Defaults to false. - _optional_ jar (CookieJar) - The cookie jar to use for the request. ### Returns (Promise) - (Object) - res (Object) - The response object from the request. - body (string) - The original response body if `getBody` is true. ### Request Example ```javascript // Assuming 'jar' is a valid CookieJar object const result = await noblox.generalRequest('https://example.com/page', { eventData: 'value' }, false, true, jar); console.log(result.body); ``` ### Response #### Success Response - res (Object): The response object. - body (string): The original response body (if `getBody` is true). #### Response Example ```json { "res": { /* ... response details ... */ }, "body": "..." } ``` ``` -------------------------------- ### Update Settings and Initialize Options Source: https://github.com/noblox/noblox.js/wiki/Usage Modify module settings directly and then re-initialize options. This is useful for customizing cache expiration or session handling behavior. ```javascript var rbx = require('noblox.js'); var request = require('request'); rbx.settings.session_only = false; rbx.settings.cache.XCSRF.expire = 60; rbx.options.init(); ``` -------------------------------- ### follow Source: https://github.com/noblox/noblox.js/wiki/User-Functions Follows a specified user by their user ID. ```APIDOC ## follow ### Description Follows the user with `userId`. ### Method (Implicitly a function call in the SDK) ### Parameters #### Path Parameters - **userId** (number) - Required - The ID of the user to follow. - **jar** (CookieJar) - Optional - The cookie jar to use for authentication. ### Returns (Promise) ``` -------------------------------- ### Get Inbox Messages - Noblox.js Source: https://github.com/noblox/noblox.js/wiki/User-Functions Retrieves messages from the user's inbox. Supports pagination, limiting results, and filtering by message tab (inbox, sent, archived). Page numbers are adjusted internally, with page 1 being the first page. ```javascript rbx.getMessages(1, 1).then(function (inbox) { console.log(inbox.messages[0]); }); ``` -------------------------------- ### http Source: https://github.com/noblox/noblox.js/wiki/Utility-Functions Sends an HTTP request to a specified URL with optional configurations, including handling login errors and adding verification tokens. ```APIDOC ## http ### Description Sends an http request to `url` with `options`. If `ignoreLoginError` is true the function will not error when the user is redirected to the ROBLOX login page, otherwise it will as detection for failed logins and preventing further errors. The custom option `verification` adds the token to the cookies as `__RequestVerificationToken`. _Note that if jar is a key in the options object but is still null, the default jar will be used_ ### Method Signature `http(url[, options, ignoreLoginError])` ### Parameters - **url** (string) - The URL to send the HTTP request to. - **options** (Object, optional) - Additional options for the request. - **verification** (string, optional) - A verification token to be added to the cookies as `__RequestVerificationToken`. - **ignoreLoginError** (boolean, optional) - If true, the function will not throw an error if the user is redirected to the login page. ### Returns (Promise) - The response body as a string. ``` -------------------------------- ### login Source: https://github.com/noblox/noblox.js/wiki/User-Functions Logs into a user account with provided username and password, storing cookies. ```APIDOC ## login ### Description Logs into `username` with `password` and stores their cookie in `jar`. ### Method (Implicitly a function call in the SDK) ### Parameters #### Path Parameters - **username** (string) - Required - The username for login. - **password** (string) - Required - The password for login. - **jar** (CookieJar) - Optional - The cookie jar to store authentication cookies. ### Returns (Promise) - userInfo (Object) - userId (number) ``` -------------------------------- ### Handle Group Join Requests Source: https://github.com/noblox/noblox.js/wiki/Group-Functions Emits join requests and waits for them to be handled. It fires a 'handle' event with the request and a boolean indicating acceptance or rejection. A callback can be provided to execute after handling. This function manages pagination and includes timeouts. ```javascript var blacklist = [1, 261] var evt = rbx.onJoinRequestHandle(18) evt.on('data', function (request) { rbx.getIdFromUsername(request.username).then(function (id) { for (var i = 0; i < blacklist.length; i++) { if (blacklist[i] === id) { evt.emit('handle', request, false); return; } } evt.emit('handle', request, true, function () { rbx.message(id, 'Welcome', 'Welcome to my group'); }); }); }); ``` -------------------------------- ### Connect Chrome to SOCKS5 Proxy Source: https://github.com/noblox/noblox.js/blob/master/tutorials/VPS Authentication.md Launch Google Chrome in incognito mode and configure it to use the SOCKS5 proxy established by the SSH tunnel. This directs your browser traffic through your VPS. ```bash start chrome --incognito --proxy-server="socks5://localhost:1234" https://www.roblox.com/login ``` -------------------------------- ### Login with Username and Password Source: https://github.com/noblox/noblox.js/wiki/Usage Use this method to log in to Roblox using your username and password. Promises are used to handle asynchronous operations, with .then for success and .catch for errors. ```javascript var rbx = require('noblox.js'); rbx.login('shedletsky', 'hunter2') .then(function () { console.log('Logged in') }) .catch(function (err) { console.error(err.stack); }); ``` -------------------------------- ### onWallPost Source: https://github.com/noblox/noblox.js/wiki/Group-Functions Fires an event when a new wall post is made in the specified group. Optionally returns viewstate information if enabled. ```APIDOC ## onWallPost ### Description Fires when there is a new wall post in the group with groupId `group`. If `view` is enabled the wall posts viewstate will be returned in `view`, otherwise it will not be present. ### Method Signature onWallPost(group, [view], [jar]) ### Parameters #### Path Parameters - **group** (number) - Required - The ID of the group to listen for wall posts. - **view** (boolean) - Optional - If enabled, the viewstate information will be returned. - **jar** (CookieJar) - Optional - The cookie jar to use for authentication. ### Returns (EventEmitter) - **data** (Object) - **post** (Object) - **content** (String) - The content of the wall post. - **author** (Object) - **id** (number) - The ID of the author. - **name** (String) - The name of the author. - **date** (Date) - The date the post was made. - **id** (number) - The ID of the wall post. - **view** (Object) - Contains viewstate information if `view` parameter is enabled. - **`__VIEWSTATE`** (string) - **`__VIEWSTATEGENERATOR`** (string) - **`__EVENTVALIDATION`** (string) - **`__RequestVerificationToken`** (string) ``` -------------------------------- ### buy Source: https://github.com/noblox/noblox.js/wiki/Asset-Functions Buys an asset with specified price restrictions. It can handle single price values or a range (high/low) for price limits. If no price restriction is set, it buys the asset at its current cost. It can accept either an asset ID or product information. ```APIDOC ## buy ### Description Buys asset `asset` with `price` restrictions. This can be a single value or an object with `high` and `low` that sets the respective price limits (both inclusive). This allows you to buy assets with a minimum or maximum amount of robux that can be used or a single required value and therefore guarantees you can't be scammed by a sudden price change. If a price restriction is not set, the asset will be bought for however much it costs (works with free assets). You are able to use product instead of asset, the options in `product` are collected automatically if not provided. ### Method ``` buy(asset: number | { ProductId: number, Creator: { Id: number }, PriceInRobux: number, UserAssetId?: number }, price?: number | { high: number, low: number }, jar?: CookieJar) ``` ### Parameters #### Arguments - `asset` (number): The ID of the asset to buy. - `asset` (Object): Product information. - `ProductId` (number): The product ID. - `Creator` (Object): Information about the creator. - `Id` (number): The creator's ID. - `PriceInRobux` (number): The price of the product in Robux. - `UserAssetId` (number, optional): The user's asset ID. - `price` (number | Object, optional): Price restrictions for the purchase. - `high` (number): The maximum price (inclusive). - `low` (number): The minimum price (inclusive). - `jar` (CookieJar, optional): The cookie jar to use for authentication. ### Returns (Promise) - (Object) - `productId` (number): The ID of the product purchased. - `price` (number): The price at which the asset was bought. ``` -------------------------------- ### getProductInfo Source: https://github.com/noblox/noblox.js/wiki/Asset-Functions Retrieves detailed information about a specific asset, including its ID, product ID, name, creator, price, and sale status. The information is cached according to system settings. ```APIDOC ## getProductInfo ### Description Gets `info` of `asset` and caches according to settings. ### Method ``` getProductInfo(asset: number) ``` ### Parameters #### Arguments - `asset` (number): The ID of the asset for which to retrieve information. ### Returns (Promise) - `info` (Object): An object containing detailed information about the asset, including: - `AssetId` (number): The asset's unique identifier. - `ProductId` (number): The product's unique identifier. - `Name` (string): The name of the asset. - `Description` (string): The description of the asset. - `AssetTypeId` (number): The type of the asset. - `Creator` (Object): Information about the asset's creator. - `Id` (number): The creator's ID. - `Name` (string): The creator's name. - `IconImageAssetId` (number): The ID of the icon image asset. - `Created` (string): The creation date and time of the asset. - `Updated` (string): The last updated date and time of the asset. - `PriceInRobux` (number): The price of the asset in Robux. - `PriceInTickets` (number | null): The price of the asset in Tickets (if applicable). - `Sales` (number): The number of sales. - `IsNew` (boolean): Whether the asset is new. - `IsForSale` (boolean): Whether the asset is currently for sale. - `IsPublicDomain` (boolean): Whether the asset is in the public domain. - `IsLimited` (boolean): Whether the asset is a limited item. - `IsLimitedUnique` (boolean): Whether the asset is a unique limited item. - `Remaining` (number | null): The number of remaining units for limited items. - `MinimumMembershipLevel` (number): The minimum membership level required to purchase. - `ContentRatingTypeId` (number): The content rating type ID. ``` -------------------------------- ### Create a Custom Cookie Jar Object Source: https://github.com/noblox/noblox.js/wiki/Usage Manually create a cookie jar object for managing user sessions. This is useful when working with multiple users or custom session storage. ```javascript var jar = {'session': 'AAAAA'}; ``` -------------------------------- ### getWall Source: https://github.com/noblox/noblox.js/wiki/Group-Functions Retrieves posts from a group wall. Supports pagination and streaming for large walls. Optionally returns viewstates for each page. ```APIDOC ## getWall ### Description Gets posts on the `group` wall. Parameter `page` may be a number or array where negative numbers indicate trailing pages, if it is not specified all pages of the wall will be retrieved. The body of the post is in `content` and the `id` and `name` of the poster are stored in the `author` object. The `id` is the unique ID of the wall post that is internally used by ROBLOX. This serves no real use other than reporting it (although it can be used indirectly to track down specific posts). The `page` the post was found on and its `index` on that page are both in the `parent` object. If `view` is true the viewstates of each page will be returned in the `views` object, with each page having its viewstates at the corresponding page number. For example page 5 of the wall will have its view stored in `wall.views[5]`. The `getStatus` function is returned as a property of the promise and returns the percent completion of the operation. If `stream` is specified `post` objects will be written to the stream and will _not_ be added to the wall object. The stream can process posts as they are retrieved but for the most part should be written to a file for post processing. This should be used for extremely large walls, as when javascript arrays reach a certain point it slows down considerably and will begin running into a lot of errors. Note that if `stream` is specified the entries will _not_ be returned in order because there is no chance for the script to sort them. Page numbers and indexes, however, are always returned with the post, allowing the data to be sorted later. The `wall` object will still be fulfilled with the promise at the end but the `posts` array will be empty. ### Arguments - group (number) - _optional_ page (number/Array) - _optional_ stream (Stream) - _optional_ jar (CookieJar) ### Returns (Promise) - wall (Object) - posts (Array) - post (Object) - content (string) - author (Object) - id (number) - name (string) - date (Date) - parent (Object) - page (number) - index (number) - id (number) - totalPages (number) - views (Object) - page (number): view (Object) - `__VIEWSTATE` (string) - `__VIEWSTATEGENERATOR` (string) - `__EVENTVALIDATION` (string) - `__RequestVerificationToken` (string) ``` -------------------------------- ### jar Source: https://github.com/noblox/noblox.js/wiki/Utility-Functions Creates a cookie jar, optionally for session-only cookies. Typically used internally or when specific cookie management is required. ```APIDOC ## jar ### Description Creates a jar file based on `sessionOnly`. Normally you will not need this argument as the function will use the default from settings.json. If for some other reason you need a jar file you can collect it this way, but without changing the settings it will not work. ### Method Signature `jar([sessionOnly])` ### Parameters - **sessionOnly** (boolean, optional) - If true, the jar will only store session cookies. ### Returns - **jar** (CookieJar) - A new cookie jar instance. ``` -------------------------------- ### Set User Rank by Rank Name Source: https://github.com/noblox/noblox.js/wiki/Home Promotes a player by their userId to a specified rank name within a group using an options object. The corresponding role object is returned. ```javascript var options = { group: 18, target: 2470023, name: 'Initiate' } rbx.setRank(options) .then(function (newRole) { console.log('The new role is: ' + JSON.stringify(newRole)); }); ``` -------------------------------- ### Utility Functions Source: https://github.com/noblox/noblox.js/wiki/Quick-Reference General utility functions for various tasks. ```APIDOC ## clearSession ### Description Clears the current user session. ## generalRequest ### Description Performs a general request to the Roblox API. ### Parameters #### Request Body - **options** (object) - Required - Options for the request. ## getAction ### Description Gets an action. ## getCurrentUser ### Description Retrieves the currently authenticated user. ## getForumError ### Description Gets forum error information. ## getGeneralToken ### Description Retrieves a general token. ## getHash ### Description Generates a hash. ## getInputs ### Description Gets input values. ## getSenderUserId ### Description Retrieves the user ID of the sender. ## getSession ### Description Retrieves the current session information. ## getVerification ### Description Performs a verification process. ## getVerificationInputs ### Description Gets inputs required for verification. ## http ### Description Performs an HTTP request. ### Parameters #### Request Body - **options** (object) - Required - HTTP request options. ## jar ### Description Manages cookies. ## shortPoll ### Description Performs a short polling request. ### Parameters #### Request Body - **options** (object) - Required - Options for the short poll. ## threaded ### Description Performs a threaded operation. ``` -------------------------------- ### onJoinRequestHandle Source: https://github.com/noblox/noblox.js/wiki/Group-Functions Manages and handles group join requests. Emits events for each request and allows for asynchronous handling, including callbacks for post-handling actions. ```APIDOC ## onJoinRequestHandle ### Description This function emits all join requests and waits until all of them have been resolved by firing the `handle` event with the request and either true or false. You can also pass a third argument `callback` to handle to execute once the join request has been handled. Once all requests on a page have been resolved, the next page is collected. Make sure that all join requests are handled in some way. Because this function has to wait for input, it does handle timeouts but does them within the function as opposed to within shortPoll. To accept all new users that aren't on a blacklist and send them a message, for example: ```javascript var blacklist = [1, 261] var evt = rbx.onJoinRequestHandle(18) evt.on('data', function (request) { rbx.getIdFromUsername(request.username).then(function (id) { for (var i = 0; i < blacklist.length; i++) { if (blacklist[i] === id) { evt.emit('handle', request, false); return; } } evt.emit('handle', request, true, function () { rbx.message(id, 'Welcome', 'Welcome to my group'); }); }); }); ``` ### Arguments - group (number) - _optional_ jar (CookieJar) ### Settings - event - onJoinRequestHandle (number) ### Returns (EventEmitter) - data - request (Object) - name (string) - date (Date) - requestId (number) ``` -------------------------------- ### Handle Forum Reply Events Source: https://github.com/noblox/noblox.js/wiki/Usage This snippet demonstrates how to use EventEmitter to listen for new forum replies. It binds to 'data', 'error', and 'close' events, closing the emitter after receiving a reply. ```javascript var onForumReply = rbx.onForumReply(forumId); onForumReply.on('data', function (post) { console.log(post); onForumReply.emit('close'); }); onForumReply.on('error', function (err) { console.error(err.stack); }); ``` -------------------------------- ### Upload Model File Stream Source: https://github.com/noblox/noblox.js/wiki/Asset-Functions Uploads model data as a stream for new or existing assets. For new assets, itemOptions including name, description, and locking settings are required. Existing assets only require data. ```javascript var fs = require('fs'); rbx.uploadModel(fs.createReadStream('./model'), {name: 'Model'}); ``` -------------------------------- ### handleJoinRequest Source: https://github.com/noblox/noblox.js/wiki/Group-Functions Accepts or rejects a user's join request to a group based on their username. Note that the username is case-sensitive. ```APIDOC ## handleJoinRequest ### Description `Accept`s user with `username` into `group`. Note that `username` is case-sensitive. ### Method `handleJoinRequest(group, username, accept[, jar])` ### Parameters #### Path Parameters - **group** (number) - Required - The ID of the group. - **username** (string) - Required - The username of the user requesting to join. - **accept** (boolean) - Required - True to accept, false to reject. - **jar** (CookieJar) - Optional - The cookie jar to use for authentication. ### Returns (Promise) ``` -------------------------------- ### getJoinRequests Source: https://github.com/noblox/noblox.js/wiki/Group-Functions Retrieves the first page of join requests for a specified group. ```APIDOC ## getJoinRequests ### Description Gets the first page of join requests from a specified group. ### Method (Implicitly a function call, not HTTP) ### Parameters #### Arguments - **group** (number) - Required - The ID of the group. - **jar** (CookieJar) - Optional - The cookie jar to use for authentication. ### Returns #### Promise - **requests** (Array) - An array of join request objects. - **request** (Object) - **username** (string) - The username of the requester. - **date** (Date) - The date the request was made. - **requestId** (number) - The ID of the join request. ``` -------------------------------- ### Set User Rank with Cookie Jar Source: https://github.com/noblox/noblox.js/wiki/Home Promotes a player by their userId to a specified rank number within a group, explicitly providing a cookie jar in the options object. The function returns the new role information. ```javascript var cookie = rbx.jar(); var options = { group: 18, target: 2470023, rank: 10, jar: cookie } rbx.setRank(options) .then(function (newRole) { console.log('The new role is: ' + JSON.stringify(newRole)); }); ``` -------------------------------- ### getHash Source: https://github.com/noblox/noblox.js/wiki/Utility-Functions Generates a unique hash for a given cookie jar, useful for caching. ```APIDOC ## getHash ### Description Generates a unique hash for the given jar file `jar` or default if none is specified. Typically used to cache items that depend on session. ### Method (Implicitly a function call in a JavaScript context) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Arguments - _optional_ jar (CookieJar) - The cookie jar for which to generate a hash. Defaults to the global jar. ### Returns - hash (string) - The generated unique hash. ### Request Example ```javascript const sessionHash = noblox.getHash(jar); console.log(sessionHash); ``` ### Response #### Success Response - hash (string): The generated hash value. #### Response Example ```json "a1b2c3d4e5f67890" ``` ``` -------------------------------- ### Set User Rank by Rank Number Source: https://github.com/noblox/noblox.js/wiki/Home Promotes a player by their userId to a specified rank number within a group. Uses the default global cookie jar if none is provided. ```javascript rbx.setRank(18, 2470023, 10) .then(function (newRole) { console.log('The new role is: ' + JSON.stringify(newRole)); }); ``` -------------------------------- ### getBlurb Source: https://github.com/noblox/noblox.js/wiki/User-Functions Retrieves the blurb (profile description) of a user by their user ID. ```APIDOC ## getBlurb ### Description Gets the `blurb` of the user with the ID `userId`. ### Method (Implicitly a function call in the SDK) ### Parameters #### Path Parameters - **userId** (number) - Required - The ID of the user whose blurb to retrieve. ### Returns (Promise) - blurb (string) ``` -------------------------------- ### promote Source: https://github.com/noblox/noblox.js/wiki/Group-Functions Promotes a user within a group. This is an alias for `changeRank(group, target, 1)`. ```APIDOC ## promote ### Description Promotes a user to the next rank in the group. ### Method (Implicitly a function call, not HTTP) ### Parameters #### Arguments - group (number) - The ID of the group. - target (number) - The user ID of the target to promote. - jar (CookieJar) - Optional. A CookieJar object for managing authentication. ### Returns (Promise) - A promise that resolves with role information. - roles (Object) - newRole (Object) - name (string) - rank (number) - ID (number) - oldRole (Object) - name (string) - rank (number) - ID (number) ``` -------------------------------- ### getVerificationInputs Source: https://github.com/noblox/noblox.js/wiki/Utility-Functions Extracts verification inputs (like __VIEWSTATE, __EVENTVALIDATION) from HTML content, typically used for ASP.NET applications. ```APIDOC ## getVerificationInputs ### Description Gets verification inputs from `html`. Short for `getInputs(html,['__VIEWSTATE','__VIEWSTATEGENERATOR','__EVENTVALIDATION, '__RequestVerificationToken']')`. Typically used for ROBLOX requests working with ASP.NET. If you have already loaded html with a parser you can pass the `selector` directly. ### Method Signature `getVerificationInputs(html/selector)` ### Parameters - **html** (string) - The HTML content to parse. - **selector** (function) - A function that acts as a selector for parsing. ### Returns - **inputs** (Object) - An object where keys are input names (e.g., `__VIEWSTATE`) and values are their corresponding values. ``` -------------------------------- ### User Events Source: https://github.com/noblox/noblox.js/wiki/Quick-Reference Functions for subscribing to user-related events. ```APIDOC ## onFriendRequest ### Description Listens for incoming friend requests. ## onMessage ### Description Listens for new messages. ## onNotification ### Description Listens for notifications. ``` -------------------------------- ### Upload Image File Stream Source: https://github.com/noblox/noblox.js/wiki/Asset-Functions Uploads an image file as a stream for shirts, pants, or decals. Specify the asset type and name. Optionally, upload to a group by providing a groupId. ```javascript var fs = require('fs'); rbx.uploadImage('Shirt', 11, fs.createReadStream('./Image.png')); ``` -------------------------------- ### uploadItem Source: https://github.com/noblox/noblox.js/wiki/Asset-Functions Uploads an image file as a new asset (shirt, pants, or decal) with a specified name and asset type. Optionally, it can be uploaded to a specific group. Returns the ID of the newly created asset. ```APIDOC ## uploadItem ### Description Uploads an image stored in `file` as an `assetType` with `name`. If `groupId` is specified it will be uploaded to that group. This is for uploading shirts, pants, or decals which have the assetTypes `11`, `12`, and `13`, respectively. Returns the asset `id` of the new item. You should pass in the file as a stream, here is an example for uploading a shirt: ```javascript var fs = require('fs'); rbx.uploadImage('Shirt', 11, fs.createReadStream('./Image.png')); ``` ### Method ``` uploadItem(name: string, assetType: number, file: string | Stream, groupId?: number, jar?: CookieJar) ``` ### Parameters #### Arguments - `name` (string): The name of the asset to upload. - `assetType` (number): The type of asset (e.g., 11 for shirt, 12 for pants, 13 for decal). - `file` (string | Stream): The image file to upload, can be a path or a readable stream. - `groupId` (number, optional): The ID of the group to upload the asset to. - `jar` (CookieJar, optional): The cookie jar to use for authentication. ### Returns (Promise) - `id` (number): The ID of the uploaded asset. ``` -------------------------------- ### Listen for Friend Requests - Noblox.js Source: https://github.com/noblox/noblox.js/wiki/User-Functions An event emitter that fires whenever a new friend request is received. Requires a CookieJar for authentication. ```javascript var friendRequests = rbx.onFriendRequest(); friendRequests.on('data', function (data) { console.log('New friend request from user ID:', data.userId); }); ``` -------------------------------- ### Retrieve Global Cookie Jar Source: https://github.com/noblox/noblox.js/wiki/Usage Access the global cookie jar used by the module. This is the recommended approach when using the module with a single user. ```javascript var rbx = require('noblox.js'); var jar = rbx.options.jar; ``` -------------------------------- ### getInputs Source: https://github.com/noblox/noblox.js/wiki/Utility-Functions Extracts verification input values from HTML content, optionally filtering by specific input names. ```APIDOC ## getInputs ### Description Returns verification inputs on the page with the names in `find` - or all inputs if not provided. Typically used for ROBLOX requests working with ASP.NET. ### Method (Implicitly a function call in a JavaScript context) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Arguments - html (string) - The HTML content of the page. - _optional_ find (array) - An array of input names to specifically find. ### Returns - inputs (Object) - An object where keys are input names and values are their corresponding values. - name (string): value (string) ### Request Example ```javascript const htmlContent = ""; const viewState = noblox.getInputs(htmlContent, ['__VIEWSTATE']); console.log(viewState.__VIEWSTATE); const allInputs = noblox.getInputs(htmlContent); console.log(allInputs.username); ``` ### Response #### Success Response - inputs (Object): An object containing the found input names and their values. #### Response Example ```json { "__VIEWSTATE": "your_viewstate_value", "username": "testuser" } ``` ``` -------------------------------- ### getRoles Source: https://github.com/noblox/noblox.js/wiki/Group-Functions Retrieves all role information for a specified group. ```APIDOC ## getRoles ### Description Returns role information for a group with the specified group ID. ### Method (Implicitly a function call, not HTTP) ### Parameters #### Arguments - **group** (number) - Required - The ID of the group. ### Returns #### Promise - **roles** (Object) - An array of role objects, each containing ID, name, and rank. ``` -------------------------------- ### Listen for Notifications - Noblox.js Source: https://github.com/noblox/noblox.js/wiki/User-Functions Utilizes WebSockets to connect to ROBLOX's notification system, providing real-time event data. User must have relevant notifications enabled in settings. Notifications have a `name` and `message` object, which includes a `type` field. ```javascript var notifications = rbx.onNotification(); notifications.on('data', function (name, message) { if (name === 'NotificationStream' && message.Type === 'NewNotification') { // A new message was received, retrieve the inbox to read it. } }); ``` -------------------------------- ### post Source: https://github.com/noblox/noblox.js/wiki/Group-Functions Posts a message to a group's wall. ```APIDOC ## post ### Description Posts a message to the group wall. ### Method (Implicitly a function call, not HTTP) ### Parameters #### Arguments - group (number) - The ID of the group. - message (string) - The message to post. - jar (CookieJar) - Optional. A CookieJar object for managing authentication. ### Returns (Promise) - A promise that resolves when the message has been posted. ``` -------------------------------- ### getForumError Source: https://github.com/noblox/noblox.js/wiki/Utility-Functions Processes forum-related 302 errors and returns a corresponding error message. ```APIDOC ## getForumError ### Description Processes some forum-related 302 error and returns a corresponding message. The argument `append` is optional and describes the calling function. ### Method (Implicitly a function call in a JavaScript context) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Arguments - location (string) - The location string associated with the forum error. - _optional_ append (string) - An optional string describing the calling function. ### Returns (Promise) - (Error) - An error object with a descriptive message. ### Request Example ```javascript try { // ... some operation that might cause a forum error ... } catch (error) { const forumError = await noblox.getForumError('thread_page', 'deletePost'); console.error(forumError.message); } ``` ### Response #### Success Response - Error object with a message property. #### Response Example ```json { "message": "Error processing forum action at thread_page." } ``` ``` -------------------------------- ### joinGroup Source: https://github.com/noblox/noblox.js/wiki/Group-Functions Joins a group with the specified ID. Optionally uses caching to prevent errors when joining/leaving multiple groups. ```APIDOC ## joinGroup ### Description Joins the group with the specified ID. ### Method (Implicitly a function call, not HTTP) ### Parameters #### Arguments - group (number) - The ID of the group to join. - useCache (boolean) - Optional. If enabled, the function will cache results. Defaults to false. - jar (CookieJar) - Optional. A CookieJar object for managing authentication. ### Returns (Promise) - A promise that resolves when the group has been joined. ``` -------------------------------- ### getSession Source: https://github.com/noblox/noblox.js/wiki/Utility-Functions Retrieves the `.ROBLOSECURITY` session cookie from the specified or default cookie jar. ```APIDOC ## getSession ### Description Gets the `.ROBLOSECURITY` session cookie from `jar`, which is the default jar file if not specified. ### Method (Implicitly a function call in a JavaScript context) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Arguments - _optional_ jar (CookieJar) - The cookie jar from which to retrieve the session cookie. Defaults to the global jar. ### Returns - session (string) - The `.ROBLOSECURITY` session cookie value. ### Request Example ```javascript const sessionCookie = noblox.getSession(jar); console.log(sessionCookie); ``` ### Response #### Success Response - session (string): The session cookie value. #### Response Example ```json "your_session_cookie_value" ``` ``` -------------------------------- ### Connect Edge to SOCKS5 Proxy Source: https://github.com/noblox/noblox.js/blob/master/tutorials/VPS Authentication.md Launch Microsoft Edge in private browsing mode and configure it to use the SOCKS5 proxy. This ensures your login request uses the SSH tunnel. ```bash start msedge --inprivate --proxy-server="socks5://localhost:1234" https://www.roblox.com/login ``` -------------------------------- ### Listen for Group Shout Updates Source: https://github.com/noblox/noblox.js/wiki/Group-Functions Use this function to receive real-time notifications when a group's shout is updated. Requires prior login if the group's shout is private. Logs the poster's username and the shout body to the console. ```javascript let GroupID = 123456; rbx.cookieLogin(cookie).then((success) => { let onShout = rbx.onShout(GroupID); onShout.on('data', function(post) { console.log(`${post.poster.username} shouted: ${post.body}`); }); onShout.on('error', function (err) { console.error(err.stack); }); console.log('Logged in.'); }).catch((err) => console.error(err.stack)); ``` -------------------------------- ### onFriendRequest Source: https://github.com/noblox/noblox.js/wiki/User-Functions An event emitter that fires when new friend requests are received. ```APIDOC ## onFriendRequest ### Description Fires when new friend requests are received. ### Arguments - _optional_ jar (CookieJar): The CookieJar to use for authentication. ### Returns (EventEmitter) - data - userId (number): The ID of the user who sent the friend request. ``` -------------------------------- ### Whitelist Port in Firewall Source: https://github.com/noblox/noblox.js/blob/master/tutorials/VPS Authentication.md Allow traffic on a specific port through your VPS's firewall. This port will be used for the SSH tunnel. Replace '1234' with your chosen port number. ```console sudo ufw allow 1234 ```