Skip to content

Group Functions

suufi edited this page Sep 22, 2019 · 4 revisions

Group Functions - noblox.js Wiki


changeRank

group, target, change[, jar]

Moves the user with userId target up or down the list of ranks in group by change. For example changeRank(group, target, 1) would promote the user 1 rank and changeRank(group, target, -1) would demote them down 1. Note that this simply follows the list, ignoring ambiguous ranks. The full newRole as well as the user's original oldRole is returned.

Arguments

  • group (number)
  • target (number)
  • change (number)
  • optional jar (CookieJar)

Returns

(Promise)

  • roles (Object)
    • newRole (Object)
      • name (string)
      • rank (number)
      • ID (number)
    • oldRole (Object)
      • name (string)
      • rank (number)
      • ID (number)

Back to Top


deleteWallPost

group, id/post[, page, jar]

Deletes the wall post with id in group. If page is known it can be inserted to speed up finding the post, otherwise it will search for the post. Alternatively post can be passed in, which only has to contain view and parent.index to work properly. Using post will be much faster because it will not have to search for the post first.

Arguments

  • group (number)
  • id (number)
  • or post (Object)
    • parent (Object)
      • index (number)
    • view (Object)
      • __VIEWSTATE (string)
      • __VIEWSTATEGENERATOR (string)
      • __EVENTVALIDATION (string)
      • __RequestVerificationToken (string)
  • optional page (number)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


demote

group, target[, jar]

Alias of changeRank(group, target, -1).

Arguments

  • group (number)
  • target (number)
  • optional jar (CookieJar)

Returns

(Promise)

  • roles (Object)
    • newRole (Object)
      • name (string)
      • rank (number)
      • ID (number)
    • oldRole (Object)
      • name (string)
      • rank (number)
      • ID (number)

Back to Top


exile

group, target[jar]

Exiles user with userId target from group.

Arguments

  • group (number)
  • target (number)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


groupPayout

group, member, amount[, recurring, usePercentage, jar]

Performs a payout in group with the groupId group. If recurring is true this will configure the recurring options for the group's payout replacing all old values, otherwise a one-time-payout is made. To clear the recurring payouts, pass in empty arrays to both member and amount. Argument member can either be a single userId or an array of userIds. If it is a single value amount must be as well, otherwise amount has to be a parallel array of equal length. If usePercentage is true amount percentage of the total group funds is paid to the members, otherwise it pays amount ROBUX. Note that recurring payouts are always percentages, and when recurring is true usePercentage is ignored.

Arguments

  • group (number)
  • members (number/Array)
    • either userId
    • or [userId1, userId2]
  • amount (number/Array)
    • either amount
    • or [amount1, amount2]
  • optional recurring
    • default false
  • optional usePercentage
    • default false
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


handleJoinRequest

group, username, accept[, jar]

Accepts user with username into group. Note that username is case-sensitive.

Arguments

  • group (number)
  • username (string)
  • accept (boolean)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


handleJoinRequestId

group, requestId, accept[, jar]

Raw utility for handling join requests based on their unique requestId. If accept is true the user is accepted into group, otherwise they are denied.

Arguments

  • group (number)
  • requestId (number)
  • accept (boolean)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


joinGroup

group[, useCache, jar]

Joins the group with id group. Unless useCache is enabled the function will not cache because errors will occur if joining or leaving the same group multiple times, you can enable it if you are only joining or leaving a group once or many differenct groups once.

Arguments

  • group (number)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


leaveGroup

group[, jar]

Leaves the group with id group. Unless useCache is enabled the function will not cache because errors will occur if joining or leaving the same group multiple times, you can enable it if you are only joining or leaving a group once or many differenct groups once.

Arguments

  • group (number)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


post

group, message[, jar]

Posts message message on the group wall with groupId group.

Arguments

  • group (number)
  • message (string)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


promote

group, target[, jar]

Alias of changeRank(group, target, 1).

Arguments

  • group (number)
  • target (number)
  • optional jar (CookieJar)

Returns

(Promise)

  • roles (Object)
    • newRole (Object)
      • name (string)
      • rank (number)
      • ID (number)
    • oldRole (Object)
      • name (string)
      • rank (number)
      • ID (number)

Back to Top


setRank

group, target, rank/roleset/name[, jar]

Promotes player with userId target in group with groupId group to rank rank, roleset roleset, or name name. One is required but not all, use roleset to speed up requests and name if there are ambiguous ranks (same rank number). If a rank or name was passed the corresponding role will be returned.

Arguments

  • group (number)
  • target (number)
  • either rank (number)
  • or roleset (number)
  • or name (string)
  • optional jar (CookieJar)

Returns

(Promise)

  • newRole (Object)
    • NOTE: If the function was called directly with a roleset only ID is present
    • name (string)
    • Rank (number)
    • ID (number)

Back to Top


shout

group, message[,jar]

Shouts message message in the group with groupId group. Setting message to "" will clear the shout.

Arguments

  • group (number)
  • message (string)
  • optional jar (CookieJar)

Returns

  • shout (Object)
    • body (string)
    • poster (Object)
      • userId (number)
      • username (string)
      • buildersClubMembershipType (string)
    • created (string)
    • updated (string)

Back to Top


getAuditLog

group[, page, action, username, stream, jar]

Gets audit log entries in group for the specified action or username where action is the actionTypeId. To find the actionTypeId for the action you want, go to the audit log and check the URL when you select a specific action. If username selected only entries from that user are searched for. To specify what page(s) to retrieve use page, which is a number or array of numbers. Negative numbers are allowed and instruct the function to return the trailing pages of the log.

Each row has an action object which contains the ID of the target and any parameters it gets. Currently this will be populated with change rank, shout, and delete post logs. The target is the ID of the user or game the action was targeted to. Sometimes there is no target and this will equal the user ID of the user who did the action. Params are in the order that they appear on the log.

For example, if you have a log with text: Froast changed user ROBLOX's rank from [L1] Initiate to [L2] Novice. then

log.action.params[0] == '[L1] Initiate'
log.action.params[1] == '[L2] Novice'
log.action.target == 1 // (ROBLOX's user ID)

Not all log types are supported, if the log you want isn't added you will have to get the parameters yourself by using the full text of the log.

The stream argument can be a writable stream in order to handle logs without taking up a ton of RAM. Each log is individually written to the stream. The audit object will still be fulfilled with the promise at the end but the logs array will be empty.

Logs are sorted from most newest to oldest.

Arguments

  • group (number)
  • optional page (number/Array)
  • optional action (number)
  • optional username (string)
  • optional jar (CookieJar)

Returns

(Promise)

  • audit (Object)
    • logs (Array)
      • user (Object)
        • name (string)
        • id (number)
        • role (string)
      • text (string)
        • Full text of the audit row
      • action (Object)
        • target (number)
        • params (Array)
      • date (Date)
      • parent (Object)
        • page (number)
        • index (number)
    • totalPages (number)
    • total (number)

Back to Top


getJoinRequests

group[, jar]

Gets the first page of join requests from group.

Arguments

  • group (number)
  • optional jar (CookieJar)

Returns

(Promise)

  • requests (Array)
    • request (Object)
      • username (string)
      • date (Date)
      • requestId (number)

Back to Top


getPlayers

group, roleset[, jar]

Gets all players in group with the array roleset

Arguments

  • group (number)
  • roleset (Array)

Returns

(Promise)

  • players (Array)
    • (Object)
      • userId (number)
      • username (string)
      • buildersClubMembershipType (string)

(Example return):

{ userId: USERID, username: 'USERNAME', buildersClubMembershipType: 'TYPE' }

Back to Top


getRankInGroup

group, userId

Gets rank of user with userId in group and caches according to settings.

Arguments

  • group (number)
  • userId (number)

Returns

(Promise)

  • rank (number)

Back to Top


getRankNameInGroup

group, userId

Gets the rank name of user with userId in group and caches according to settings.

Arguments

  • group (number)
  • userId (number)

Returns

(Promise)

  • name (string)

Back to Top


getRole

group/roles, rank/name/id

Returns role information of rank rank, which can be a single rank or an array of ranks. The roles object can be passed in directly from the getRoles function or the group id can be given to retrieve it automatically. If an array of ranks is inputted a parallel array of roles is returned. Alternatively, the name name of the role can be searched for, this should be used if there are "ambiguous roles" that have the same rank. If ambiguous roles cannot be resolved an error will be thrown. The actual roleset id may be used as well.

Arguments

  • roles (Object)
  • either rank (number/Array)
  • or name (string/Array)
  • or id (number/Array)

Returns

(Promise)

  • role (Object)
    • ID (number)
    • Name (string)
    • Rank (number)

Back to Top


getRoles

group

Returns role information of a group with groupId group in the form [{"ID":number,"name":"string","rank":number},{"ID":number,"name":"string","rank":number}].

Arguments

  • group (number)

Returns

(Promise)

  • roles (Object)
    • ID (number)
    • name (string)
    • rank (number)

Back to Top


getRolesetInGroupWithJar

group[, jar]

Gets the roleset of the logged in user in group.

Arguments

  • group (number)
  • optional jar (CookieJar)

Returns

(Promise)

  • rolesetId (number)

Back to Top


getShout

group[, jar]

Gets the current shout in group. If there is no shout the promise is fulfilled but nothing is returned.

Arguments

  • group (number)
  • optional jar (CookieJar)

Returns

(Promise)

  • shout (Object)
    • body (string)
    • poster (Object)
      • userId (number)
      • username (string)
      • buildersClubMembershipType (string)
    • created (string)
    • updated (string)

Back to Top


getWall

group[, page, stream, view, jar]

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)

Back to Top


getWallPost

group, id[, page, view, jar]

Gets the post with id. If view is true view information will be returned, which can be used to do actions on the post. If page is known it can be given to speed up the request, otherwise it will be found automatically using a binary search.

Arguments

  • group (number)
  • optional id (number)
  • optional page (number)
  • optional jar (CookieJar)

Returns

(Promise)

  • post (Object)
    • content (string)
    • author (Object)
      • id (number)
      • name (string)
    • date (Date)
    • id (number)
    • parent (Object)
      • page (number)
      • index (number)
    • view (Object)
  • totalPages (number)

Back to Top


onJoinRequestHandle

group[, jar]

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:

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)

Back to Top


onShout

group[, jar]

Fires when there is a shout in the group with groupId group. If the shout was cleared the shout body will be blank.

Arguments

  • group (number)
  • message (string)
  • optional jar (CookieJar)

Returns

(EventEmitter)

  • data
    • shout (Object)
      • body (string)
      • poster (Object)
        • userId (number)
        • username (string)
        • buildersClubMembershipType (string)
      • created (string)
      • updated (string)

Example

To get a shout update on a group and log it to console:

let GroupID = 123456;

rbx.cookieLogin(cookie).then((success) => { // Required if the group's shout is private

    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));

Back to Top


onWallPost

group[, view, jar]

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.

Arguments

  • group (number)
  • optional jar (CookieJar)

Returns

(EventEmitter)

  • data
    • post (Object)
      • content (String)
      • author (Object)
        • id (number)
        • name (String)
      • date (Date)
      • id (number)
      • view (Object)
        • __VIEWSTATE (string)
        • __VIEWSTATEGENERATOR (string)
        • __EVENTVALIDATION (string)
        • __RequestVerificationToken (string)

Back to Top


This wiki is currently outdated. It will be kept for reference purposes. It is highly recommended you visit https://noblox.js.org instead to see the latest documentation.

Clone this wiki locally