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.
- package/.eslintrc.js +21 -0
- package/.github/FUNDING.yml +3 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
- package/.github/workflows/doc-publish.yml +33 -0
- package/.github/workflows/npmpublish.yml +70 -0
- package/.travis.yml +13 -0
- package/CODE_OF_CONDUCT.md +76 -0
- package/LICENSE +21 -0
- package/README.md +168 -0
- package/examples/cleanPlayers.js +130 -0
- package/examples/cleanWall.js +110 -0
- package/examples/revertRanks.js +100 -0
- package/examples/savePlayers.js +119 -0
- package/examples/saveWall.js +96 -0
- package/img/moderatedThumbnails/moderatedThumbnail_100x100.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_110x110.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_140x140.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_150x150.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_150x200.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_180x180.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_250x250.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_30x30.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_352x352.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_420x420.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_48x48.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_50x50.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_60x60.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_720x720.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_75x75.png +0 -0
- package/img/noblox-js-small.png +0 -0
- package/img/noblox-js.png +0 -0
- package/img/thumbnailSizes.png +0 -0
- package/jsDocsConfig.json +55 -0
- package/lib/accountinformation/getUserSocialLinks.js +42 -0
- package/lib/accountsettings/block.js +58 -0
- package/lib/accountsettings/unblock.js +58 -0
- package/lib/asset/deleteFromInventory.js +69 -0
- package/lib/asset/getGamePassProductInfo.js +51 -0
- package/lib/asset/getProductInfo.js +56 -0
- package/lib/asset/uploadAnimation.js +103 -0
- package/lib/asset/uploadItem.js +83 -0
- package/lib/asset/uploadModel.js +90 -0
- package/lib/avatar/avatarRules.js +38 -0
- package/lib/avatar/currentlyWearing.js +32 -0
- package/lib/avatar/getAvatar.js +35 -0
- package/lib/avatar/getCurrentAvatar.js +37 -0
- package/lib/avatar/getRecentItems.js +37 -0
- package/lib/avatar/outfitDetails.js +32 -0
- package/lib/avatar/outfits.js +37 -0
- package/lib/avatar/redrawAvatar.js +48 -0
- package/lib/avatar/removeAssetId.js +55 -0
- package/lib/avatar/setAvatarBodyColors.js +60 -0
- package/lib/avatar/setAvatarScales.js +60 -0
- package/lib/avatar/setPlayerAvatarType.js +50 -0
- package/lib/avatar/setWearingAssets.js +50 -0
- package/lib/avatar/wearAssetId.js +55 -0
- package/lib/badges/getAwardedTimestamps.js +52 -0
- package/lib/badges/getBadgeInfo.js +43 -0
- package/lib/badges/getGameBadges.js +62 -0
- package/lib/badges/getPlayerBadges.js +28 -0
- package/lib/badges/updateBadgeInfo.js +80 -0
- package/lib/cache/add.js +14 -0
- package/lib/cache/addIf.js +26 -0
- package/lib/cache/clear.js +8 -0
- package/lib/cache/get.js +28 -0
- package/lib/cache/index.js +17 -0
- package/lib/cache/new.js +12 -0
- package/lib/cache/wrap.js +25 -0
- package/lib/chat/addUsersToConversation.js +61 -0
- package/lib/chat/chatSettings.js +33 -0
- package/lib/chat/getChatMessages.js +40 -0
- package/lib/chat/getConversations.js +43 -0
- package/lib/chat/getRolloutSettings.js +35 -0
- package/lib/chat/getUnreadConversationCount.js +33 -0
- package/lib/chat/getUnreadMessages.js +38 -0
- package/lib/chat/getUserConversations.js +37 -0
- package/lib/chat/markChatAsRead.js +52 -0
- package/lib/chat/markChatAsSeen.js +50 -0
- package/lib/chat/multiGetLatestMessages.js +37 -0
- package/lib/chat/onNewConversation.js +50 -0
- package/lib/chat/onNewMessage.js +53 -0
- package/lib/chat/onNewMessageBySelf.js +50 -0
- package/lib/chat/onUserOnline.js +50 -0
- package/lib/chat/onUserTyping.js +54 -0
- package/lib/chat/removeFromGroupConversation.js +62 -0
- package/lib/chat/renameGroupConversation.js +57 -0
- package/lib/chat/sendChatMessage.js +57 -0
- package/lib/chat/setChatUserTyping.js +61 -0
- package/lib/chat/start121Conversation.js +50 -0
- package/lib/chat/startCloudEditConversation.js +50 -0
- package/lib/chat/startGroupConversation.js +62 -0
- package/lib/client/onNotification.js +70 -0
- package/lib/client/setAPIKey.js +18 -0
- package/lib/client/setCookie.js +38 -0
- package/lib/datastores/deleteDatastoreEntry.js +66 -0
- package/lib/datastores/getDatastoreEntry.js +98 -0
- package/lib/datastores/getDatastoreEntryVersions.js +83 -0
- package/lib/datastores/getDatastoreKeys.js +73 -0
- package/lib/datastores/getDatastores.js +72 -0
- package/lib/datastores/incrementDatastoreEntry.js +93 -0
- package/lib/datastores/setDatastoreEntry.js +90 -0
- package/lib/develop/canManage.js +44 -0
- package/lib/develop/configureItem.js +142 -0
- package/lib/develop/updateUniverse.js +53 -0
- package/lib/develop/updateUniverseAccess.js +55 -0
- package/lib/economy/buy.js +99 -0
- package/lib/economy/getGroupFunds.js +43 -0
- package/lib/economy/getGroupRevenueSummary.js +48 -0
- package/lib/economy/getGroupTransactions.js +32 -0
- package/lib/economy/getResaleData.js +54 -0
- package/lib/economy/getResellers.js +35 -0
- package/lib/economy/getUserTransactions.js +34 -0
- package/lib/economy/onGroupTransaction.js +74 -0
- package/lib/friends/acceptFriendRequest.js +59 -0
- package/lib/friends/declineAllFriendRequests.js +57 -0
- package/lib/friends/declineFriendRequest.js +59 -0
- package/lib/friends/getFollowers.js +61 -0
- package/lib/friends/getFollowings.js +61 -0
- package/lib/friends/getFriendRequests.js +56 -0
- package/lib/friends/getFriends.js +53 -0
- package/lib/friends/onFriendRequest.js +58 -0
- package/lib/friends/removeFriend.js +58 -0
- package/lib/friends/sendFriendRequest.js +59 -0
- package/lib/friends/unfollow.js +58 -0
- package/lib/games/addDeveloperProduct.js +65 -0
- package/lib/games/checkDeveloperProductName.js +39 -0
- package/lib/games/configureGamePass.js +146 -0
- package/lib/games/getDeveloperProducts.js +51 -0
- package/lib/games/getGameInstances.js +31 -0
- package/lib/games/getGamePasses.js +39 -0
- package/lib/games/getGameRevenue.js +49 -0
- package/lib/games/getGameSocialLinks.js +45 -0
- package/lib/games/getGroupGames.js +30 -0
- package/lib/games/getPlaceInfo.js +48 -0
- package/lib/games/getUniverseInfo.js +51 -0
- package/lib/games/updateDeveloperProduct.js +69 -0
- package/lib/groups/changeRank.js +59 -0
- package/lib/groups/deleteWallPost.js +64 -0
- package/lib/groups/deleteWallPostsByUser.js +59 -0
- package/lib/groups/demote.js +25 -0
- package/lib/groups/exile.js +59 -0
- package/lib/groups/getAuditLog.js +67 -0
- package/lib/groups/getGroup.js +57 -0
- package/lib/groups/getGroupSocialLinks.js +44 -0
- package/lib/groups/getGroups.js +88 -0
- package/lib/groups/getJoinRequest.js +52 -0
- package/lib/groups/getJoinRequests.js +58 -0
- package/lib/groups/getPlayers.js +108 -0
- package/lib/groups/getRankInGroup.js +52 -0
- package/lib/groups/getRankNameInGroup.js +52 -0
- package/lib/groups/getRole.js +64 -0
- package/lib/groups/getRolePermissions.js +51 -0
- package/lib/groups/getRoles.js +56 -0
- package/lib/groups/getShout.js +49 -0
- package/lib/groups/getWall.js +59 -0
- package/lib/groups/groupPayout.js +103 -0
- package/lib/groups/handleJoinRequest.js +60 -0
- package/lib/groups/leaveGroup.js +60 -0
- package/lib/groups/onAuditLog.js +62 -0
- package/lib/groups/onJoinRequest.js +63 -0
- package/lib/groups/onJoinRequestHandle.js +105 -0
- package/lib/groups/onShout.js +57 -0
- package/lib/groups/onWallPost.js +58 -0
- package/lib/groups/promote.js +25 -0
- package/lib/groups/searchGroups.js +32 -0
- package/lib/groups/setGroupDescription.js +65 -0
- package/lib/groups/setGroupName.js +66 -0
- package/lib/groups/setRank.js +79 -0
- package/lib/groups/shout.js +65 -0
- package/lib/index.js +30 -0
- package/lib/internal/levelOneCopy.js +16 -0
- package/lib/internal/queue.js +61 -0
- package/lib/internal/timeout.js +30 -0
- package/lib/internal/wrap.js +78 -0
- package/lib/inventory/getCollectibles.js +31 -0
- package/lib/inventory/getInventory.js +32 -0
- package/lib/inventory/getInventoryById.js +31 -0
- package/lib/inventory/getOwnership.js +54 -0
- package/lib/inventory/getUAIDs.js +47 -0
- package/lib/itemconfiguration/getGroupAssets.js +32 -0
- package/lib/options.js +26 -0
- package/lib/party/onPartyDeleted.js +53 -0
- package/lib/party/onPartyInvite.js +53 -0
- package/lib/party/onPartyJoinedGame.js +53 -0
- package/lib/party/onPartyLeftGame.js +53 -0
- package/lib/party/onPartySelfJoined.js +53 -0
- package/lib/party/onPartySelfLeft.js +53 -0
- package/lib/party/onPartyUserJoined.js +53 -0
- package/lib/party/onPartyUserLeft.js +53 -0
- package/lib/premiumfeatures/getPremium.js +51 -0
- package/lib/presence/getPresences.js +63 -0
- package/lib/privatemessages/getMessages.js +60 -0
- package/lib/privatemessages/message.js +80 -0
- package/lib/privatemessages/onMessage.js +88 -0
- package/lib/thumbnails/getLogo.js +60 -0
- package/lib/thumbnails/getPlayerThumbnail.js +121 -0
- package/lib/thumbnails/getThumbnails.js +93 -0
- package/lib/trades/acceptTrade.js +58 -0
- package/lib/trades/canTradeWith.js +48 -0
- package/lib/trades/counterTrade.js +84 -0
- package/lib/trades/declineTrade.js +58 -0
- package/lib/trades/getTradeInfo.js +52 -0
- package/lib/trades/getTrades.js +37 -0
- package/lib/trades/sendTrade.js +82 -0
- package/lib/users/getBlurb.js +36 -0
- package/lib/users/getIdFromUsername.js +53 -0
- package/lib/users/getPlayerInfo.js +100 -0
- package/lib/users/getUsernameFromId.js +44 -0
- package/lib/users/onBlurbChange.js +46 -0
- package/lib/util/clearSession.js +32 -0
- package/lib/util/generalRequest.js +61 -0
- package/lib/util/getAction.js +45 -0
- package/lib/util/getCurrentUser.js +44 -0
- package/lib/util/getGeneralToken.js +52 -0
- package/lib/util/getHash.js +29 -0
- package/lib/util/getInputs.js +37 -0
- package/lib/util/getPageResults.js +89 -0
- package/lib/util/getSenderUserId.js +30 -0
- package/lib/util/getSession.js +38 -0
- package/lib/util/getVerification.js +60 -0
- package/lib/util/getVerificationInputs.js +31 -0
- package/lib/util/http.js +110 -0
- package/lib/util/jar.js +24 -0
- package/lib/util/refreshCookie.js +52 -0
- package/lib/util/relog.js +81 -0
- package/lib/util/setOptions.js +54 -0
- package/lib/util/shortPoll.js +102 -0
- package/lib/util/threaded.js +80 -0
- package/package.json +94 -0
- package/postinstall.js +1 -0
- package/settings.json +107 -0
- package/test/accountinformation.test.js +27 -0
- package/test/accountsettings.test.js +27 -0
- package/test/asset.test.js +81 -0
- package/test/assets/Great-White-Shark-Fin.rbxm +0 -0
- package/test/assets/KeyframeSequence.rbxm +0 -0
- package/test/avatar.test.js +164 -0
- package/test/badges.test.js +96 -0
- package/test/chat.test.js +104 -0
- package/test/datastore.test.js +105 -0
- package/test/develop.test.js +53 -0
- package/test/economy.test.js +137 -0
- package/test/friends.test.js +128 -0
- package/test/games.test.js +212 -0
- package/test/groups.test.js +311 -0
- package/test/inventory.test.js +98 -0
- package/test/itemconfiguration.test.js +24 -0
- package/test/premiumfeatures.test.js +17 -0
- package/test/presence.test.js +25 -0
- package/test/privatemessages.test.js +33 -0
- package/test/thumbnails.test.js +53 -0
- package/test/users.test.js +68 -0
- package/tutorials/Authentication.md +75 -0
- package/tutorials/Event Emitters.md +26 -0
- package/tutorials/Promises.md +86 -0
- package/tutorials/VPS Authentication.md +72 -0
- package/typings/index.d.ts +2525 -0
- package/typings/jsDocs.ts +1927 -0
@@ -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 = ['userId']
|
7
|
+
exports.optional = ['jar']
|
8
|
+
|
9
|
+
// Docs
|
10
|
+
/**
|
11
|
+
* 🔐 Accept a user's friend request.
|
12
|
+
* @category User
|
13
|
+
* @alias acceptFriendRequest
|
14
|
+
* @param {number} userId - The id of the user.
|
15
|
+
* @returns {Promise<void>}
|
16
|
+
* @example const noblox = require("noblox.js")
|
17
|
+
* // Login using your cookie
|
18
|
+
* noblox.acceptFriendRequest(123456)
|
19
|
+
**/
|
20
|
+
|
21
|
+
// Define
|
22
|
+
function acceptFriendRequest (jar, token, userId) {
|
23
|
+
return new Promise((resolve, reject) => {
|
24
|
+
const httpOpt = {
|
25
|
+
url: `//friends.roblox.com/v1/users/${userId}/accept-friend-request`,
|
26
|
+
options: {
|
27
|
+
method: 'POST',
|
28
|
+
jar: jar,
|
29
|
+
headers: {
|
30
|
+
'X-CSRF-TOKEN': token,
|
31
|
+
'Content-Type': 'application/json'
|
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
|
+
})
|
50
|
+
})
|
51
|
+
}
|
52
|
+
|
53
|
+
exports.func = function (args) {
|
54
|
+
const jar = args.jar
|
55
|
+
return getGeneralToken({ jar: jar })
|
56
|
+
.then(function (xcsrf) {
|
57
|
+
return acceptFriendRequest(jar, xcsrf, args.userId)
|
58
|
+
})
|
59
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http.js').func
|
3
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
4
|
+
|
5
|
+
// Args
|
6
|
+
exports.required = []
|
7
|
+
exports.optional = ['jar']
|
8
|
+
|
9
|
+
// Docs
|
10
|
+
/**
|
11
|
+
* 🔐 Decline all incoming friend requests.
|
12
|
+
* @category User
|
13
|
+
* @alias declineAllFriendRequests
|
14
|
+
* @returns {Promise<void>}
|
15
|
+
* @example const noblox = require("noblox.js")
|
16
|
+
* // Login using your cookie
|
17
|
+
* noblox.declineAllFriendRequests()
|
18
|
+
**/
|
19
|
+
|
20
|
+
// Define
|
21
|
+
function declineAllFriendRequests (jar, token) {
|
22
|
+
return new Promise((resolve, reject) => {
|
23
|
+
const httpOpt = {
|
24
|
+
url: '//friends.roblox.com/v1/user/friend-requests/decline-all',
|
25
|
+
options: {
|
26
|
+
method: 'POST',
|
27
|
+
jar: jar,
|
28
|
+
headers: {
|
29
|
+
'X-CSRF-TOKEN': token
|
30
|
+
},
|
31
|
+
resolveWithFullResponse: true
|
32
|
+
}
|
33
|
+
}
|
34
|
+
return http(httpOpt)
|
35
|
+
.then(function (res) {
|
36
|
+
if (res.statusCode === 200) {
|
37
|
+
resolve()
|
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
|
+
})
|
49
|
+
}
|
50
|
+
|
51
|
+
exports.func = function (args) {
|
52
|
+
const jar = args.jar
|
53
|
+
return getGeneralToken({ jar: jar })
|
54
|
+
.then(function (xcsrf) {
|
55
|
+
return declineAllFriendRequests(jar, xcsrf)
|
56
|
+
})
|
57
|
+
}
|
@@ -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 = ['userId']
|
7
|
+
exports.optional = ['jar']
|
8
|
+
|
9
|
+
// Docs
|
10
|
+
/**
|
11
|
+
* 🔐 Decline a user's friend request.
|
12
|
+
* @category User
|
13
|
+
* @alias declineFriendRequest
|
14
|
+
* @param {number} userId - The id of the user that sent the friend request that is being declined.
|
15
|
+
* @returns {Promise<void>}
|
16
|
+
* @example const noblox = require("noblox.js")
|
17
|
+
* // Login using your cookie
|
18
|
+
* noblox.declineFriendRequest(123456)
|
19
|
+
**/
|
20
|
+
|
21
|
+
// Define
|
22
|
+
function declineFriendRequest (jar, token, userId) {
|
23
|
+
return new Promise((resolve, reject) => {
|
24
|
+
const httpOpt = {
|
25
|
+
url: `//friends.roblox.com/v1/users/${userId}/decline-friend-request`,
|
26
|
+
options: {
|
27
|
+
method: 'POST',
|
28
|
+
jar: jar,
|
29
|
+
headers: {
|
30
|
+
'X-CSRF-TOKEN': token,
|
31
|
+
'Content-Type': 'application/json'
|
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
|
+
})
|
50
|
+
})
|
51
|
+
}
|
52
|
+
|
53
|
+
exports.func = function (args) {
|
54
|
+
const jar = args.jar
|
55
|
+
return getGeneralToken({ jar: jar })
|
56
|
+
.then(function (xcsrf) {
|
57
|
+
return declineFriendRequest(jar, xcsrf, args.userId)
|
58
|
+
})
|
59
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http.js').func
|
3
|
+
|
4
|
+
// Args
|
5
|
+
exports.required = ['userId']
|
6
|
+
exports.optional = ['sortOrder', 'limit', 'cursor', 'jar']
|
7
|
+
|
8
|
+
// Docs
|
9
|
+
/**
|
10
|
+
* ✅ Get a user's followers.
|
11
|
+
* @category User
|
12
|
+
* @alias getFollowers
|
13
|
+
* @param {number} userId - The id of the user whose followers are being returned.
|
14
|
+
* @param {Limit=} [limit=10] - The amount of followers being fetched each request.
|
15
|
+
* @param {SortOrder=} [sortOrder=Asc] - The order that the data should be sorted by (Asc or Desc)
|
16
|
+
* @param {string=} cursor - The cursor for the previous or next page.
|
17
|
+
* @returns {Promise<FollowersPage>}
|
18
|
+
* @example const noblox = require("noblox.js")
|
19
|
+
* let followers = await noblox.getFollowers(123456, "Asc", 10)
|
20
|
+
**/
|
21
|
+
|
22
|
+
// Define
|
23
|
+
function getFollowers (jar, userId, sortOrder, limit, cursor) {
|
24
|
+
return new Promise((resolve, reject) => {
|
25
|
+
const httpOpt = {
|
26
|
+
url: `//friends.roblox.com/v1/users/${userId}/followers?limit=${limit}&sortOrder=${sortOrder}&cursor=${cursor}`,
|
27
|
+
options: {
|
28
|
+
method: 'GET',
|
29
|
+
jar: jar,
|
30
|
+
resolveWithFullResponse: true
|
31
|
+
}
|
32
|
+
}
|
33
|
+
return http(httpOpt)
|
34
|
+
.then(function (res) {
|
35
|
+
if (res.statusCode === 200) {
|
36
|
+
const response = JSON.parse(res.body)
|
37
|
+
response.data = response.data.map((entry) => {
|
38
|
+
entry.created = new Date(entry.created)
|
39
|
+
return entry
|
40
|
+
})
|
41
|
+
resolve(response)
|
42
|
+
} else {
|
43
|
+
const body = JSON.parse(res.body) || {}
|
44
|
+
if (body.errors && body.errors.length > 0) {
|
45
|
+
const errors = body.errors.map((e) => {
|
46
|
+
return e.message
|
47
|
+
})
|
48
|
+
reject(new Error(`${res.statusCode} ${errors.join(', ')}`))
|
49
|
+
}
|
50
|
+
}
|
51
|
+
})
|
52
|
+
})
|
53
|
+
}
|
54
|
+
|
55
|
+
exports.func = function (args) {
|
56
|
+
const jar = args.jar
|
57
|
+
const sortOrder = args.sortOrder || 'Asc'
|
58
|
+
const limit = args.limit || (10).toString()
|
59
|
+
const cursor = args.cursor || ''
|
60
|
+
return getFollowers(jar, args.userId, sortOrder, limit, cursor)
|
61
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http.js').func
|
3
|
+
|
4
|
+
// Args
|
5
|
+
exports.required = ['userId']
|
6
|
+
exports.optional = ['sortOrder', 'limit', 'cursor', 'jar']
|
7
|
+
|
8
|
+
// Docs
|
9
|
+
/**
|
10
|
+
* ✅ Get the users followed by the user.
|
11
|
+
* @category User
|
12
|
+
* @alias getFollowings
|
13
|
+
* @param {number} userId - The id of the user.
|
14
|
+
* @param {Limit=} [limit=10] - The amount of users fetched by each request (10, 25, 50, 100)
|
15
|
+
* @param {SortOrder=} [sortOrder=Asc] - The order that the returned data will be sorted by (Asc or Desc)
|
16
|
+
* @param {string=} cursor - The previous or next page's cursor.
|
17
|
+
* @returns {Promise<FollowingsPage>}
|
18
|
+
* @example const noblox = require("noblox.js")
|
19
|
+
* let following = await noblox.getFollowings(123456, "Asc", 50)
|
20
|
+
**/
|
21
|
+
|
22
|
+
// Define
|
23
|
+
function getFollowings (jar, userId, sortOrder, limit, cursor) {
|
24
|
+
return new Promise((resolve, reject) => {
|
25
|
+
const httpOpt = {
|
26
|
+
url: `//friends.roblox.com/v1/users/${userId}/followings?limit=${limit}&sortOrder=${sortOrder}&cursor=${cursor}`,
|
27
|
+
options: {
|
28
|
+
method: 'GET',
|
29
|
+
jar: jar,
|
30
|
+
resolveWithFullResponse: true
|
31
|
+
}
|
32
|
+
}
|
33
|
+
return http(httpOpt)
|
34
|
+
.then(function (res) {
|
35
|
+
if (res.statusCode === 200) {
|
36
|
+
const response = JSON.parse(res.body)
|
37
|
+
response.data = response.data.map((entry) => {
|
38
|
+
entry.created = new Date(entry.created)
|
39
|
+
return entry
|
40
|
+
})
|
41
|
+
resolve(response)
|
42
|
+
} else {
|
43
|
+
const body = JSON.parse(res.body) || {}
|
44
|
+
if (body.errors && body.errors.length > 0) {
|
45
|
+
const errors = body.errors.map((e) => {
|
46
|
+
return e.message
|
47
|
+
})
|
48
|
+
reject(new Error(`${res.statusCode} ${errors.join(', ')}`))
|
49
|
+
}
|
50
|
+
}
|
51
|
+
})
|
52
|
+
})
|
53
|
+
}
|
54
|
+
|
55
|
+
exports.func = function (args) {
|
56
|
+
const jar = args.jar
|
57
|
+
const sortOrder = args.sortOrder || 'Asc'
|
58
|
+
const limit = args.limit || (10).toString()
|
59
|
+
const cursor = args.cursor || ''
|
60
|
+
return getFollowings(jar, args.userId, sortOrder, limit, cursor)
|
61
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http.js').func
|
3
|
+
|
4
|
+
// Args
|
5
|
+
exports.required = []
|
6
|
+
exports.optional = ['sortOrder', 'limit', 'cursor', 'jar']
|
7
|
+
|
8
|
+
// Docs
|
9
|
+
/**
|
10
|
+
* 🔐 Get the friend requests of the authenticated user.
|
11
|
+
* @category User
|
12
|
+
* @alias getFriendRequests
|
13
|
+
* @param {SortOrder=} [sortOrder=Asc] - The order of the returned data (Asc or Desc)
|
14
|
+
* @param {Limit=} [limit=10] - The number of users returned by each request.
|
15
|
+
* @param {string=} cursor - The previous or next page's cursor.
|
16
|
+
* @returns {Promise<FriendRequestsPage>}
|
17
|
+
* @example const noblox = require("noblox.js")
|
18
|
+
* // Login using your cookie
|
19
|
+
* let friendRequests = await noblox.getFriendRequests({sortOrder: "Desc", limit: 100})
|
20
|
+
**/
|
21
|
+
|
22
|
+
// Define
|
23
|
+
function getFriendsRequests (args) {
|
24
|
+
return new Promise((resolve, reject) => {
|
25
|
+
const jar = args.jar
|
26
|
+
const httpOpt = {
|
27
|
+
url: '//friends.roblox.com/v1/my/friends/requests',
|
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
|
+
const response = JSON.parse(res.body)
|
38
|
+
response.data = response.data.map((entry) => {
|
39
|
+
entry.created = new Date(entry.created)
|
40
|
+
return entry
|
41
|
+
})
|
42
|
+
resolve(response)
|
43
|
+
} else {
|
44
|
+
const body = JSON.parse(res.body) || {}
|
45
|
+
if (body.errors && body.errors.length > 0) {
|
46
|
+
const errors = body.errors.map((e) => {
|
47
|
+
return e.message
|
48
|
+
})
|
49
|
+
reject(new Error(`${res.statusCode} ${errors.join(', ')}`))
|
50
|
+
}
|
51
|
+
}
|
52
|
+
})
|
53
|
+
})
|
54
|
+
}
|
55
|
+
|
56
|
+
exports.func = getFriendsRequests
|
@@ -0,0 +1,53 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http.js').func
|
3
|
+
// Args
|
4
|
+
exports.required = ['userId']
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* ✅ Get the friends of a user
|
10
|
+
* @category User
|
11
|
+
* @alias getFriends
|
12
|
+
* @param {number} userId - The id of the user whose friends are being returned.
|
13
|
+
* @returns {Promise<Friends>}
|
14
|
+
* @example const noblox = require("noblox.js")
|
15
|
+
* let friends = await noblox.getFriends(123456)
|
16
|
+
**/
|
17
|
+
|
18
|
+
// Define
|
19
|
+
function getFriends (jar, userId) {
|
20
|
+
return new Promise((resolve, reject) => {
|
21
|
+
const httpOpt = {
|
22
|
+
url: `//friends.roblox.com/v1/users/${userId}/friends`,
|
23
|
+
options: {
|
24
|
+
method: 'GET',
|
25
|
+
jar: jar,
|
26
|
+
resolveWithFullResponse: true
|
27
|
+
}
|
28
|
+
}
|
29
|
+
return http(httpOpt)
|
30
|
+
.then(function (res) {
|
31
|
+
if (res.statusCode === 200) {
|
32
|
+
const response = JSON.parse(res.body)
|
33
|
+
response.data = response.data.map((entry) => {
|
34
|
+
entry.created = new Date(entry.created)
|
35
|
+
return entry
|
36
|
+
})
|
37
|
+
resolve(response)
|
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
|
+
})
|
49
|
+
}
|
50
|
+
|
51
|
+
exports.func = function (args) {
|
52
|
+
return getFriends(args.jar, args.userId)
|
53
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
// Dependencies
|
2
|
+
const events = require('events')
|
3
|
+
|
4
|
+
// Includes
|
5
|
+
const onNotification = require('../client/onNotification.js').func
|
6
|
+
|
7
|
+
// Args
|
8
|
+
exports.optional = ['jar']
|
9
|
+
|
10
|
+
// Docs
|
11
|
+
/**
|
12
|
+
* 🔐 An event for when a user sends you a friend request.
|
13
|
+
* @category User
|
14
|
+
* @alias onFriendRequest
|
15
|
+
* @returns An EventEmitter that emits when a user sends you a friend request.
|
16
|
+
* @example const noblox = require("noblox.js")
|
17
|
+
* // Login using your cookie
|
18
|
+
*
|
19
|
+
* const friendRequestEvent = noblox.onFriendRequest()
|
20
|
+
* friendRequestEvent.on("data", function(data) {
|
21
|
+
* console.log("New friend request! ", data)
|
22
|
+
* })
|
23
|
+
* friendRequestEvent.on("error", function(err) {
|
24
|
+
* console.error("Something went wrong: ", err)
|
25
|
+
* // Handle error as needed
|
26
|
+
* })
|
27
|
+
**/
|
28
|
+
|
29
|
+
// Define
|
30
|
+
exports.func = function (args) {
|
31
|
+
const jar = args.jar
|
32
|
+
const onFriendRequest = new events.EventEmitter()
|
33
|
+
const notifications = onNotification({ jar: jar })
|
34
|
+
notifications.on('data', function (name, message) {
|
35
|
+
if (name === 'FriendshipNotifications' && message.Type === 'FriendshipRequested') {
|
36
|
+
onFriendRequest.emit('data', message.EventArgs.UserId1)
|
37
|
+
}
|
38
|
+
})
|
39
|
+
notifications.on('error', function (err) {
|
40
|
+
onFriendRequest.emit('error', err)
|
41
|
+
})
|
42
|
+
notifications.on('connect', function () {
|
43
|
+
onFriendRequest.emit('connect')
|
44
|
+
})
|
45
|
+
notifications.on('close', function (internal) {
|
46
|
+
if (internal) {
|
47
|
+
return
|
48
|
+
}
|
49
|
+
onFriendRequest.emit('close', true)
|
50
|
+
})
|
51
|
+
onFriendRequest.on('close', function (internal) {
|
52
|
+
if (internal) {
|
53
|
+
return
|
54
|
+
}
|
55
|
+
notifications.emit('close', true)
|
56
|
+
})
|
57
|
+
return onFriendRequest
|
58
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http.js').func
|
3
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
4
|
+
|
5
|
+
// Args
|
6
|
+
exports.required = ['userId']
|
7
|
+
exports.optional = ['jar']
|
8
|
+
|
9
|
+
// Docs
|
10
|
+
/**
|
11
|
+
* 🔐 Remove a user from your friends list.
|
12
|
+
* @category User
|
13
|
+
* @alias removeFriend
|
14
|
+
* @param {number} userId - The id of the user.
|
15
|
+
* @returns {Promise<void>}
|
16
|
+
* @example const noblox = require("noblox.js")
|
17
|
+
* // Login using your cookie
|
18
|
+
* noblox.removeFriend(123456)
|
19
|
+
**/
|
20
|
+
|
21
|
+
// Define
|
22
|
+
function removeFriend (jar, token, userId) {
|
23
|
+
return new Promise((resolve, reject) => {
|
24
|
+
const httpOpt = {
|
25
|
+
url: `//friends.roblox.com/v1/users/${userId}/unfriend`,
|
26
|
+
options: {
|
27
|
+
method: 'POST',
|
28
|
+
jar: jar,
|
29
|
+
headers: {
|
30
|
+
'X-CSRF-TOKEN': token
|
31
|
+
},
|
32
|
+
resolveWithFullResponse: true
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return http(httpOpt)
|
36
|
+
.then(function (res) {
|
37
|
+
if (res.statusCode === 200) {
|
38
|
+
resolve()
|
39
|
+
} else {
|
40
|
+
const body = JSON.parse(res.body) || {}
|
41
|
+
if (body.errors && body.errors.length > 0) {
|
42
|
+
const errors = body.errors.map((e) => {
|
43
|
+
return e.message
|
44
|
+
})
|
45
|
+
reject(new Error(`${res.statusCode} ${errors.join(', ')}`))
|
46
|
+
}
|
47
|
+
}
|
48
|
+
})
|
49
|
+
})
|
50
|
+
}
|
51
|
+
|
52
|
+
exports.func = function (args) {
|
53
|
+
const jar = args.jar
|
54
|
+
return getGeneralToken({ jar: jar })
|
55
|
+
.then(function (xcsrf) {
|
56
|
+
return removeFriend(jar, xcsrf, args.userId)
|
57
|
+
})
|
58
|
+
}
|
@@ -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 = ['userId']
|
7
|
+
exports.optional = ['jar']
|
8
|
+
|
9
|
+
// Docs
|
10
|
+
/**
|
11
|
+
* 🔐 Send a friend request to a user.
|
12
|
+
* @category User
|
13
|
+
* @alias sendFriendRequest
|
14
|
+
* @param {number} userId - The id of the user.
|
15
|
+
* @returns {Promise<void>}
|
16
|
+
* @example const noblox = require("noblox.js")
|
17
|
+
* // Login using your cookie
|
18
|
+
* noblox.sendFriendRequest(123456)
|
19
|
+
**/
|
20
|
+
|
21
|
+
// Define
|
22
|
+
function sendFriendRequest (jar, token, userId) {
|
23
|
+
return new Promise((resolve, reject) => {
|
24
|
+
const httpOpt = {
|
25
|
+
url: `//friends.roblox.com/v1/users/${userId}/request-friendship`,
|
26
|
+
options: {
|
27
|
+
method: 'POST',
|
28
|
+
jar: jar,
|
29
|
+
headers: {
|
30
|
+
'X-CSRF-TOKEN': token,
|
31
|
+
'Content-Type': 'application/json'
|
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
|
+
})
|
50
|
+
})
|
51
|
+
}
|
52
|
+
|
53
|
+
exports.func = function (args) {
|
54
|
+
const jar = args.jar
|
55
|
+
return getGeneralToken({ jar: jar })
|
56
|
+
.then(function (xcsrf) {
|
57
|
+
return sendFriendRequest(jar, xcsrf, args.userId)
|
58
|
+
})
|
59
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http.js').func
|
3
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
4
|
+
|
5
|
+
// Args
|
6
|
+
exports.required = ['userId']
|
7
|
+
exports.optional = ['jar']
|
8
|
+
|
9
|
+
// Docs
|
10
|
+
/**
|
11
|
+
* 🔐 Unfollow a user.
|
12
|
+
* @category User
|
13
|
+
* @alias unfollow
|
14
|
+
* @param {number} userId - The id of the user.
|
15
|
+
* @returns {Promise<void>}
|
16
|
+
* @example const noblox = require("noblox.js")
|
17
|
+
* // Login using your cookie
|
18
|
+
* noblox.unfollow(123456)
|
19
|
+
**/
|
20
|
+
|
21
|
+
// Define
|
22
|
+
function unfollow (jar, token, userId) {
|
23
|
+
return new Promise((resolve, reject) => {
|
24
|
+
const httpOpt = {
|
25
|
+
url: `//friends.roblox.com/v1/users/${userId}/unfollow`,
|
26
|
+
options: {
|
27
|
+
method: 'POST',
|
28
|
+
jar: jar,
|
29
|
+
headers: {
|
30
|
+
'X-CSRF-TOKEN': token
|
31
|
+
},
|
32
|
+
resolveWithFullResponse: true
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return http(httpOpt)
|
36
|
+
.then(function (res) {
|
37
|
+
if (res.statusCode === 200) {
|
38
|
+
resolve()
|
39
|
+
} else {
|
40
|
+
const body = JSON.parse(res.body) || {}
|
41
|
+
if (body.errors && body.errors.length > 0) {
|
42
|
+
const errors = body.errors.map((e) => {
|
43
|
+
return e.message
|
44
|
+
})
|
45
|
+
reject(new Error(`${res.statusCode} ${errors.join(', ')}`))
|
46
|
+
}
|
47
|
+
}
|
48
|
+
})
|
49
|
+
})
|
50
|
+
}
|
51
|
+
|
52
|
+
exports.func = function (args) {
|
53
|
+
const jar = args.jar
|
54
|
+
return getGeneralToken({ jar: jar })
|
55
|
+
.then(function (xcsrf) {
|
56
|
+
return unfollow(jar, xcsrf, args.userId)
|
57
|
+
})
|
58
|
+
}
|