noblox.ts-fetch 4.6.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of noblox.ts-fetch might be problematic. Click here for more details.

Files changed (259) hide show
  1. package/.eslintrc.js +21 -0
  2. package/.github/FUNDING.yml +3 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
  5. package/.github/workflows/doc-publish.yml +33 -0
  6. package/.github/workflows/npmpublish.yml +70 -0
  7. package/.travis.yml +13 -0
  8. package/CODE_OF_CONDUCT.md +76 -0
  9. package/LICENSE +21 -0
  10. package/README.md +168 -0
  11. package/examples/cleanPlayers.js +130 -0
  12. package/examples/cleanWall.js +110 -0
  13. package/examples/revertRanks.js +100 -0
  14. package/examples/savePlayers.js +119 -0
  15. package/examples/saveWall.js +96 -0
  16. package/img/moderatedThumbnails/moderatedThumbnail_100x100.png +0 -0
  17. package/img/moderatedThumbnails/moderatedThumbnail_110x110.png +0 -0
  18. package/img/moderatedThumbnails/moderatedThumbnail_140x140.png +0 -0
  19. package/img/moderatedThumbnails/moderatedThumbnail_150x150.png +0 -0
  20. package/img/moderatedThumbnails/moderatedThumbnail_150x200.png +0 -0
  21. package/img/moderatedThumbnails/moderatedThumbnail_180x180.png +0 -0
  22. package/img/moderatedThumbnails/moderatedThumbnail_250x250.png +0 -0
  23. package/img/moderatedThumbnails/moderatedThumbnail_30x30.png +0 -0
  24. package/img/moderatedThumbnails/moderatedThumbnail_352x352.png +0 -0
  25. package/img/moderatedThumbnails/moderatedThumbnail_420x420.png +0 -0
  26. package/img/moderatedThumbnails/moderatedThumbnail_48x48.png +0 -0
  27. package/img/moderatedThumbnails/moderatedThumbnail_50x50.png +0 -0
  28. package/img/moderatedThumbnails/moderatedThumbnail_60x60.png +0 -0
  29. package/img/moderatedThumbnails/moderatedThumbnail_720x720.png +0 -0
  30. package/img/moderatedThumbnails/moderatedThumbnail_75x75.png +0 -0
  31. package/img/noblox-js-small.png +0 -0
  32. package/img/noblox-js.png +0 -0
  33. package/img/thumbnailSizes.png +0 -0
  34. package/jsDocsConfig.json +55 -0
  35. package/lib/accountinformation/getUserSocialLinks.js +42 -0
  36. package/lib/accountsettings/block.js +58 -0
  37. package/lib/accountsettings/unblock.js +58 -0
  38. package/lib/asset/deleteFromInventory.js +69 -0
  39. package/lib/asset/getGamePassProductInfo.js +51 -0
  40. package/lib/asset/getProductInfo.js +56 -0
  41. package/lib/asset/uploadAnimation.js +103 -0
  42. package/lib/asset/uploadItem.js +83 -0
  43. package/lib/asset/uploadModel.js +90 -0
  44. package/lib/avatar/avatarRules.js +38 -0
  45. package/lib/avatar/currentlyWearing.js +32 -0
  46. package/lib/avatar/getAvatar.js +35 -0
  47. package/lib/avatar/getCurrentAvatar.js +37 -0
  48. package/lib/avatar/getRecentItems.js +37 -0
  49. package/lib/avatar/outfitDetails.js +32 -0
  50. package/lib/avatar/outfits.js +37 -0
  51. package/lib/avatar/redrawAvatar.js +48 -0
  52. package/lib/avatar/removeAssetId.js +55 -0
  53. package/lib/avatar/setAvatarBodyColors.js +60 -0
  54. package/lib/avatar/setAvatarScales.js +60 -0
  55. package/lib/avatar/setPlayerAvatarType.js +50 -0
  56. package/lib/avatar/setWearingAssets.js +50 -0
  57. package/lib/avatar/wearAssetId.js +55 -0
  58. package/lib/badges/getAwardedTimestamps.js +52 -0
  59. package/lib/badges/getBadgeInfo.js +43 -0
  60. package/lib/badges/getGameBadges.js +62 -0
  61. package/lib/badges/getPlayerBadges.js +28 -0
  62. package/lib/badges/updateBadgeInfo.js +80 -0
  63. package/lib/cache/add.js +14 -0
  64. package/lib/cache/addIf.js +26 -0
  65. package/lib/cache/clear.js +8 -0
  66. package/lib/cache/get.js +28 -0
  67. package/lib/cache/index.js +17 -0
  68. package/lib/cache/new.js +12 -0
  69. package/lib/cache/wrap.js +25 -0
  70. package/lib/chat/addUsersToConversation.js +61 -0
  71. package/lib/chat/chatSettings.js +33 -0
  72. package/lib/chat/getChatMessages.js +40 -0
  73. package/lib/chat/getConversations.js +43 -0
  74. package/lib/chat/getRolloutSettings.js +35 -0
  75. package/lib/chat/getUnreadConversationCount.js +33 -0
  76. package/lib/chat/getUnreadMessages.js +38 -0
  77. package/lib/chat/getUserConversations.js +37 -0
  78. package/lib/chat/markChatAsRead.js +52 -0
  79. package/lib/chat/markChatAsSeen.js +50 -0
  80. package/lib/chat/multiGetLatestMessages.js +37 -0
  81. package/lib/chat/onNewConversation.js +50 -0
  82. package/lib/chat/onNewMessage.js +53 -0
  83. package/lib/chat/onNewMessageBySelf.js +50 -0
  84. package/lib/chat/onUserOnline.js +50 -0
  85. package/lib/chat/onUserTyping.js +54 -0
  86. package/lib/chat/removeFromGroupConversation.js +62 -0
  87. package/lib/chat/renameGroupConversation.js +57 -0
  88. package/lib/chat/sendChatMessage.js +57 -0
  89. package/lib/chat/setChatUserTyping.js +61 -0
  90. package/lib/chat/start121Conversation.js +50 -0
  91. package/lib/chat/startCloudEditConversation.js +50 -0
  92. package/lib/chat/startGroupConversation.js +62 -0
  93. package/lib/client/onNotification.js +70 -0
  94. package/lib/client/setAPIKey.js +18 -0
  95. package/lib/client/setCookie.js +38 -0
  96. package/lib/datastores/deleteDatastoreEntry.js +66 -0
  97. package/lib/datastores/getDatastoreEntry.js +98 -0
  98. package/lib/datastores/getDatastoreEntryVersions.js +83 -0
  99. package/lib/datastores/getDatastoreKeys.js +73 -0
  100. package/lib/datastores/getDatastores.js +72 -0
  101. package/lib/datastores/incrementDatastoreEntry.js +93 -0
  102. package/lib/datastores/setDatastoreEntry.js +90 -0
  103. package/lib/develop/canManage.js +44 -0
  104. package/lib/develop/configureItem.js +142 -0
  105. package/lib/develop/updateUniverse.js +53 -0
  106. package/lib/develop/updateUniverseAccess.js +55 -0
  107. package/lib/economy/buy.js +99 -0
  108. package/lib/economy/getGroupFunds.js +43 -0
  109. package/lib/economy/getGroupRevenueSummary.js +48 -0
  110. package/lib/economy/getGroupTransactions.js +32 -0
  111. package/lib/economy/getResaleData.js +54 -0
  112. package/lib/economy/getResellers.js +35 -0
  113. package/lib/economy/getUserTransactions.js +34 -0
  114. package/lib/economy/onGroupTransaction.js +74 -0
  115. package/lib/friends/acceptFriendRequest.js +59 -0
  116. package/lib/friends/declineAllFriendRequests.js +57 -0
  117. package/lib/friends/declineFriendRequest.js +59 -0
  118. package/lib/friends/getFollowers.js +61 -0
  119. package/lib/friends/getFollowings.js +61 -0
  120. package/lib/friends/getFriendRequests.js +56 -0
  121. package/lib/friends/getFriends.js +53 -0
  122. package/lib/friends/onFriendRequest.js +58 -0
  123. package/lib/friends/removeFriend.js +58 -0
  124. package/lib/friends/sendFriendRequest.js +59 -0
  125. package/lib/friends/unfollow.js +58 -0
  126. package/lib/games/addDeveloperProduct.js +65 -0
  127. package/lib/games/checkDeveloperProductName.js +39 -0
  128. package/lib/games/configureGamePass.js +146 -0
  129. package/lib/games/getDeveloperProducts.js +51 -0
  130. package/lib/games/getGameInstances.js +31 -0
  131. package/lib/games/getGamePasses.js +39 -0
  132. package/lib/games/getGameRevenue.js +49 -0
  133. package/lib/games/getGameSocialLinks.js +45 -0
  134. package/lib/games/getGroupGames.js +30 -0
  135. package/lib/games/getPlaceInfo.js +48 -0
  136. package/lib/games/getUniverseInfo.js +51 -0
  137. package/lib/games/updateDeveloperProduct.js +69 -0
  138. package/lib/groups/changeRank.js +59 -0
  139. package/lib/groups/deleteWallPost.js +64 -0
  140. package/lib/groups/deleteWallPostsByUser.js +59 -0
  141. package/lib/groups/demote.js +25 -0
  142. package/lib/groups/exile.js +59 -0
  143. package/lib/groups/getAuditLog.js +67 -0
  144. package/lib/groups/getGroup.js +57 -0
  145. package/lib/groups/getGroupSocialLinks.js +44 -0
  146. package/lib/groups/getGroups.js +88 -0
  147. package/lib/groups/getJoinRequest.js +52 -0
  148. package/lib/groups/getJoinRequests.js +58 -0
  149. package/lib/groups/getPlayers.js +108 -0
  150. package/lib/groups/getRankInGroup.js +52 -0
  151. package/lib/groups/getRankNameInGroup.js +52 -0
  152. package/lib/groups/getRole.js +64 -0
  153. package/lib/groups/getRolePermissions.js +51 -0
  154. package/lib/groups/getRoles.js +56 -0
  155. package/lib/groups/getShout.js +49 -0
  156. package/lib/groups/getWall.js +59 -0
  157. package/lib/groups/groupPayout.js +103 -0
  158. package/lib/groups/handleJoinRequest.js +60 -0
  159. package/lib/groups/leaveGroup.js +60 -0
  160. package/lib/groups/onAuditLog.js +62 -0
  161. package/lib/groups/onJoinRequest.js +63 -0
  162. package/lib/groups/onJoinRequestHandle.js +105 -0
  163. package/lib/groups/onShout.js +57 -0
  164. package/lib/groups/onWallPost.js +58 -0
  165. package/lib/groups/promote.js +25 -0
  166. package/lib/groups/searchGroups.js +32 -0
  167. package/lib/groups/setGroupDescription.js +65 -0
  168. package/lib/groups/setGroupName.js +66 -0
  169. package/lib/groups/setRank.js +79 -0
  170. package/lib/groups/shout.js +65 -0
  171. package/lib/index.js +30 -0
  172. package/lib/internal/levelOneCopy.js +16 -0
  173. package/lib/internal/queue.js +61 -0
  174. package/lib/internal/timeout.js +30 -0
  175. package/lib/internal/wrap.js +78 -0
  176. package/lib/inventory/getCollectibles.js +31 -0
  177. package/lib/inventory/getInventory.js +32 -0
  178. package/lib/inventory/getInventoryById.js +31 -0
  179. package/lib/inventory/getOwnership.js +54 -0
  180. package/lib/inventory/getUAIDs.js +47 -0
  181. package/lib/itemconfiguration/getGroupAssets.js +32 -0
  182. package/lib/options.js +26 -0
  183. package/lib/party/onPartyDeleted.js +53 -0
  184. package/lib/party/onPartyInvite.js +53 -0
  185. package/lib/party/onPartyJoinedGame.js +53 -0
  186. package/lib/party/onPartyLeftGame.js +53 -0
  187. package/lib/party/onPartySelfJoined.js +53 -0
  188. package/lib/party/onPartySelfLeft.js +53 -0
  189. package/lib/party/onPartyUserJoined.js +53 -0
  190. package/lib/party/onPartyUserLeft.js +53 -0
  191. package/lib/premiumfeatures/getPremium.js +51 -0
  192. package/lib/presence/getPresences.js +63 -0
  193. package/lib/privatemessages/getMessages.js +60 -0
  194. package/lib/privatemessages/message.js +80 -0
  195. package/lib/privatemessages/onMessage.js +88 -0
  196. package/lib/thumbnails/getLogo.js +60 -0
  197. package/lib/thumbnails/getPlayerThumbnail.js +121 -0
  198. package/lib/thumbnails/getThumbnails.js +93 -0
  199. package/lib/trades/acceptTrade.js +58 -0
  200. package/lib/trades/canTradeWith.js +48 -0
  201. package/lib/trades/counterTrade.js +84 -0
  202. package/lib/trades/declineTrade.js +58 -0
  203. package/lib/trades/getTradeInfo.js +52 -0
  204. package/lib/trades/getTrades.js +37 -0
  205. package/lib/trades/sendTrade.js +82 -0
  206. package/lib/users/getBlurb.js +36 -0
  207. package/lib/users/getIdFromUsername.js +53 -0
  208. package/lib/users/getPlayerInfo.js +100 -0
  209. package/lib/users/getUsernameFromId.js +44 -0
  210. package/lib/users/onBlurbChange.js +46 -0
  211. package/lib/util/clearSession.js +32 -0
  212. package/lib/util/generalRequest.js +61 -0
  213. package/lib/util/getAction.js +45 -0
  214. package/lib/util/getCurrentUser.js +44 -0
  215. package/lib/util/getGeneralToken.js +52 -0
  216. package/lib/util/getHash.js +29 -0
  217. package/lib/util/getInputs.js +37 -0
  218. package/lib/util/getPageResults.js +89 -0
  219. package/lib/util/getSenderUserId.js +30 -0
  220. package/lib/util/getSession.js +38 -0
  221. package/lib/util/getVerification.js +60 -0
  222. package/lib/util/getVerificationInputs.js +31 -0
  223. package/lib/util/http.js +110 -0
  224. package/lib/util/jar.js +24 -0
  225. package/lib/util/refreshCookie.js +52 -0
  226. package/lib/util/relog.js +81 -0
  227. package/lib/util/setOptions.js +54 -0
  228. package/lib/util/shortPoll.js +102 -0
  229. package/lib/util/threaded.js +80 -0
  230. package/package.json +94 -0
  231. package/postinstall.js +1 -0
  232. package/settings.json +107 -0
  233. package/test/accountinformation.test.js +27 -0
  234. package/test/accountsettings.test.js +27 -0
  235. package/test/asset.test.js +81 -0
  236. package/test/assets/Great-White-Shark-Fin.rbxm +0 -0
  237. package/test/assets/KeyframeSequence.rbxm +0 -0
  238. package/test/avatar.test.js +164 -0
  239. package/test/badges.test.js +96 -0
  240. package/test/chat.test.js +104 -0
  241. package/test/datastore.test.js +105 -0
  242. package/test/develop.test.js +53 -0
  243. package/test/economy.test.js +137 -0
  244. package/test/friends.test.js +128 -0
  245. package/test/games.test.js +212 -0
  246. package/test/groups.test.js +311 -0
  247. package/test/inventory.test.js +98 -0
  248. package/test/itemconfiguration.test.js +24 -0
  249. package/test/premiumfeatures.test.js +17 -0
  250. package/test/presence.test.js +25 -0
  251. package/test/privatemessages.test.js +33 -0
  252. package/test/thumbnails.test.js +53 -0
  253. package/test/users.test.js +68 -0
  254. package/tutorials/Authentication.md +75 -0
  255. package/tutorials/Event Emitters.md +26 -0
  256. package/tutorials/Promises.md +86 -0
  257. package/tutorials/VPS Authentication.md +72 -0
  258. package/typings/index.d.ts +2525 -0
  259. package/typings/jsDocs.ts +1927 -0
@@ -0,0 +1,59 @@
1
+ // Includes
2
+ const setRank = require('./setRank.js').func
3
+ const getRoles = require('./getRoles.js').func
4
+ const getRankNameInGroup = require('./getRankNameInGroup.js').func
5
+
6
+ // Args
7
+ exports.required = ['group', 'target', 'change']
8
+ exports.optional = ['jar']
9
+
10
+ // Docs
11
+ /**
12
+ * 🔐 Change a user's rank.
13
+ * @category Group
14
+ * @alias changeRank
15
+ * @param {number} groupId - The id of the group.
16
+ * @param {number} target - The userId of the target.
17
+ * @param {number} change - The change in rank (1 = one rank higher, -1 = one rank lower)
18
+ * @returns {Promise<ChangeRankResult>}
19
+ * @example const noblox = require("noblox.js")
20
+ * // Login using your cookie
21
+ * noblox.changeRank(1, 2, -1)
22
+ **/
23
+
24
+ // Define
25
+ exports.func = function (args) {
26
+ const group = args.group
27
+ const target = args.target
28
+ const amount = args.change
29
+ const jar = args.jar
30
+ return getRankNameInGroup({ group: group, userId: target })
31
+ .then(function (rank) {
32
+ if (rank === 'Guest') {
33
+ throw new Error('Target user is not in group')
34
+ }
35
+ return getRoles({ group: group })
36
+ .then(function (roles) {
37
+ for (let i = 0; i < roles.length; i++) {
38
+ const role = roles[i]
39
+ const thisRank = role.name
40
+
41
+ if (thisRank === rank) {
42
+ const change = i + amount
43
+ const found = roles[change]
44
+
45
+ if (!found) {
46
+ throw new Error('Rank change is out of range')
47
+ } else if (found.name === 'Guest' || found.rank === 0) {
48
+ throw new Error('Group members cannot be demoted to guest.')
49
+ }
50
+
51
+ return setRank({ group: group, target: target, rank: found.id, jar: jar })
52
+ .then(function () {
53
+ return { newRole: found, oldRole: role }
54
+ })
55
+ }
56
+ }
57
+ })
58
+ })
59
+ }
@@ -0,0 +1,64 @@
1
+ // Includes
2
+ const http = require('../util/http.js').func
3
+ const getGeneralToken = require('../util/getGeneralToken.js').func
4
+
5
+ // Args
6
+ exports.required = ['group', ['postId', 'post']]
7
+ exports.optional = ['jar']
8
+
9
+ // Docs
10
+ /**
11
+ * 🔐 Delete a wall post.
12
+ * @category Group
13
+ * @alias deleteWallPost
14
+ * @param {number} group - The id of the group.
15
+ * @param {number} postId - The id of the post to delete.
16
+ * @returns {Promise<void>}
17
+ * @example const noblox = require("noblox.js")
18
+ * // Login using your cookie
19
+ * noblox.deleteWallPost(1, 2)
20
+ **/
21
+
22
+ // Define
23
+ function deleteWallPost (jar, token, group, postId) {
24
+ return new Promise((resolve, reject) => {
25
+ const httpOpt = {
26
+ url: `//groups.roblox.com/v1/groups/${group}/wall/posts/${postId}`,
27
+ options: {
28
+ method: 'DELETE',
29
+ jar: 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
+ const body = JSON.parse(res.body) || {}
42
+ if (body.errors && body.errors.length > 0) {
43
+ const errors = body.errors.map((e) => {
44
+ return e.message
45
+ })
46
+ reject(new Error(`${res.statusCode} ${errors.join(', ')}`))
47
+ }
48
+ }
49
+ }).catch(error => reject(error))
50
+ })
51
+ }
52
+
53
+ exports.func = function (args) {
54
+ const group = args.group
55
+ const jar = args.jar
56
+ return getGeneralToken({ jar: jar })
57
+ .then(function (xcsrf) {
58
+ if (args.post) {
59
+ return deleteWallPost(jar, xcsrf, group, args.post.id)
60
+ } else {
61
+ return deleteWallPost(jar, xcsrf, group, args.postId)
62
+ }
63
+ })
64
+ }
@@ -0,0 +1,59 @@
1
+ // Includes
2
+ const http = require('../util/http.js').func
3
+ const getGeneralToken = require('../util/getGeneralToken.js').func
4
+
5
+ // Args
6
+ exports.required = ['group', 'userId']
7
+ exports.optional = ['jar']
8
+
9
+ // Docs
10
+ /**
11
+ * 🔐 Removes all wall posts sent by the provided user.
12
+ * @category Group
13
+ * @alias deleteWallPostsByUser
14
+ * @param {number} group - The id of the group.
15
+ * @param {number} userId - The userId of the user having their posts removed.
16
+ * @returns {Promise<void>}
17
+ * @example const noblox = require("noblox.js")
18
+ * // Login using your cookie
19
+ * noblox.deleteWallPostsByUser(1, 2)
20
+ **/
21
+
22
+ function deleteWallPostsByUser (group, userId, jar, xcsrf) {
23
+ return new Promise((resolve, reject) => {
24
+ const httpOpt = {
25
+ url: `https://groups.roblox.com/v1/groups/${group}/wall/users/${userId}/posts`,
26
+ options: {
27
+ method: 'DELETE',
28
+ resolveWithFullResponse: true,
29
+ jar: jar,
30
+ headers: {
31
+ 'X-CSRF-TOKEN': xcsrf
32
+ }
33
+ }
34
+ }
35
+
36
+ return http(httpOpt)
37
+ .then(function (res) {
38
+ const responseData = JSON.parse(res.body)
39
+ if (res.statusCode !== 200) {
40
+ let error = 'An unknown error has occurred.'
41
+ if (responseData && responseData.errors) {
42
+ error = responseData.errors.map((e) => e.message).join('\n')
43
+ }
44
+ reject(new Error(error))
45
+ } else {
46
+ resolve()
47
+ }
48
+ }).catch(error => reject(error))
49
+ })
50
+ }
51
+
52
+ // Define
53
+ exports.func = function (args) {
54
+ const jar = args.jar
55
+ return getGeneralToken({ jar: jar })
56
+ .then(function (xcsrf) {
57
+ return deleteWallPostsByUser(args.group, args.userId, args.jar, xcsrf)
58
+ })
59
+ }
@@ -0,0 +1,25 @@
1
+ // Includes
2
+ const changeRank = require('./changeRank.js').func
3
+
4
+ // Args
5
+ exports.required = ['group', 'target']
6
+ exports.optional = ['jar']
7
+
8
+ // Docs
9
+ /**
10
+ * 🔐 Demote a user.
11
+ * @category Group
12
+ * @alias demote
13
+ * @param {number} group - The id of the group.
14
+ * @param {number} target - The userId of the user being demoted.
15
+ * @returns {Promise<ChangeRankResult>}
16
+ * @example const noblox = require("noblox.js")
17
+ * // Login using your cookie
18
+ * noblox.demote(1, 2)
19
+ **/
20
+
21
+ // Define
22
+ exports.func = function (args) {
23
+ args.change = -1
24
+ return changeRank(args)
25
+ }
@@ -0,0 +1,59 @@
1
+ // Includes
2
+ const http = require('../util/http.js').func
3
+ const getGeneralToken = require('../util/getGeneralToken.js').func
4
+
5
+ // Args
6
+ exports.required = ['group', 'target']
7
+ exports.optional = ['jar']
8
+
9
+ // Docs
10
+ /**
11
+ * 🔐 Exile a user from a group.
12
+ * @category Group
13
+ * @alias exile
14
+ * @param {number} group - The id of the group.
15
+ * @param {number} target - The userId of the user being exiled.
16
+ * @returns {Promise<void>}
17
+ * @example const noblox = require("noblox.js")
18
+ * // Login using your cookie
19
+ * noblox.exile(1, 2)
20
+ **/
21
+
22
+ function exileUser (group, target, jar, xcsrf) {
23
+ return new Promise((resolve, reject) => {
24
+ const httpOpt = {
25
+ url: `https://groups.roblox.com/v1/groups/${group}/users/${target}`,
26
+ options: {
27
+ method: 'DELETE',
28
+ resolveWithFullResponse: true,
29
+ jar: jar,
30
+ headers: {
31
+ 'X-CSRF-TOKEN': xcsrf
32
+ }
33
+ }
34
+ }
35
+
36
+ return http(httpOpt)
37
+ .then(function (res) {
38
+ const responseData = JSON.parse(res.body)
39
+ if (res.statusCode !== 200) {
40
+ let error = 'An unknown error has occurred.'
41
+ if (responseData && responseData.errors) {
42
+ error = responseData.errors.map((e) => e.message).join('\n')
43
+ }
44
+ reject(new Error(error))
45
+ } else {
46
+ resolve()
47
+ }
48
+ }).catch(error => reject(error))
49
+ })
50
+ }
51
+
52
+ // Define
53
+ exports.func = function (args) {
54
+ const jar = args.jar
55
+ return getGeneralToken({ jar: jar })
56
+ .then(function (xcsrf) {
57
+ return exileUser(args.group, args.target, args.jar, xcsrf)
58
+ })
59
+ }
@@ -0,0 +1,67 @@
1
+ // Includes
2
+ const http = require('../util/http.js').func
3
+
4
+ exports.required = ['group']
5
+ exports.optional = ['actionType', 'userId', 'sortOrder', 'limit', 'cursor', 'jar']
6
+
7
+ // Docs
8
+ /**
9
+ * 🔐 Get the audit log for the group.
10
+ * @category Group
11
+ * @alias getAuditLog
12
+ * @param {number} group - The id of the group.
13
+ * @param {("DeletePost" | "RemoveMember" | "AcceptJoinRequest" | "DeclineJoinRequest" | "PostStatus" | "ChangeRank" | "BuyAd" | "SendAllyRequest" | "CreateEnemy" | "AcceptAllyRequest" | "DeclineAllyRequest" | "DeleteAlly" | "DeleteEnemy" | "AddGroupPlace" | "RemoveGroupPlace" | "CreateItems" | "ConfigureItems" | "SpendGroupFunds" | "ChangeOwner" | "Delete" | "AdjustCurrencyAmounts" | "Abandon" | "Claim" | "Rename" | "ChangeDescription" | "InviteToClan" | "KickFromClan" | "CancelClanInvite" | "BuyClan" | "CreateGroupAsset" | "UpdateGroupAsset" | "ConfigureGroupAsset" | "RevertGroupAsset" | "CreateGroupDeveloperProduct" | "ConfigureGroupGame" | "Lock" | "Unlock" | "CreateGamePass" | "CreateBadge" | "ConfigureBadge" | "SavePlace" | "PublishPlace")=} actionType - The action type to filter for.
14
+ * @param {number=} userId - The user's id to filter for.
15
+ * @param {SortOrder=} sortOrder - The order to sort the logs by.
16
+ * @param {Limit=} limit - The maximum logs per a page.
17
+ * @param {string=} cursor - The cursor for the page.
18
+ * @returns {Promise<AuditPage>}
19
+ * @example const noblox = require("noblox.js")
20
+ * // Login using your cookie
21
+ * const rankLogs = await noblox.getAuditLog(1, "ChangeRank", 2, "Asc")
22
+ **/
23
+
24
+ function getAuditLog (group, actionType, userId, sortOrder, limit, cursor, jar) {
25
+ return new Promise((resolve, reject) => {
26
+ const httpOpt = {
27
+ url: `https://groups.roblox.com/v1/groups/${group}/audit-log?actionType=${actionType}&cursor=${cursor}&limit=${limit}&sortOrder=${sortOrder}&userId=${userId}`,
28
+ options: {
29
+ method: 'GET',
30
+ resolveWithFullResponse: true,
31
+ jar: jar
32
+ }
33
+ }
34
+
35
+ return http(httpOpt)
36
+ .then(function (res) {
37
+ const responseData = JSON.parse(res.body)
38
+ if (res.statusCode !== 200) {
39
+ let error = 'An unknown error has occurred.'
40
+ if (responseData && responseData.errors) {
41
+ error = responseData.errors.map((e) => e.message).join('\n')
42
+ }
43
+ reject(new Error(error))
44
+ } else {
45
+ responseData.data = responseData.data.map((entry) => {
46
+ // We need to set milliseconds to 0 because Roblox does this fascinating thing
47
+ // Where they vary the ms value on each request, for an existing action.
48
+ entry.created = new Date(entry.created)
49
+ entry.created.setMilliseconds(0)
50
+ return entry
51
+ })
52
+ resolve(responseData)
53
+ }
54
+ }).catch(error => reject(error))
55
+ })
56
+ }
57
+
58
+ // Define
59
+ exports.func = function (args) {
60
+ const jar = args.jar
61
+ const actionType = args.actionType || ''
62
+ const userId = args.userId || ''
63
+ const sortOrder = args.sortOrder || 'Asc'
64
+ const limit = args.limit || (100).toString()
65
+ const cursor = args.cursor || ''
66
+ return getAuditLog(args.group, actionType, userId, sortOrder, limit, cursor, jar)
67
+ }
@@ -0,0 +1,57 @@
1
+ // Includes
2
+ const http = require('../util/http.js').func
3
+
4
+ // Args
5
+ exports.required = ['groupId']
6
+ exports.optional = []
7
+
8
+ // Docs
9
+ /**
10
+ * ✅ Get a group's info.
11
+ * @category Group
12
+ * @alias getGroup
13
+ * @param {number} groupId - The id of the group.
14
+ * @returns {Promise<Group>}
15
+ * @example const noblox = require("noblox.js")
16
+ * const groupInfo = await noblox.getGroup(1)
17
+ **/
18
+
19
+ // Define
20
+ function getGroup (groupId) {
21
+ return new Promise((resolve, reject) => {
22
+ const httpOpt = {
23
+ url: `//groups.roblox.com/v1/groups/${groupId}`,
24
+ options: {
25
+ method: 'GET',
26
+ resolveWithFullResponse: true
27
+ }
28
+ }
29
+ return http(httpOpt)
30
+ .then(function (res) {
31
+ if (res.statusCode === 200) {
32
+ const body = JSON.parse(res.body)
33
+
34
+ if (body.shout) {
35
+ body.shout.created = new Date(body.shout.created)
36
+ body.shout.updated = new Date(body.shout.updated)
37
+ }
38
+
39
+ resolve(body)
40
+ } else {
41
+ const body = JSON.parse(res.body) || {}
42
+ if (body.errors && body.errors.length > 0) {
43
+ const errors = body.errors.map((e) => {
44
+ return e.message
45
+ })
46
+ reject(new Error(`${res.statusCode} ${errors.join(', ')}`))
47
+ } else {
48
+ reject(new Error(`${res.statusCode} ${res.body}`))
49
+ }
50
+ }
51
+ }).catch(error => reject(error))
52
+ })
53
+ }
54
+
55
+ exports.func = function (args) {
56
+ return getGroup(args.groupId)
57
+ }
@@ -0,0 +1,44 @@
1
+ // Includes
2
+ const http = require('../util/http.js').func
3
+
4
+ // Args
5
+ exports.required = ['groupId']
6
+ exports.optional = ['jar']
7
+
8
+ // Docs
9
+ /**
10
+ * 🔐 Get the social link data associated with a group.
11
+ * @category Group
12
+ * @alias getGroupSocialLinks
13
+ * @param {number} groupId - The id of the group.
14
+ * @returns {Promise<SocialLinkResponse[]>}
15
+ * @example const noblox = require("noblox.js")
16
+ * const groupSocialLinks = await noblox.getGroupSocialLinks(9997719)
17
+ **/
18
+
19
+ // Define
20
+ function getGroupSocialLinks (groupId, jar) {
21
+ return http({
22
+ url: `//groups.roblox.com/v1/groups/${groupId}/social-links`,
23
+ options: {
24
+ jar: jar,
25
+ resolveWithFullResponse: true
26
+ }
27
+ })
28
+ .then(({ statusCode, body }) => {
29
+ const { errors, data } = JSON.parse(body)
30
+ if (statusCode === 200 && data) {
31
+ return data
32
+ } else if (statusCode === 400 || statusCode === 403 || statusCode === 404) {
33
+ throw new Error(`${errors[0].message} | groupId: ${groupId}`)
34
+ } else if (statusCode === 401) {
35
+ throw new Error(`${errors[0].message} (Are you logged in?) | groupId: ${groupId}`)
36
+ } else {
37
+ throw new Error(`An unknown error occurred with getGroupSocialLinks() | [${statusCode}] groupId: ${groupId}`)
38
+ }
39
+ })
40
+ }
41
+
42
+ exports.func = function ({ groupId, jar }) {
43
+ return getGroupSocialLinks(groupId, jar)
44
+ }
@@ -0,0 +1,88 @@
1
+ // Includes
2
+ const http = require('../util/http.js').func
3
+
4
+ // Args
5
+ exports.required = ['userId']
6
+ exports.optional = []
7
+
8
+ // Docs
9
+ /**
10
+ * ✅ Get the groups of a user.
11
+ * @category User
12
+ * @alias getGroups
13
+ * @param {number} userId - The id of the user.
14
+ * @returns {Promise<IGroupPartial[]>}
15
+ * @example const noblox = require("noblox.js")
16
+ * let groups = await noblox.getGroups(123456)
17
+ **/
18
+
19
+ // Define
20
+ function getGroups (userId) {
21
+ return new Promise((resolve, reject) => {
22
+ const requests = [
23
+ constructRequest(`//groups.roblox.com/v2/users/${userId}/groups/roles`),
24
+ constructRequest(`//groups.roblox.com/v1/users/${userId}/groups/primary/role`)
25
+ ].map(promise => promise.then(
26
+ val => ({ status: 'fulfilled', value: val }),
27
+ rej => ({ status: 'rejected', reason: rej })
28
+ ))
29
+
30
+ const result = []
31
+
32
+ Promise.all(requests).then(async (promiseResponses) => {
33
+ let responses = promiseResponses.map(response => response.value)
34
+ const failedResponse = (responses[0].statusCode !== 200 || !responses[0].body) // we only check the first request because the second one errors if a primary is not set
35
+
36
+ if (failedResponse) {
37
+ const body = responses[0].body || {}
38
+ if (body.errors && body.errors.length > 0) {
39
+ const errors = body.errors.map((e) => {
40
+ return e.message
41
+ })
42
+ reject(new Error(`${responses[0].statusCode} ${errors.join(', ')}`))
43
+ }
44
+ reject(new Error('The provided user ID is not valid.'))
45
+ }
46
+
47
+ responses = responses.map(r => r.body)
48
+
49
+ const groupRoleData = responses[0].data
50
+ if (groupRoleData) {
51
+ const primaryGroupId = responses[1] && responses[1].group && responses[1].group.id
52
+
53
+ const groupThumbails = await constructRequest(`https://thumbnails.roblox.com/v1/groups/icons?groupIds=${groupRoleData.map(data => data.group.id).join(',')}&size=150x150&format=Png&isCircular=false`)
54
+
55
+ groupRoleData.forEach(data => {
56
+ const insertion = {
57
+ Id: data.group.id,
58
+ Name: data.group.name,
59
+ MemberCount: data.group.memberCount,
60
+ IsPrimary: data.group.id === primaryGroupId,
61
+ Rank: data.role.rank,
62
+ Role: data.role.name,
63
+ RoleId: data.role.id,
64
+ EmblemUrl: groupThumbails.body.data.find(thumbnail => thumbnail.targetId === data.group.id).imageUrl
65
+ }
66
+ result.push(insertion)
67
+ })
68
+ }
69
+
70
+ resolve(result)
71
+ })
72
+ })
73
+ }
74
+
75
+ function constructRequest (url) {
76
+ return http({
77
+ url: url,
78
+ options: {
79
+ resolveWithFullResponse: true,
80
+ followRedirect: false,
81
+ json: true
82
+ }
83
+ })
84
+ }
85
+
86
+ exports.func = function (args) {
87
+ return getGroups(args.userId)
88
+ }
@@ -0,0 +1,52 @@
1
+ // Includes
2
+ const http = require('../util/http.js').func
3
+
4
+ // Args
5
+ exports.required = ['group', 'userId']
6
+ exports.optional = ['jar']
7
+
8
+ // Docs
9
+ /**
10
+ * 🔐 Gets a specific join request, given a user ID.
11
+ * @category Group
12
+ * @alias getJoinRequest
13
+ * @param {number} group - The id of the group.
14
+ * @param {number} userId - The user ID whose join request is wanted.
15
+ * @returns {(Promise<GroupJoinRequest>|Promise<null>)} A join request if one exists, or null.
16
+ * @example const noblox = require("noblox.js")
17
+ * // Login using your cookie
18
+ * const request = await noblox.getJoinRequest(4591072, 5903228)
19
+ **/
20
+
21
+ // Define
22
+ function getJoinRequest (jar, group, userId) {
23
+ return new Promise((resolve, reject) => {
24
+ const httpOpt = {
25
+ url: `//groups.roblox.com/v1/groups/${group}/join-requests/users/${userId}`,
26
+ options: {
27
+ method: 'GET',
28
+ jar: jar,
29
+ resolveWithFullResponse: true
30
+ }
31
+ }
32
+ return http(httpOpt)
33
+ .then(function (res) {
34
+ if (res.statusCode === 200) {
35
+ resolve(JSON.parse(res.body) || null)
36
+ } else {
37
+ const body = JSON.parse(res.body) || {}
38
+ if (body.errors && body.errors.length > 0) {
39
+ const errors = body.errors.map((e) => {
40
+ return e.message
41
+ })
42
+ reject(new Error(`${res.statusCode} ${errors.join(', ')}`))
43
+ }
44
+ }
45
+ }).catch(error => reject(error))
46
+ })
47
+ }
48
+
49
+ exports.func = function (args) {
50
+ const jar = args.jar
51
+ return getJoinRequest(jar, args.group, args.userId)
52
+ }
@@ -0,0 +1,58 @@
1
+ // Includes
2
+ const http = require('../util/http.js').func
3
+
4
+ // Args
5
+ exports.required = ['group']
6
+ exports.optional = ['sortOrder', 'limit', 'cursor', 'jar']
7
+
8
+ // Docs
9
+ /**
10
+ * 🔐 Get the join requests for a group.
11
+ * @category Group
12
+ * @alias getJoinRequests
13
+ * @param {number} group - The id of the group.
14
+ * @param {SortOrder=} sortOrder - The order to sort the requests by.
15
+ * @param {Limit=} limit - The maximum results per a page.
16
+ * @param {string=} cursor - The cursor for the next page.
17
+ * @returns {Promise<GroupJoinRequestsPage>}
18
+ * @example const noblox = require("noblox.js")
19
+ * // Login using your cookie
20
+ * const requests = await noblox.getJoinRequests(1, "Asc")
21
+ **/
22
+
23
+ // Define
24
+ function getJoinRequests (jar, group, sortOrder, limit, cursor) {
25
+ return new Promise((resolve, reject) => {
26
+ const httpOpt = {
27
+ url: `//groups.roblox.com/v1/groups/${group}/join-requests?limit=${limit}&sortOrder=${sortOrder}&cursor=${cursor}`,
28
+ options: {
29
+ method: 'GET',
30
+ jar: jar,
31
+ resolveWithFullResponse: true
32
+ }
33
+ }
34
+ return http(httpOpt)
35
+ .then(function (res) {
36
+ if (res.statusCode === 200) {
37
+ resolve(JSON.parse(res.body))
38
+ } else {
39
+ const body = JSON.parse(res.body) || {}
40
+ if (body.errors && body.errors.length > 0) {
41
+ const errors = body.errors.map((e) => {
42
+ return e.message
43
+ })
44
+ reject(new Error(`${res.statusCode} ${errors.join(', ')}`))
45
+ }
46
+ }
47
+ })
48
+ .catch(error => reject(error))
49
+ })
50
+ }
51
+
52
+ exports.func = function (args) {
53
+ const jar = args.jar
54
+ const sortOrder = args.sortOrder || 'Asc'
55
+ const limit = args.limit || (10).toString()
56
+ const cursor = args.cursor || ''
57
+ return getJoinRequests(jar, args.group, sortOrder, limit, cursor)
58
+ }