Skip to content

Forum Functions

Samuel Rapana Betio edited this page Aug 10, 2017 · 1 revision

Forum Functions - roblox-js Wiki


forumPost

forumId/postId, body[, subject, locked, jar]

Creates a new forum thread with subject and body in the subforum with forumId. Alternatively, reply to an existing post by providing postId instead. If locked is true, replies will be disabled (this technically works with both new threads and replies, but the latter obviously won't make a difference). Note that subject is required when making a new post but is optional when replying. To find forumId go to the subforum you want in a browser and check the end of the URL.

Arguments

  • either forumId (number)
  • or postId (number)
  • body (string)
  • optional subject (string)
  • optional locked (boolean)
    • default false
  • optional jar (CookieJar)

Returns

(Promise)

  • postId (number)

Back to Top


getForum

forumId[, jar]

Gets post information on the first page of the subforum with forumId.

Note that you must be logged in or supply a jar if you want up-to-date information and correct dates. This is because when you are not logged in the forum page will be cached by ROBLOX server-side and they will often return to you outdated information as well as dates which are not in your time zone.

Arguments

  • forumId (number)
  • optional jar (CookieJar)

Returns

(Promise)

  • posts (Array)
    • post (Object)
      • id (number)
      • subject (string)
      • author (Object)
        • id (number)
        • name (string)
      • status (string)
        • The name of the icon ROBLOX gives to the post, indicating whether it is a popular post, whether it has been read, whether it has been locked, etc.
      • replies (number)
      • views (number)
      • pinned (boolean)
        • True if the post is pinned.
      • locked (boolean)
        • True if the post is locked. However, if it is false it is not guaranteed that the post is unlocked.
      • lastPost (Object)
        • Information about the most recent post made to the thread, including the thread itself.
        • author (string)
        • id (number)
        • date (Date)
      • totalPages (number)

Back to Top


getForumPost

postId[, page]

Gets replies to forum post with id postId. If page is specified it will only get posts from that specific page number or, if it is an array, all the posts from pages in the array, otherwise it will get all posts from all pages of the thread. If page is negative you can get the trailing pages of the forum post. For example, if a forum post has 10 pages total and you put -1 in page, only the posts from page 10 are returned. If you put -2, if would return page 9. You can put negative numbers in an array as well, sending [-1, -2] will return replies on both page 9 and page 10 (this is all to make it easier to read the latest replies on a post). Note that if there is an invalid page in an array of pages no error will occur but that page simply won't be collected.

If the post is actually a reply to a thread and not a thread itself, the function will automatically resolve the parent thread and then search for that specific post in the thread, returning only the reply. Using a page number when calling with a reply may result in unexpected behavior. Note that if the reply happens to be on the first page the function will not know the true total number of pages and replace it with -1.

The getStatus function is returned as a property of the promise and returns a very rough estimate of the percent completion.

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

rbx.getForumPost(201983178).then(function (thread) {
  console.log(thread.posts[thread.posts.length - 1]);
})

Arguments

  • postId (number)
  • optional page (number/Array)

Returns

(Promise)

  • thread (Object)
    • posts (Array)
      • reply (Object)
        • author (Object)
          • id (number)
          • name (string)
          • online (boolean)
          • tag (string)
            • The user's image tag. For example if they are a moderator it will be "Forum Moderator" and if they have a top 100 poster image it will be "Top 100 Poster". If there is none it will be null
          • joinDate (Date)
          • postCount (number)
        • postId (number)
        • date (Date)
        • content (string)
        • parent (Object)
          • The id of the thread and well as the page the post was on (useful if the post itself was not a thread)
          • id (number)
          • page (number)
    • totalPages (number)
    • subject (string)
    • resolved (number)
      • NOTE: Will only be present if the post was a reply

Back to Top


onForumPost

forumId[, includeReplies, jar]

This fires with new forum posts made in the subforum with the specified forumId. If includeReplies is enabled it will fire for replies to existing forum posts as well, otherwise it will only fire when a new thread is created. Note that when includeReplies is enabled and the post is a reply there will be limited information about the post and isReply will be true, although the parent thread information will be available in parent.

A user must be logged in in order to supply accurate information. This is because if the user is not logged in ROBLOX will cache forums server-side and return times that are not in the user's local time.

Arguments

  • forumId (number)
  • optional includeReplies (boolean)
  • optional jar (CookieJar)

Returns

(EventEmitter)

  • data If the post is not a reply
    • post (Object)
      • id (number)
      • subject (string)
      • author (Object)
        • id (number)
        • name (string)
      • status (string)
      • replies (number)
      • views (number)
      • pinned (boolean)
      • locked (boolean)
      • isReply
        • false
      • lastPost (Object)
        • author (string)
        • id (number)
        • date (Date) If the post is a reply
    • post (Object)
      • author (string)
      • id (number)
      • date (Date)
      • isReply
        • true
      • parent
        • id (number)
        • subject (string)
        • author (Object)
          • id (number)
          • name (string)
        • status (string)
        • replies (number)
        • views (number)
        • pinned (boolean)
        • locked (boolean)

Back to Top


onForumReply

postId

Fires when new posts are made onto the forum post with post ID postId.

Arguments

  • postId (number)

Returns

(EventEmitter)

  • data
    • reply (Object)
      • author (Object)
        • id (number)
        • name (string)
        • joinDate (Date)
        • online (boolean)
        • tag (string)
        • postCount (number)
      • postId (number)
      • date (Date)
      • content (string)
      • parent (Object)
        • id (number)
        • page (number)
        • subject (string)

Back to Top


Clone this wiki locally