noblox-asset.js 7.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
  2. package/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
  3. package/.github/workflows/doc-publish.yml +33 -0
  4. package/.github/workflows/npmpublish.yml +72 -0
  5. package/.github/workflows/run-tests.yml +49 -0
  6. package/CODE_OF_CONDUCT.md +76 -0
  7. package/LICENSE +21 -0
  8. package/README.md +182 -0
  9. package/eslint.config.mjs +34 -0
  10. package/examples/cleanPlayers.js +130 -0
  11. package/examples/cleanWall.js +110 -0
  12. package/examples/revertRanks.js +100 -0
  13. package/examples/savePlayers.js +119 -0
  14. package/examples/saveWall.js +96 -0
  15. package/img/moderatedThumbnails/moderatedThumbnail_100x100.png +0 -0
  16. package/img/moderatedThumbnails/moderatedThumbnail_110x110.png +0 -0
  17. package/img/moderatedThumbnails/moderatedThumbnail_140x140.png +0 -0
  18. package/img/moderatedThumbnails/moderatedThumbnail_150x150.png +0 -0
  19. package/img/moderatedThumbnails/moderatedThumbnail_150x200.png +0 -0
  20. package/img/moderatedThumbnails/moderatedThumbnail_180x180.png +0 -0
  21. package/img/moderatedThumbnails/moderatedThumbnail_250x250.png +0 -0
  22. package/img/moderatedThumbnails/moderatedThumbnail_30x30.png +0 -0
  23. package/img/moderatedThumbnails/moderatedThumbnail_352x352.png +0 -0
  24. package/img/moderatedThumbnails/moderatedThumbnail_420x420.png +0 -0
  25. package/img/moderatedThumbnails/moderatedThumbnail_48x48.png +0 -0
  26. package/img/moderatedThumbnails/moderatedThumbnail_50x50.png +0 -0
  27. package/img/moderatedThumbnails/moderatedThumbnail_60x60.png +0 -0
  28. package/img/moderatedThumbnails/moderatedThumbnail_720x720.png +0 -0
  29. package/img/moderatedThumbnails/moderatedThumbnail_75x75.png +0 -0
  30. package/img/noblox-js-small.png +0 -0
  31. package/img/noblox-js.png +0 -0
  32. package/img/thumbnailSizes.png +0 -0
  33. package/jsDocsConfig.json +55 -0
  34. package/lib/accountinformation/getUserSocialLinks.js +40 -0
  35. package/lib/accountsettings/block.js +53 -0
  36. package/lib/accountsettings/unblock.js +53 -0
  37. package/lib/asset/deleteFromInventory.js +56 -0
  38. package/lib/asset/getGamePassProductInfo.js +50 -0
  39. package/lib/asset/getProductInfo.js +46 -0
  40. package/lib/asset/uploadAnimation.js +103 -0
  41. package/lib/asset/uploadItem.js +83 -0
  42. package/lib/asset/uploadModel.js +90 -0
  43. package/lib/avatar/avatarRules.js +39 -0
  44. package/lib/avatar/currentlyWearing.js +33 -0
  45. package/lib/avatar/getAvatar.js +36 -0
  46. package/lib/avatar/getCurrentAvatar.js +38 -0
  47. package/lib/avatar/getRecentItems.js +36 -0
  48. package/lib/avatar/outfitDetails.js +33 -0
  49. package/lib/avatar/outfits.js +38 -0
  50. package/lib/avatar/redrawAvatar.js +47 -0
  51. package/lib/avatar/removeAssetId.js +51 -0
  52. package/lib/avatar/setAvatarBodyColors.js +61 -0
  53. package/lib/avatar/setAvatarScales.js +61 -0
  54. package/lib/avatar/setPlayerAvatarType.js +51 -0
  55. package/lib/avatar/setWearingAssets.js +51 -0
  56. package/lib/avatar/wearAssetId.js +51 -0
  57. package/lib/badges/getAwardedTimestamps.js +49 -0
  58. package/lib/badges/getBadgeInfo.js +44 -0
  59. package/lib/badges/getGameBadges.js +63 -0
  60. package/lib/badges/getPlayerBadges.js +28 -0
  61. package/lib/badges/updateBadgeInfo.js +75 -0
  62. package/lib/cache/add.js +14 -0
  63. package/lib/cache/addIf.js +26 -0
  64. package/lib/cache/clear.js +8 -0
  65. package/lib/cache/get.js +28 -0
  66. package/lib/cache/index.js +17 -0
  67. package/lib/cache/new.js +12 -0
  68. package/lib/cache/wrap.js +25 -0
  69. package/lib/chat/addUsersToConversation.js +58 -0
  70. package/lib/chat/chatSettings.js +34 -0
  71. package/lib/chat/getChatMessages.js +41 -0
  72. package/lib/chat/getConversations.js +44 -0
  73. package/lib/chat/getRolloutSettings.js +36 -0
  74. package/lib/chat/getUnreadConversationCount.js +34 -0
  75. package/lib/chat/getUnreadMessages.js +39 -0
  76. package/lib/chat/getUserConversations.js +38 -0
  77. package/lib/chat/markChatAsRead.js +53 -0
  78. package/lib/chat/markChatAsSeen.js +51 -0
  79. package/lib/chat/multiGetLatestMessages.js +38 -0
  80. package/lib/chat/onNewConversation.js +50 -0
  81. package/lib/chat/onNewMessage.js +53 -0
  82. package/lib/chat/onNewMessageBySelf.js +50 -0
  83. package/lib/chat/onUserOnline.js +50 -0
  84. package/lib/chat/onUserTyping.js +54 -0
  85. package/lib/chat/removeFromGroupConversation.js +59 -0
  86. package/lib/chat/renameGroupConversation.js +58 -0
  87. package/lib/chat/sendChatMessage.js +58 -0
  88. package/lib/chat/setChatUserTyping.js +58 -0
  89. package/lib/chat/start121Conversation.js +51 -0
  90. package/lib/chat/startCloudEditConversation.js +51 -0
  91. package/lib/chat/startGroupConversation.js +59 -0
  92. package/lib/client/onNotification.js +86 -0
  93. package/lib/client/setAPIKey.js +18 -0
  94. package/lib/client/setCookie.js +38 -0
  95. package/lib/datastores/deleteDatastoreEntry.js +56 -0
  96. package/lib/datastores/getDatastoreEntry.js +88 -0
  97. package/lib/datastores/getDatastoreEntryVersions.js +73 -0
  98. package/lib/datastores/getDatastoreKeys.js +63 -0
  99. package/lib/datastores/getDatastores.js +62 -0
  100. package/lib/datastores/incrementDatastoreEntry.js +83 -0
  101. package/lib/datastores/setDatastoreEntry.js +80 -0
  102. package/lib/develop/canManage.js +42 -0
  103. package/lib/develop/configureItem.js +210 -0
  104. package/lib/develop/updateUniverse.js +52 -0
  105. package/lib/develop/updateUniverseAccess.js +54 -0
  106. package/lib/economy/getGroupFunds.js +42 -0
  107. package/lib/economy/getGroupPayoutEligibility.js +55 -0
  108. package/lib/economy/getGroupRevenueSummary.js +42 -0
  109. package/lib/economy/getGroupTransactions.js +32 -0
  110. package/lib/economy/getResaleData.js +48 -0
  111. package/lib/economy/getResellers.js +35 -0
  112. package/lib/economy/getUserFunds.js +43 -0
  113. package/lib/economy/getUserTransactions.js +34 -0
  114. package/lib/economy/onGroupTransaction.js +74 -0
  115. package/lib/friends/acceptFriendRequest.js +54 -0
  116. package/lib/friends/declineAllFriendRequests.js +52 -0
  117. package/lib/friends/declineFriendRequest.js +54 -0
  118. package/lib/friends/getFollowerCount.js +35 -0
  119. package/lib/friends/getFollowers.js +56 -0
  120. package/lib/friends/getFollowingCount.js +35 -0
  121. package/lib/friends/getFollowings.js +56 -0
  122. package/lib/friends/getFriendCount.js +35 -0
  123. package/lib/friends/getFriendRequests.js +51 -0
  124. package/lib/friends/getFriends.js +48 -0
  125. package/lib/friends/onFriendRequest.js +58 -0
  126. package/lib/friends/removeFriend.js +53 -0
  127. package/lib/friends/sendFriendRequest.js +54 -0
  128. package/lib/friends/unfollow.js +53 -0
  129. package/lib/games/addDeveloperProduct.js +53 -0
  130. package/lib/games/configureGamePass.js +126 -0
  131. package/lib/games/getDeveloperProducts.js +44 -0
  132. package/lib/games/getGameInstances.js +31 -0
  133. package/lib/games/getGamePasses.js +39 -0
  134. package/lib/games/getGameRevenue.js +48 -0
  135. package/lib/games/getGameSocialLinks.js +42 -0
  136. package/lib/games/getGroupGames.js +30 -0
  137. package/lib/games/getPlaceInfo.js +47 -0
  138. package/lib/games/getUniverseInfo.js +50 -0
  139. package/lib/games/publishToTopic.js +52 -0
  140. package/lib/games/sendUserNotification.js +65 -0
  141. package/lib/games/updateDeveloperProduct.js +56 -0
  142. package/lib/groups/banFromGroup.js +47 -0
  143. package/lib/groups/changeRank.js +59 -0
  144. package/lib/groups/deleteWallPost.js +59 -0
  145. package/lib/groups/deleteWallPostsByUser.js +55 -0
  146. package/lib/groups/demote.js +25 -0
  147. package/lib/groups/exile.js +55 -0
  148. package/lib/groups/getAuditLog.js +64 -0
  149. package/lib/groups/getGroup.js +50 -0
  150. package/lib/groups/getGroupBans.js +37 -0
  151. package/lib/groups/getGroupSocialLinks.js +41 -0
  152. package/lib/groups/getGroups.js +82 -0
  153. package/lib/groups/getJoinRequest.js +47 -0
  154. package/lib/groups/getJoinRequests.js +53 -0
  155. package/lib/groups/getPlayers.js +103 -0
  156. package/lib/groups/getRankInGroup.js +45 -0
  157. package/lib/groups/getRankNameInGroup.js +44 -0
  158. package/lib/groups/getRole.js +64 -0
  159. package/lib/groups/getRolePermissions.js +48 -0
  160. package/lib/groups/getRoles.js +53 -0
  161. package/lib/groups/getShout.js +47 -0
  162. package/lib/groups/getWall.js +56 -0
  163. package/lib/groups/groupPayout.js +103 -0
  164. package/lib/groups/handleJoinRequest.js +57 -0
  165. package/lib/groups/handleJoinRequests.js +61 -0
  166. package/lib/groups/leaveGroup.js +56 -0
  167. package/lib/groups/onAuditLog.js +62 -0
  168. package/lib/groups/onJoinRequest.js +63 -0
  169. package/lib/groups/onJoinRequestHandle.js +105 -0
  170. package/lib/groups/onShout.js +57 -0
  171. package/lib/groups/onWallPost.js +58 -0
  172. package/lib/groups/promote.js +25 -0
  173. package/lib/groups/searchGroups.js +32 -0
  174. package/lib/groups/setGroupDescription.js +58 -0
  175. package/lib/groups/setGroupName.js +59 -0
  176. package/lib/groups/setRank.js +74 -0
  177. package/lib/groups/setRoleInfo.js +84 -0
  178. package/lib/groups/shout.js +58 -0
  179. package/lib/groups/unbanFromGroup.js +41 -0
  180. package/lib/index.js +212 -0
  181. package/lib/internal/levelOneCopy.js +16 -0
  182. package/lib/internal/queue.js +61 -0
  183. package/lib/internal/timeout.js +30 -0
  184. package/lib/internal/wrap.js +78 -0
  185. package/lib/inventory/getCollectibles.js +31 -0
  186. package/lib/inventory/getInventory.js +32 -0
  187. package/lib/inventory/getInventoryById.js +31 -0
  188. package/lib/inventory/getOwnership.js +47 -0
  189. package/lib/inventory/getUAIDs.js +47 -0
  190. package/lib/itemconfiguration/getGroupAssets.js +32 -0
  191. package/lib/options.js +26 -0
  192. package/lib/party/onPartyDeleted.js +53 -0
  193. package/lib/party/onPartyInvite.js +53 -0
  194. package/lib/party/onPartyJoinedGame.js +53 -0
  195. package/lib/party/onPartyLeftGame.js +53 -0
  196. package/lib/party/onPartySelfJoined.js +53 -0
  197. package/lib/party/onPartySelfLeft.js +53 -0
  198. package/lib/party/onPartyUserJoined.js +53 -0
  199. package/lib/party/onPartyUserLeft.js +53 -0
  200. package/lib/premiumfeatures/getPremium.js +46 -0
  201. package/lib/presence/getPresences.js +60 -0
  202. package/lib/privatemessages/getMessages.js +55 -0
  203. package/lib/privatemessages/message.js +75 -0
  204. package/lib/privatemessages/onMessage.js +89 -0
  205. package/lib/thumbnails/getLogo.js +56 -0
  206. package/lib/thumbnails/getPlayerThumbnail.js +120 -0
  207. package/lib/thumbnails/getThumbnails.js +92 -0
  208. package/lib/trades/acceptTrade.js +52 -0
  209. package/lib/trades/canTradeWith.js +43 -0
  210. package/lib/trades/counterTrade.js +78 -0
  211. package/lib/trades/declineTrade.js +52 -0
  212. package/lib/trades/getTradeInfo.js +47 -0
  213. package/lib/trades/getTrades.js +37 -0
  214. package/lib/trades/sendTrade.js +76 -0
  215. package/lib/users/getBlurb.js +37 -0
  216. package/lib/users/getIdFromUsername.js +56 -0
  217. package/lib/users/getPlayerInfo.js +128 -0
  218. package/lib/users/getUserInfo.js +35 -0
  219. package/lib/users/getUsernameFromId.js +45 -0
  220. package/lib/users/getUsernameHistory.js +42 -0
  221. package/lib/users/onBlurbChange.js +46 -0
  222. package/lib/users/searchUsers.js +41 -0
  223. package/lib/util/apiError.js +50 -0
  224. package/lib/util/clearSession.js +32 -0
  225. package/lib/util/generalRequest.js +61 -0
  226. package/lib/util/getAction.js +45 -0
  227. package/lib/util/getAuthenticatedUser.js +41 -0
  228. package/lib/util/getCurrentUser.js +58 -0
  229. package/lib/util/getGeneralToken.js +52 -0
  230. package/lib/util/getHash.js +29 -0
  231. package/lib/util/getInputs.js +37 -0
  232. package/lib/util/getPageResults.js +86 -0
  233. package/lib/util/getSenderUserId.js +30 -0
  234. package/lib/util/getSession.js +38 -0
  235. package/lib/util/getVerification.js +60 -0
  236. package/lib/util/getVerificationInputs.js +31 -0
  237. package/lib/util/http.js +138 -0
  238. package/lib/util/jar.js +25 -0
  239. package/lib/util/refreshCookie.js +52 -0
  240. package/lib/util/relog.js +81 -0
  241. package/lib/util/setOptions.js +54 -0
  242. package/lib/util/shortPoll.js +102 -0
  243. package/package.json +76 -0
  244. package/postinstall.mjs +1 -0
  245. package/settings.json +115 -0
  246. package/test/accountinformation.test.js +27 -0
  247. package/test/accountsettings.test.js +27 -0
  248. package/test/asset.test.js +81 -0
  249. package/test/assets/Great-White-Shark-Fin.rbxm +0 -0
  250. package/test/assets/KeyframeSequence.rbxm +0 -0
  251. package/test/avatar.test.js +164 -0
  252. package/test/badges.test.js +96 -0
  253. package/test/chat.test.js +104 -0
  254. package/test/datastore.test.js +105 -0
  255. package/test/develop.test.js +53 -0
  256. package/test/economy.test.js +143 -0
  257. package/test/friends.test.js +146 -0
  258. package/test/games.test.js +229 -0
  259. package/test/groups.test.js +405 -0
  260. package/test/inventory.test.js +98 -0
  261. package/test/itemconfiguration.test.js +24 -0
  262. package/test/premiumfeatures.test.js +17 -0
  263. package/test/presence.test.js +25 -0
  264. package/test/privatemessages.test.js +33 -0
  265. package/test/thumbnails.test.js +53 -0
  266. package/test/users.test.js +110 -0
  267. package/tutorials/Authentication.md +75 -0
  268. package/tutorials/Event Emitters.md +26 -0
  269. package/tutorials/Promises.md +86 -0
  270. package/tutorials/VPS Authentication.md +72 -0
  271. package/typings/index.d.ts +2639 -0
  272. package/typings/jsDocs.ts +1987 -0
@@ -0,0 +1,54 @@
1
+ // Includes
2
+ const http = require('../util/http.js').func
3
+ const getGeneralToken = require('../util/getGeneralToken.js').func
4
+ const RobloxAPIError = require('../util/apiError.js')
5
+
6
+ // Args
7
+ exports.required = ['userId']
8
+ exports.optional = ['jar']
9
+
10
+ // Docs
11
+ /**
12
+ * 🔐 Send a friend request to a user.
13
+ * @category User
14
+ * @alias sendFriendRequest
15
+ * @param {number} userId - The id of the user.
16
+ * @returns {Promise<void>}
17
+ * @example const noblox = require("noblox.js")
18
+ * // Login using your cookie
19
+ * noblox.sendFriendRequest(123456)
20
+ **/
21
+
22
+ // Define
23
+ function sendFriendRequest (jar, token, userId) {
24
+ return new Promise((resolve, reject) => {
25
+ const httpOpt = {
26
+ url: `//friends.roblox.com/v1/users/${userId}/request-friendship`,
27
+ options: {
28
+ method: 'POST',
29
+ jar,
30
+ headers: {
31
+ 'X-CSRF-TOKEN': token,
32
+ 'Content-Type': 'application/json'
33
+ },
34
+ resolveWithFullResponse: true
35
+ }
36
+ }
37
+ return http(httpOpt)
38
+ .then(function (res) {
39
+ if (res.statusCode === 200) {
40
+ resolve()
41
+ } else {
42
+ reject(new RobloxAPIError(res))
43
+ }
44
+ })
45
+ })
46
+ }
47
+
48
+ exports.func = function (args) {
49
+ const jar = args.jar
50
+ return getGeneralToken({ jar })
51
+ .then(function (xcsrf) {
52
+ return sendFriendRequest(jar, xcsrf, args.userId)
53
+ })
54
+ }
@@ -0,0 +1,53 @@
1
+ // Includes
2
+ const http = require('../util/http.js').func
3
+ const getGeneralToken = require('../util/getGeneralToken.js').func
4
+ const RobloxAPIError = require('../util/apiError.js')
5
+
6
+ // Args
7
+ exports.required = ['userId']
8
+ exports.optional = ['jar']
9
+
10
+ // Docs
11
+ /**
12
+ * 🔐 Unfollow a user.
13
+ * @category User
14
+ * @alias unfollow
15
+ * @param {number} userId - The id of the user.
16
+ * @returns {Promise<void>}
17
+ * @example const noblox = require("noblox.js")
18
+ * // Login using your cookie
19
+ * noblox.unfollow(123456)
20
+ **/
21
+
22
+ // Define
23
+ function unfollow (jar, token, userId) {
24
+ return new Promise((resolve, reject) => {
25
+ const httpOpt = {
26
+ url: `//friends.roblox.com/v1/users/${userId}/unfollow`,
27
+ options: {
28
+ method: 'POST',
29
+ jar,
30
+ headers: {
31
+ 'X-CSRF-TOKEN': token
32
+ },
33
+ resolveWithFullResponse: true
34
+ }
35
+ }
36
+ return http(httpOpt)
37
+ .then(function (res) {
38
+ if (res.statusCode === 200) {
39
+ resolve()
40
+ } else {
41
+ reject(new RobloxAPIError(res))
42
+ }
43
+ })
44
+ })
45
+ }
46
+
47
+ exports.func = function (args) {
48
+ const jar = args.jar
49
+ return getGeneralToken({ jar })
50
+ .then(function (xcsrf) {
51
+ return unfollow(jar, xcsrf, args.userId)
52
+ })
53
+ }
@@ -0,0 +1,53 @@
1
+ const http = require('../util/http.js').func
2
+ const getGeneralToken = require('../util/getGeneralToken.js').func
3
+ const RobloxAPIError = require('../util/apiError.js')
4
+
5
+ exports.required = ['universeId', 'name', 'priceInRobux']
6
+ exports.optional = ['description', 'jar']
7
+
8
+ // Docs
9
+ /**
10
+ * 🔐 Create a developer product.
11
+ * @category Game
12
+ * @alias addDeveloperProduct
13
+ * @param {number} universeId - The id of the universe.
14
+ * @param {string} name - The name of the developer product.
15
+ * @param {number} priceInRobux - The price of the product.
16
+ * @param {string=} description - The description of the developer product.
17
+ * @returns {Promise<DeveloperProductAddResult>}
18
+ * @example const noblox = require("noblox.js")
19
+ * // Login using your cookie
20
+ * noblox.addDeveloperProduct(1, "A Developer Product", 100, "A cool item.")
21
+ **/
22
+
23
+ const nextFunction = (jar, token, universeId, name, priceInRobux, description) => {
24
+ description = description || ''
25
+ return http({
26
+ url: '//apis.roblox.com/developer-products/v1/universes/' + universeId + '/developerproducts?name=' + name + '&description=' + description + '&priceInRobux=' + priceInRobux,
27
+ options: {
28
+ method: 'POST',
29
+ jar,
30
+ headers: {
31
+ 'X-CSRF-TOKEN': token
32
+ },
33
+ resolveWithFullResponse: true
34
+ }
35
+ }).then(function (res) {
36
+ if (res.statusCode !== 200) {
37
+ throw new RobloxAPIError(res)
38
+ }
39
+ try {
40
+ return JSON.parse(res.body)
41
+ } catch (_) {
42
+ throw new Error('Failed to parse response body (not valid JSON)')
43
+ }
44
+ })
45
+ }
46
+
47
+ exports.func = (args) => {
48
+ const jar = args.jar
49
+
50
+ return getGeneralToken({ jar }).then((xcsrf) => {
51
+ return nextFunction(jar, xcsrf, args.universeId, args.name, args.priceInRobux, args.description)
52
+ })
53
+ }
@@ -0,0 +1,126 @@
1
+ // Includes
2
+ const http = require('../util/http').func
3
+ const getGeneralToken = require('../util/getGeneralToken').func
4
+ const RobloxAPIError = require('../util/apiError')
5
+
6
+ // Args
7
+ exports.required = ['gamePassId', 'name']
8
+ exports.optional = ['description', 'price', 'icon', 'jar']
9
+
10
+ // Docs
11
+ /**
12
+ * 🔐 Modifies an existing game pass.
13
+ * @category Game
14
+ * @alias configureGamePass
15
+ * @param {number} gamePassId - The id of the game pass.
16
+ * @param {string} name - The name of the game pass; skips name, description, and icon if set to "".
17
+ * @param {string=} description - The description of the game pass; description is updated when name is modified.
18
+ * @param {number|boolean=} price - The price of the game pass in Robux; sets to 'Off Sale' if 0, false, or a negative value; skips if true.
19
+ * @param {ReadStream=} icon - The read stream for the game pass icon being uploaded; .png, .jpg, .gif
20
+ * @returns {Promise<GamePassResponse>}
21
+ * @example const noblox = require("noblox.js")
22
+ * const fs = require("fs")
23
+ * // Login using your cookie
24
+ * noblox.configureGamePass(12345678, "Game Pass Title", "Game Pass Description", 1234, fs.createReadStream("./Image.png"))
25
+ **/
26
+
27
+ // Define
28
+ function configureGamePass (gamePassId, name, description, price, icon, jar, token) {
29
+ return new Promise((resolve, reject) => {
30
+ const httpOpt = {
31
+ url: `//apis.roblox.com/game-passes/v1/game-passes/${gamePassId}/details`,
32
+ options: {
33
+ method: 'POST',
34
+ jar,
35
+ headers: {
36
+ 'X-CSRF-TOKEN': token
37
+ },
38
+ resolveWithFullResponse: true,
39
+ formData: {
40
+ Name: name,
41
+ Description: description,
42
+ File: icon
43
+ }
44
+ }
45
+ }
46
+
47
+ // Skip updating name and description if name is empty.
48
+ if (!name) {
49
+ resolve({
50
+ gamePassId,
51
+ ...price
52
+ })
53
+ }
54
+
55
+ return http(httpOpt).then(function (res) {
56
+ if (res.statusCode === 200) {
57
+ resolve({
58
+ gamePassId,
59
+ name,
60
+ description: description || '',
61
+ ...price,
62
+ iconChanged: !!icon // Boolean Cast
63
+ })
64
+ } else {
65
+ reject(new RobloxAPIError(res))
66
+ }
67
+ }).catch(error => reject(error))
68
+ })
69
+ }
70
+
71
+ // Configuring the name/description and Robux must be done in separate calls, albeit to the same end-point.
72
+ function configureRobux (args, token) {
73
+ const httpOpt = {
74
+ url: `//apis.roblox.com/game-passes/v1/game-passes/${args.gamePassId}/details`,
75
+ options: {
76
+ method: 'POST',
77
+ jar: args.jar,
78
+ headers: {
79
+ 'X-CSRF-TOKEN': token
80
+ },
81
+ resolveWithFullResponse: true,
82
+ formData: {
83
+ IsForSale: (!!Math.max(args.price, 0)).toString(), // Boolean Cast
84
+ Price: Math.floor(args.price || 0).toString() // Prevent Decimals
85
+ }
86
+ }
87
+ }
88
+ return http(httpOpt).then(function (res) {
89
+ if (res.statusCode === 200) {
90
+ // Passing price as an object, so they can be omitted if configureRobux is not run.
91
+ return configureGamePass(
92
+ args.gamePassId,
93
+ args.name,
94
+ args.description,
95
+ {
96
+ price: Math.max(Math.floor(args.price || 0), 0),
97
+ isForSale: !!Math.max(args.price, 0)
98
+ },
99
+ args.icon,
100
+ args.jar,
101
+ token
102
+ )
103
+ } else {
104
+ if (res.statusCode === 403) {
105
+ throw new Error('You do not have permission to edit this game pass.')
106
+ } else {
107
+ throw new Error(res.body.errors || 'An unknown error occurred with status code ' + res.statusCode)
108
+ }
109
+ }
110
+ })
111
+ }
112
+
113
+ exports.func = function (args) {
114
+ const jar = args.jar
115
+
116
+ return getGeneralToken({
117
+ jar
118
+ }).then(function (token) {
119
+ // Needs to catch falsy input of `false` and `0` as they should change the gamepass to offsale; price updating will be skipped if undefined.
120
+ if (typeof (args.price) === 'boolean' || typeof (args.price) === 'number') {
121
+ return configureRobux(args, token)
122
+ } else {
123
+ return configureGamePass(args.gamePassId, args.name, args.description, undefined, args.icon, jar, token)
124
+ }
125
+ })
126
+ }
@@ -0,0 +1,44 @@
1
+ // Includes
2
+ const http = require('../util/http.js').func
3
+ const RobloxAPIError = require('../util/apiError.js')
4
+
5
+ // Args
6
+ exports.required = ['placeId']
7
+ exports.optional = ['page', 'jar']
8
+
9
+ // Docs
10
+ /**
11
+ * 🔐 Returns the existing developer products in a specified game.
12
+ * @category Game
13
+ * @alias getDeveloperProducts
14
+ * @param {number} placeId - The ID of the place whose developer products you want to retrieve
15
+ * @param {number} [page=1] - Which page of developer products to return (pageSize is 50)
16
+ * @returns {Promise<DeveloperProductsResult>}
17
+ */
18
+
19
+ function getDeveloperProducts (jar, placeId, page) {
20
+ return new Promise((resolve, reject) => {
21
+ const httpOpt = {
22
+ url: `//api.roblox.com/developerproducts/list?placeid=${placeId}&page=${page}`,
23
+ options: {
24
+ method: 'GET',
25
+ jar,
26
+ resolveWithFullResponse: true
27
+ }
28
+ }
29
+ return http(httpOpt)
30
+ .then(function (res) {
31
+ if (res.statusCode === 200) {
32
+ resolve(JSON.parse(res.body))
33
+ } else {
34
+ reject(new RobloxAPIError(res))
35
+ }
36
+ })
37
+ .catch(error => reject(error))
38
+ })
39
+ }
40
+
41
+ // Define
42
+ exports.func = function (args) {
43
+ return getDeveloperProducts(args.jar, args.placeId, args.page || 1)
44
+ }
@@ -0,0 +1,31 @@
1
+ // Includes
2
+ const getPageResults = require('../util/getPageResults.js').func
3
+
4
+ // Args
5
+ exports.required = ['placeId']
6
+ exports.optional = ['serverType', 'sortOrder', 'limit', 'jar']
7
+
8
+ // Docs
9
+ /**
10
+ * 🔓 Get the servers in a game.
11
+ * @category Game
12
+ * @alias getGameInstances
13
+ * @param {number} placeId - The id of the place.
14
+ * @param {("Public" | "Friend" | "VIP")=} [serverType=Public] - The type of server to get
15
+ * @param {SortOrder=} [sortOrder=Asc] - The order that the servers will be sorted by (Asc or Desc)
16
+ * @param {number=} [limit=∞] - The maximum number of results.
17
+ * @returns {Promise<GameInstance[]>}
18
+ * @example const noblox = require("noblox.js")
19
+ * // Login using your cookie
20
+ * const servers = await noblox.getGameInstances(1)
21
+ **/
22
+
23
+ // Define
24
+ exports.func = function (args) {
25
+ return getPageResults({
26
+ jar: args.jar,
27
+ url: `//games.roblox.com/v1/games/${args.placeId}/servers/${args.serverType || 'Public'}`,
28
+ sortOrder: args.sortOrder,
29
+ limit: args.limit
30
+ })
31
+ }
@@ -0,0 +1,39 @@
1
+ // Includes
2
+ const getPageResults = require('../util/getPageResults.js').func
3
+
4
+ // Args
5
+ exports.required = ['universeId']
6
+ exports.optional = ['limit']
7
+
8
+ // Docs
9
+ /**
10
+ * ✅ Gets a game's game passes.
11
+ * @category Game
12
+ * @alias getGamePasses
13
+ * @param {number} universeId - The id of the universe.
14
+ * @param {Limit=} limit - The max number of game passes to return.
15
+ * @returns {Promise<GamePassData[]>}
16
+ * @example const noblox = require("noblox.js")
17
+ * const gamePasses = await noblox.getGamePasses(1686885941)
18
+ **/
19
+
20
+ // Define
21
+ const getGamePasses = async (universeId, limit) => {
22
+ return getPageResults({
23
+ url: `//games.roblox.com/v1/games/${universeId}/game-passes`,
24
+ limit
25
+ }).catch(err => {
26
+ if (err.message === '404 The requested universe does not exist.') {
27
+ err.message += '\n\nYou are possibly providing a placeId instead of a universeId.\nUse getPlaceInfo() to retrieve the universeId: https://noblox.js.org/global.html#getPlaceInfo\n'
28
+ throw err
29
+ }
30
+ throw err
31
+ })
32
+ }
33
+
34
+ exports.func = function ({ universeId, limit }) {
35
+ if (isNaN(universeId)) {
36
+ throw new Error('The provided universe ID is not a number.')
37
+ }
38
+ return getGamePasses(universeId, limit)
39
+ }
@@ -0,0 +1,48 @@
1
+ const http = require('../util/http.js').func
2
+ const getGeneralToken = require('../util/getGeneralToken.js').func
3
+ const RobloxAPIError = require('../util/apiError.js')
4
+
5
+ exports.required = ['placeId', 'type', 'granularity']
6
+ exports.optional = ['jar']
7
+
8
+ /**
9
+ * 🔐 Get the Game Revenue data.
10
+ * @category Game
11
+ * @alias getGameRevenue
12
+ * @param {number} placeId - The id of the game.
13
+ * @param {"Revenue" | "RevenuePerVisit" | "AverageVisitLength" | "Visits"} type - The type of revenue. Options: Revenue, RevenuePerVisit, AverageVisitLength, Visits
14
+ * @param {"Hourly" | "Daily" | "Monthly"} granularity - The type of revenue. Options: Hourly, Daily, Monthly
15
+ * @returns {Promise<GameRevenueResponse>}
16
+ * @example const noblox = require("noblox.js")
17
+ * const gameRevenue = await noblox.getGameRevenue(936068308, "Revenue", "Hourly");
18
+ **/
19
+
20
+ function getGameRevenue (placeId, type, granularity, jar, token) {
21
+ return new Promise((resolve, reject) => {
22
+ const httpOpt = {
23
+ url: `//develop.roblox.com/v1/places/${placeId}/stats/${type}?granularity=${granularity}`,
24
+ options: {
25
+ method: 'GET',
26
+ jar,
27
+ headers: {
28
+ 'X-CSRF-TOKEN': token
29
+ },
30
+ resolveWithFullResponse: true
31
+ }
32
+ }
33
+ return http(httpOpt)
34
+ .then(function (res) {
35
+ if (res.statusCode === 200) resolve(JSON.parse(res.body))
36
+ else reject(new RobloxAPIError(res))
37
+ })
38
+ .catch(function (err) { console.error(err); reject(err) })
39
+ })
40
+ }
41
+
42
+ exports.func = function (args) {
43
+ const jar = args.jar
44
+ return getGeneralToken({ jar })
45
+ .then(function (xcsrf) {
46
+ return getGameRevenue(args.placeId, args.type, args.granularity, jar, xcsrf)
47
+ })
48
+ }
@@ -0,0 +1,42 @@
1
+ // Includes
2
+ const http = require('../util/http.js').func
3
+ const RobloxAPIError = require('../util/apiError.js')
4
+
5
+ // Args
6
+ exports.required = ['universeId']
7
+ exports.optional = ['jar']
8
+
9
+ // Docs
10
+ /**
11
+ * 🔐 Get the social link data associated with a game.
12
+ * @category Game
13
+ * @alias getGameSocialLinks
14
+ * @param {number} universeId - The universe id of the game.
15
+ * @returns {Promise<SocialLinkResponse[]>}
16
+ * @see [getPlaceInfo()](global.html#getPlaceInfo) - can be used to convert a placeId to a universeId
17
+ * @example const noblox = require("noblox.js")
18
+ * const gameSocialLinks = await noblox.getGameSocialLinks(2615802125)
19
+ **/
20
+
21
+ // Define
22
+ function getGameSocialLinks (universeId, jar) {
23
+ return http({
24
+ url: `//games.roblox.com/v1/games/${universeId}/social-links/list`,
25
+ options: {
26
+ jar,
27
+ resolveWithFullResponse: true
28
+ }
29
+ })
30
+ .then((res) => {
31
+ const { data } = JSON.parse(res.body)
32
+ if (res.statusCode === 200) {
33
+ return data
34
+ } else {
35
+ throw new RobloxAPIError(res)
36
+ }
37
+ })
38
+ }
39
+
40
+ exports.func = function ({ universeId, jar }) {
41
+ return getGameSocialLinks(universeId, jar)
42
+ }
@@ -0,0 +1,30 @@
1
+ // Includes
2
+ const getPageResults = require('../util/getPageResults.js').func
3
+
4
+ // Args
5
+ exports.required = ['groupId']
6
+ exports.optional = ['accessFilter', 'sortOrder', 'limit']
7
+
8
+ // Docs
9
+ /**
10
+ * ✅ Get a group's games.
11
+ * @category Group
12
+ * @alias getGroupGames
13
+ * @param {number} groupId - The id of the group.
14
+ * @param {("All" | "Public" | "Private")=} [accessFilter=All] - Filtering games via access level.
15
+ * @param {SortOrder=} [sortOrder=Asc] - The order results are sorted in.
16
+ * @param {Limit=} [limit=∞] - The maximum number of games to return
17
+ * @returns {Promise<GroupGameInfo[]>}
18
+ * @example const noblox = require("noblox.js")
19
+ * const groupGames = await noblox.getGroupGames({groupId: 1, accessFilter: 'All', sortOrder: 'Asc', limit: '100'})
20
+ **/
21
+
22
+ // Define
23
+ exports.func = function (args) {
24
+ return getPageResults({
25
+ url: `//games.roblox.com/v2/groups/${args.groupId}/games`,
26
+ query: { accessFilter: args.accessFilter || 'All' },
27
+ sortOrder: args.sortOrder || 'Asc',
28
+ limit: args.limit
29
+ })
30
+ }
@@ -0,0 +1,47 @@
1
+ // Includes
2
+ const http = require('../util/http.js').func
3
+ const RobloxAPIError = require('../util/apiError.js')
4
+
5
+ // Args
6
+ exports.required = ['placeId']
7
+ exports.optional = ['jar']
8
+
9
+ // Docs
10
+ /**
11
+ * 🔓 Get the info for a universe.
12
+ * @category Game
13
+ * @alias getPlaceInfo
14
+ * @param {number | Array<number>} universeId - The id(s) of the place(s).
15
+ * @returns {Promise<PlaceInformation[]>}
16
+ * @example const noblox = require("noblox.js")
17
+ * const universeInfo = await noblox.getPlaceInfo([ 10905034443 ])
18
+ **/
19
+
20
+ function getPlaceInfo (placeIds, jar) {
21
+ return new Promise((resolve, reject) => {
22
+ if (typeof (placeIds) === 'number') placeIds = [placeIds]
23
+
24
+ const httpOpt = {
25
+ url: `//games.roblox.com/v1/games/multiget-place-details?placeIds=${placeIds.join(',')}`,
26
+ options: {
27
+ json: true,
28
+ resolveWithFullResponse: true,
29
+ jar,
30
+ method: 'GET'
31
+ }
32
+ }
33
+
34
+ return http(httpOpt)
35
+ .then(function (res) {
36
+ if (res.statusCode === 200) {
37
+ resolve(res.body)
38
+ } else {
39
+ reject(new RobloxAPIError(res))
40
+ }
41
+ }).catch(reject)
42
+ })
43
+ }
44
+
45
+ exports.func = function (args) {
46
+ return getPlaceInfo(args.placeId, args.jar)
47
+ }
@@ -0,0 +1,50 @@
1
+ const http = require('../util/http.js').func
2
+ const RobloxAPIError = require('../util/apiError.js')
3
+
4
+ exports.required = ['universeId']
5
+ exports.optional = ['jar']
6
+
7
+ // Docs
8
+ /**
9
+ * 🔓 Get the info for a universe.
10
+ * @category Game
11
+ * @alias getUniverseInfo
12
+ * @param {number | Array<number>} universeId - The id(s) of the universe(s).
13
+ * @returns {Promise<UniverseInformation[]>}
14
+ * @example const noblox = require("noblox.js")
15
+ * const universeInfo = await noblox.getUniverseInfo([ 2152417643 ])
16
+ **/
17
+
18
+ function getUniverseInfo (universeIds, jar) {
19
+ return new Promise((resolve, reject) => {
20
+ if (typeof (universeIds) === 'number') universeIds = [universeIds]
21
+
22
+ const httpOpt = {
23
+ url: `//games.roblox.com/v1/games?universeIds=${universeIds.join(',')}`,
24
+ options: {
25
+ json: true,
26
+ resolveWithFullResponse: true,
27
+ jar,
28
+ method: 'GET'
29
+ }
30
+ }
31
+
32
+ return http(httpOpt)
33
+ .then(function (res) {
34
+ if (res.statusCode === 200) {
35
+ resolve(res.body.data.map((universe) => {
36
+ universe.created = new Date(universe.created)
37
+ universe.updated = new Date(universe.updated)
38
+
39
+ return universe
40
+ }))
41
+ } else {
42
+ reject(new RobloxAPIError(res))
43
+ }
44
+ }).catch(reject)
45
+ })
46
+ }
47
+
48
+ exports.func = function (args) {
49
+ return getUniverseInfo(args.universeId, args.jar)
50
+ }
@@ -0,0 +1,52 @@
1
+ const http = require('../util/http.js').func
2
+ const RobloxAPIError = require('../util/apiError.js')
3
+
4
+ exports.required = ['universeId', 'topic', 'data']
5
+ exports.optional = ['jar']
6
+
7
+ // Docs
8
+ /**
9
+ * ☁️ Publish a message to a subscribed topic.
10
+ * @category Game
11
+ * @alias publishToTopic
12
+ * @param {number} universeId - The id of the universe.
13
+ * @param {string} topic - The name of the topic.
14
+ * @param {Object | string} data - The data to post.
15
+ * @returns {Promise<boolean>}
16
+ * @example const noblox = require("noblox.js")
17
+ * const data = { targetUser: 123456789, staffMember: 1210019099, action: "Kick" }
18
+ *
19
+ * await noblox.publishToTopic(2152417643, "ModerateUser", data)
20
+ **/
21
+
22
+ function publishToTopic (universeId, topic, data, jar) {
23
+ return new Promise((resolve, reject) => {
24
+ const httpOpt = {
25
+ url: `//apis.roblox.com/messaging-service/v1/universes/${universeId}/topics/${topic}`,
26
+ options: {
27
+ json: true,
28
+ resolveWithFullResponse: true,
29
+ jar,
30
+ method: 'POST',
31
+ body: { message: JSON.stringify(data) },
32
+ headers: {
33
+ 'Content-Type': 'application/json'
34
+ }
35
+ }
36
+ }
37
+
38
+ return http(httpOpt)
39
+ .then(function (res) {
40
+ if (res.statusCode === 200) {
41
+ resolve(true)
42
+ } else {
43
+ reject(new RobloxAPIError(res))
44
+ }
45
+ })
46
+ .catch(reject)
47
+ })
48
+ }
49
+
50
+ exports.func = function (args) {
51
+ return publishToTopic(args.universeId, args.topic, args.data, args.jar)
52
+ }