Skip to content

User Functions

lordhammyrblx edited this page Feb 7, 2019 · 1 revision

User Functions - noblox.js Wiki


acceptFriendRequest

userId[, jar]

Accepts friend requests from userId.

Arguments

  • userId (number)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


block

userId[, jar]

Blocks the user with userId.

Arguments

  • userId (number)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


declineFriendRequest

userId[, jar]

Declines friend requests from userId.

Arguments

  • userId (number)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


follow

userId[, jar]

Follows the user with userId.

Arguments

  • userId (number)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


login

username, password[, jar]

Logs into username with password and stores their cookie in jar.

Arguments

  • username (string)
  • password (string)
  • optional jar (CookieJar)

Returns

(Promise)

  • userInfo (Object)
    • userId (number)

Back to Top


message

recipient, subject, message[, jar]

Sends a message with body and subject to the user with id recipient.

Arguments

  • recipient (number)
  • subject (string)
  • body (string)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


removeFriend

userId[, jar]

Removes friends with userId.

Arguments

  • userId (number)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


sendFriendRequest

userId[, jar]

Sends a friend request to userId.

Arguments

  • userId (number)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


unblock

userId[, jar]

Unblocks the user with userId.

Arguments

  • userId (number)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


unfollow

userId[, jar]

Unfollows the user with userId.

Arguments

  • userId (number)
  • optional jar (CookieJar)

Returns

(Promise)

Back to Top


getBlurb

userId

Gets the blurb of the user with the ID userId.

Arguments

  • userId (number)

Returns

(Promise)

  • blurb (string)

Back to Top


getFriends

userId, type[, page, limit, jar]

Gets the friend list of userId where type is AllFriends, Following, Followers, or FriendRequests. The page parameter can be a number or array of numbers specifying what pages to get. Note that pages are in groups of 200 friends. If you need to be more precise use limit. As usual page can be negative to specify trailing pages. If limit is specified a maximum of that many friends are retrieved.

You do not have to be logged in to get friends however if you want to get friend requests you have to and if you want to see what games your friends are in you may have to be logged in as the permission is often limited to friends.

Friends are returned in the order they appear on the normal list.

Arguments

  • userId (number)
  • type (string)
  • optional page (number/Array)
  • optional limit (number)
  • optional jar (CookieJar)

Returns

(Promise)

  • list (Object)
    • friends (Array)
      • friend (Object)
        • user (Object)
          • id (number)
          • name (string)
        • avatar (Object)
          • url (string)
          • final (boolean)
            • Whether or not this is the final avatar. This will be false if it is moderated or is still loading.
        • status (Object)
          • online (boolean)
          • lastSeen (Date)
        • parent (Object)
          • page (number)
          • index (number)
          • fullIndex (number)
        • inGame (boolean)
        • inStudio (boolean)
        • following (boolean)
        • deleted (boolean)
    • totalPages (number)
    • total (number)

Back to Top


getIdFromUsername

username

Gets the id of user with username and caches according to settings.

Arguments

  • username (string)

Returns

(Promise)

  • id (number)

Back to Top


getMessages

[page, limit, tab, jar]

Gets messages in the inbox of player with jar. If page does not exist the entire inbox will be indexed, otherwise it will only do the specific page or a specific number of pages in an array. Similar to getForumPost, negative numbers can be used to get pages of the inbox starting from the end. Note that even though ROBLOX internally begins pages at 0, if you pass a page into this function it will automatically be adjusted. So the first page of the inbox is page 1 and not page 0.

If limit is defined that is the maximum number of messages that will be returned. Regardless of how many pages are specified, the function will automatically cut down request sizes to meet it. For example, if you do not specify a page number but enter in a limit of 30, the function will only get the first page and half of the second page (each page has 20 messages).

The tab option specifies which part of messages to index where 0 is the inbox, 1 is sent messages, and 3 is archived messages.

An object is returned with the thread's posts in the posts array, they are in order from newest to oldest. For example, to get your latest message:

rbx.getMessages(1, 1).then(function (inbox) {
  console.log(inbox.messages[0]);
});

Arguments

  • optional page (number/Array)
  • optional limit (number)
  • optional tab (number)
  • optional jar (CookieJar)

Returns

(Promise)

  • inbox (Object)
    • messages (Array)
      • message (Object)
        • sender (Object)
          • userId (number)
          • name (string)
        • subject (string)
        • body (string)
        • created (Date)
        • updated (Date)
        • read (boolean)
        • parent (Object)
          • page (number)
        • id (number)
    • totalPages (number)
    • total (number)

Back to Top


getStatus

userId

Gets the status message of the user with the ID userId.

Arguments

  • userId (number)

Returns

(Promise)

  • status (string)

Back to Top


getUsernameFromId

id

Gets username of user with id and caches according to settings.

Arguments

  • id (number)

Returns

(Promise)

  • username (string)

Back to Top


onFriendRequest

[jar]

Fires when new friend requests are received.

Arguments

  • optional jar (CookieJar)

Returns

(EventEmitter)

  • data
    • userId (number)

Back to Top


onMessage

[jar]

Fires whenever a new message is received. Because it relies on onNotification, the logged in user's notification stream for messages must be enabled; however, it is one of the true events and does not rely on short polling.

Arguments

  • optional jar (CookieJar)

Returns

(EventEmitter)

  • data
    • message (Object)
      • sender (Object)
        • userId (number)
        • name (string)
      • subject (string)
      • body (string)
      • created (Date)
      • updated (Date)
      • read (boolean)
      • parent (Object)
        • page (number)
      • id (number)

Back to Top


onNotification

[jar]

This is one of the only true streams, using web sockets to connect to ROBLOX's notification system. The logged in user must have relevant notifications enabled in their settings in order to receive notifications through this (of course). All notifications haven't been mapped out but what is known is that they all have a name and message (separate arguments to the data event), where message is an object that includes a field type.

For example, a new message notification would be detected as so:

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

Arguments

  • optional jar (CookieJar)

Returns

(EventEmitter)

  • data
    • name (String)
    • message (Object)
      • type (String)

Back to Top