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,37 @@
|
|
1
|
+
const http = require('../util/http.js').func
|
2
|
+
|
3
|
+
exports.required = ['userId']
|
4
|
+
exports.optional = ['page', 'itemsPerPage']
|
5
|
+
|
6
|
+
// Docs
|
7
|
+
/**
|
8
|
+
* ✅ Get a user's outfits.
|
9
|
+
* @category Avatar
|
10
|
+
* @alias outfits
|
11
|
+
* @param {number} userId - The userId of the user.
|
12
|
+
* @param {number=} page - The page to index.
|
13
|
+
* @param {number=} itemsPerPage - The number of results on each page.
|
14
|
+
* @returns {Promise<GetOutfitsResult>}
|
15
|
+
* @example const noblox = require("noblox.js")
|
16
|
+
* const outfits = await noblox.outfits(1)
|
17
|
+
**/
|
18
|
+
|
19
|
+
exports.func = (args) => {
|
20
|
+
const userId = args.userId
|
21
|
+
const page = parseInt(args.page) ? parseInt(args.page) : '*'
|
22
|
+
const itemsPerPage = parseInt(args.itemsPerPage) ? parseInt(args.itemsPerPage) : '*'
|
23
|
+
|
24
|
+
return http({
|
25
|
+
url: '//avatar.roblox.com/v1/users/' + userId + '/outfits?page=' + page + '&itemsPerPage=' + itemsPerPage,
|
26
|
+
options: {
|
27
|
+
method: 'GET',
|
28
|
+
resolveWithFullResponse: true
|
29
|
+
}
|
30
|
+
}).then((res) => {
|
31
|
+
if (res.statusCode === 200) {
|
32
|
+
return JSON.parse(res.body)
|
33
|
+
} else {
|
34
|
+
throw new Error('User does not exist')
|
35
|
+
}
|
36
|
+
})
|
37
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
const http = require('../util/http.js').func
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
3
|
+
|
4
|
+
exports.optional = ['jar']
|
5
|
+
|
6
|
+
// Docs
|
7
|
+
/**
|
8
|
+
* 🔐 Redraw your avatar.
|
9
|
+
* @category Avatar
|
10
|
+
* @alias redrawAvatar
|
11
|
+
* @returns {Promise<void>}
|
12
|
+
* @example const noblox = require("noblox.js")
|
13
|
+
* // Login using your cookie
|
14
|
+
* noblox.redrawAvatar()
|
15
|
+
**/
|
16
|
+
|
17
|
+
function redrawAvatar (jar, token) {
|
18
|
+
return new Promise((resolve, reject) => {
|
19
|
+
const httpOpt = {
|
20
|
+
url: '//avatar.roblox.com/v1/avatar/redraw-thumbnail',
|
21
|
+
options: {
|
22
|
+
method: 'POST',
|
23
|
+
jar: jar,
|
24
|
+
headers: {
|
25
|
+
'X-CSRF-TOKEN': token
|
26
|
+
},
|
27
|
+
resolveWithFullResponse: true
|
28
|
+
}
|
29
|
+
}
|
30
|
+
return http(httpOpt).then((res) => {
|
31
|
+
if (res.statusCode === 200) {
|
32
|
+
resolve()
|
33
|
+
} else if (res.statusCode === 429) {
|
34
|
+
reject(new Error('Redraw avatar floodchecked'))
|
35
|
+
} else {
|
36
|
+
reject(new Error('Redraw avatar failed'))
|
37
|
+
}
|
38
|
+
}).catch(error => reject(error))
|
39
|
+
})
|
40
|
+
}
|
41
|
+
|
42
|
+
exports.func = (args) => {
|
43
|
+
const jar = args.jar
|
44
|
+
|
45
|
+
return getGeneralToken({ jar: jar }).then((xcsrf) => {
|
46
|
+
return redrawAvatar(jar, xcsrf)
|
47
|
+
})
|
48
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
const http = require('../util/http.js').func
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
3
|
+
|
4
|
+
exports.required = ['assetId']
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 Removes an asset from your avatar.
|
10
|
+
* @category Avatar
|
11
|
+
* @alias removeAssetId
|
12
|
+
* @param {number} assetId - The assetId to remove.
|
13
|
+
* @returns {Promise<void>}
|
14
|
+
* @example const noblox = require("noblox.js")
|
15
|
+
* // Login using your cookie
|
16
|
+
* noblox.removeAssetId(1)
|
17
|
+
**/
|
18
|
+
|
19
|
+
function removeAssetId (assetId, jar, xcsrf) {
|
20
|
+
return new Promise((resolve, reject) => {
|
21
|
+
const httpOpt = {
|
22
|
+
url: 'https://avatar.roblox.com/v1/avatar/assets/' + assetId + '/remove',
|
23
|
+
options: {
|
24
|
+
method: 'POST',
|
25
|
+
jar: jar,
|
26
|
+
headers: {
|
27
|
+
'X-CSRF-TOKEN': xcsrf
|
28
|
+
},
|
29
|
+
resolveWithFullResponse: true
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
return http(httpOpt)
|
34
|
+
.then(function (res) {
|
35
|
+
const responseData = JSON.parse(res.body)
|
36
|
+
if (res.statusCode !== 200) {
|
37
|
+
let error = 'An unknown error has occurred.'
|
38
|
+
if (responseData && responseData.errors) {
|
39
|
+
error = responseData.errors.map((e) => e.message).join('\n')
|
40
|
+
}
|
41
|
+
reject(new Error(error))
|
42
|
+
} else {
|
43
|
+
resolve()
|
44
|
+
}
|
45
|
+
}).catch(error => reject(error))
|
46
|
+
})
|
47
|
+
}
|
48
|
+
|
49
|
+
exports.func = (args) => {
|
50
|
+
const jar = args.jar
|
51
|
+
|
52
|
+
return getGeneralToken({ jar: jar }).then((xcsrf) => {
|
53
|
+
return removeAssetId(args.assetId, jar, xcsrf)
|
54
|
+
})
|
55
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
const http = require('../util/http.js').func
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
3
|
+
|
4
|
+
exports.required = ['headColorId', 'torsoColorId', 'rightArmColorId', 'leftArmColorId', 'rightLegColorId', 'leftLegColorId']
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 Set the colors of your avatar.
|
10
|
+
* @category Avatar
|
11
|
+
* @alias setAvatarBodyColors
|
12
|
+
* @param {number} headColorId - The [BrickColor Code]{@link https://developer.roblox.com/en-us/articles/BrickColor-Codes} of the head.
|
13
|
+
* @param {number} torsoColorId - The [BrickColor Code]{@link https://developer.roblox.com/en-us/articles/BrickColor-Codes} of the torso.
|
14
|
+
* @param {number} rightArmColorId - The [BrickColor Code]{@link https://developer.roblox.com/en-us/articles/BrickColor-Codes} of the right arm.
|
15
|
+
* @param {number} leftArmColorId - The [BrickColor Code]{@link https://developer.roblox.com/en-us/articles/BrickColor-Codes} of the left arm.
|
16
|
+
* @param {number} rightLegColorId - The [BrickColor Code]{@link https://developer.roblox.com/en-us/articles/BrickColor-Codes} of the right leg.
|
17
|
+
* @param {number} leftLegColorId - The [BrickColor Code]{@link https://developer.roblox.com/en-us/articles/BrickColor-Codes} of the left leg.
|
18
|
+
* @returns {Promise<void>}
|
19
|
+
* @example const noblox = require("noblox.js")
|
20
|
+
* // Login using your cookie
|
21
|
+
* noblox.setAvatarBodyColors(125, 125, 125, 125, 125, 125)
|
22
|
+
**/
|
23
|
+
|
24
|
+
const nextFunction = (jar, token, headColorId, torsoColorId, rightArmColorId, leftArmColorId, rightLegColorId, leftLegColorId) => {
|
25
|
+
return http({
|
26
|
+
url: '//avatar.roblox.com/v1/avatar/set-body-colors',
|
27
|
+
options: {
|
28
|
+
method: 'POST',
|
29
|
+
jar: jar,
|
30
|
+
headers: {
|
31
|
+
'X-CSRF-TOKEN': token
|
32
|
+
},
|
33
|
+
json: {
|
34
|
+
headColorId: headColorId,
|
35
|
+
torsoColorId: torsoColorId,
|
36
|
+
rightArmColorId: rightArmColorId,
|
37
|
+
leftArmColorId: leftArmColorId,
|
38
|
+
rightLegColorId: rightLegColorId,
|
39
|
+
leftLegColorId: leftLegColorId
|
40
|
+
},
|
41
|
+
resolveWithFullResponse: true
|
42
|
+
}
|
43
|
+
}).then((res) => {
|
44
|
+
if (res.statusCode === 200) {
|
45
|
+
if (!res.body.success) {
|
46
|
+
throw new Error(res.body)
|
47
|
+
}
|
48
|
+
} else {
|
49
|
+
throw new Error('Set body colors failed')
|
50
|
+
}
|
51
|
+
})
|
52
|
+
}
|
53
|
+
|
54
|
+
exports.func = (args) => {
|
55
|
+
const jar = args.jar
|
56
|
+
|
57
|
+
return getGeneralToken({ jar: jar }).then((xcsrf) => {
|
58
|
+
return nextFunction(jar, xcsrf, args.headColorId, args.torsoColorId, args.rightArmColorId, args.leftArmColorId, args.rightLegColorId, args.leftLegColorId)
|
59
|
+
})
|
60
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
const http = require('../util/http.js').func
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
3
|
+
|
4
|
+
exports.required = ['height', 'width', 'head']
|
5
|
+
exports.optional = ['depth', 'proportion', 'bodyType', 'jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 Set the scale of your avatar.
|
10
|
+
* @category Avatar
|
11
|
+
* @alias setAvatarScales
|
12
|
+
* @param {number} height - The height scale of the avatar.
|
13
|
+
* @param {number} width - The width scale of the avatar.
|
14
|
+
* @param {number} head - The head scale of the avatar.
|
15
|
+
* @param {number=} depth - The depth scale of the avatar.
|
16
|
+
* @param {number=} proportion - The proportion scale of the avatar.
|
17
|
+
* @param {number=} bodyType - The body type scale of the avatar.
|
18
|
+
* @returns {Promise<void>}
|
19
|
+
* @example const noblox = require("noblox.js")
|
20
|
+
* // Login using your cookie
|
21
|
+
* noblox.setAvatarScales(1, 1, 1, 1, 1, 1)
|
22
|
+
**/
|
23
|
+
|
24
|
+
const nextFunction = (jar, token, height, width, head, depth, proportion, bodyType) => {
|
25
|
+
return http({
|
26
|
+
url: '//avatar.roblox.com/v1/avatar/set-scales',
|
27
|
+
options: {
|
28
|
+
method: 'POST',
|
29
|
+
jar: jar,
|
30
|
+
headers: {
|
31
|
+
'X-CSRF-TOKEN': token
|
32
|
+
},
|
33
|
+
json: {
|
34
|
+
height: height,
|
35
|
+
width: width,
|
36
|
+
head: head,
|
37
|
+
depth: depth,
|
38
|
+
proportion: proportion,
|
39
|
+
bodyType: bodyType
|
40
|
+
},
|
41
|
+
resolveWithFullResponse: true
|
42
|
+
}
|
43
|
+
}).then((res) => {
|
44
|
+
if (res.statusCode === 200) {
|
45
|
+
if (!res.body.success) {
|
46
|
+
throw new Error(res.body)
|
47
|
+
}
|
48
|
+
} else {
|
49
|
+
throw new Error('Set avatar scale failed')
|
50
|
+
}
|
51
|
+
})
|
52
|
+
}
|
53
|
+
|
54
|
+
exports.func = (args) => {
|
55
|
+
const jar = args.jar
|
56
|
+
|
57
|
+
return getGeneralToken({ jar: jar }).then((xcsrf) => {
|
58
|
+
return nextFunction(jar, xcsrf, args.height, args.width, args.head, args.depth, args.proportion, args.bodyType)
|
59
|
+
})
|
60
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
const http = require('../util/http.js').func
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
3
|
+
|
4
|
+
exports.required = ['avatarType']
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 Set the type of your avatar.
|
10
|
+
* @category Avatar
|
11
|
+
* @alias setPlayerAvatarType
|
12
|
+
* @param {PlayerAvatarType} avatarType - The type of your avatar. (R6 or R15)
|
13
|
+
* @returns {Promise<void>}
|
14
|
+
* @example const noblox = require("noblox.js")
|
15
|
+
* // Login using your cookie
|
16
|
+
* noblox.setPlayerAvatarType("R6")
|
17
|
+
**/
|
18
|
+
|
19
|
+
const nextFunction = (jar, token, avatarType) => {
|
20
|
+
return http({
|
21
|
+
url: '//avatar.roblox.com/v1/avatar/set-player-avatar-type',
|
22
|
+
options: {
|
23
|
+
method: 'POST',
|
24
|
+
jar: jar,
|
25
|
+
headers: {
|
26
|
+
'X-CSRF-TOKEN': token
|
27
|
+
},
|
28
|
+
json: {
|
29
|
+
playerAvatarType: avatarType
|
30
|
+
},
|
31
|
+
resolveWithFullResponse: true
|
32
|
+
}
|
33
|
+
}).then((res) => {
|
34
|
+
if (res.statusCode === 200) {
|
35
|
+
if (!res.body.success) {
|
36
|
+
throw new Error(res.body)
|
37
|
+
}
|
38
|
+
} else {
|
39
|
+
throw new Error('Set avatar type failed')
|
40
|
+
}
|
41
|
+
})
|
42
|
+
}
|
43
|
+
|
44
|
+
exports.func = (args) => {
|
45
|
+
const jar = args.jar
|
46
|
+
|
47
|
+
return getGeneralToken({ jar: jar }).then((xcsrf) => {
|
48
|
+
return nextFunction(jar, xcsrf, args.avatarType)
|
49
|
+
})
|
50
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
const http = require('../util/http.js').func
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
3
|
+
|
4
|
+
exports.required = ['assetIds']
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 Set the assets your avatar is wearing.
|
10
|
+
* @category Avatar
|
11
|
+
* @alias setWearingAssets
|
12
|
+
* @param {Array<number>} assetIds - An array of asset IDs to wear.
|
13
|
+
* @returns {Promise<void>}
|
14
|
+
* @example const noblox = require("noblox.js")
|
15
|
+
* // Login using your cookie
|
16
|
+
* noblox.setWearingAssets([1, 2, 3])
|
17
|
+
**/
|
18
|
+
|
19
|
+
const nextFunction = (jar, token, assetIds) => {
|
20
|
+
return http({
|
21
|
+
url: '//avatar.roblox.com/v1/avatar/set-wearing-assets',
|
22
|
+
options: {
|
23
|
+
method: 'POST',
|
24
|
+
jar: jar,
|
25
|
+
headers: {
|
26
|
+
'X-CSRF-TOKEN': token
|
27
|
+
},
|
28
|
+
json: {
|
29
|
+
assetIds: assetIds
|
30
|
+
},
|
31
|
+
resolveWithFullResponse: true
|
32
|
+
}
|
33
|
+
}).then((res) => {
|
34
|
+
if (res.statusCode === 200) {
|
35
|
+
if (!res.body.success) {
|
36
|
+
throw new Error('Invalid assets: ' + res.body.invalidAssetIds.join(', '))
|
37
|
+
}
|
38
|
+
} else {
|
39
|
+
throw new Error('Wear assets failed')
|
40
|
+
}
|
41
|
+
})
|
42
|
+
}
|
43
|
+
|
44
|
+
exports.func = (args) => {
|
45
|
+
const jar = args.jar
|
46
|
+
|
47
|
+
return getGeneralToken({ jar: jar }).then((xcsrf) => {
|
48
|
+
return nextFunction(jar, xcsrf, args.assetIds)
|
49
|
+
})
|
50
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
const http = require('../util/http.js').func
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
3
|
+
|
4
|
+
exports.required = ['assetId']
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 Wear a specific asset.
|
10
|
+
* @category Avatar
|
11
|
+
* @alias wearAssetId
|
12
|
+
* @param {number} assetId - The assetId to wear.
|
13
|
+
* @returns {Promise<void>}
|
14
|
+
* @example const noblox = require("noblox.js")
|
15
|
+
* // Login using your cookie
|
16
|
+
* noblox.wearAssetId(1117747196)
|
17
|
+
**/
|
18
|
+
|
19
|
+
function wearAssetId (assetId, jar, xcsrf) {
|
20
|
+
return new Promise((resolve, reject) => {
|
21
|
+
const httpOpt = {
|
22
|
+
url: 'https://avatar.roblox.com/v1/avatar/assets/' + assetId + '/wear',
|
23
|
+
options: {
|
24
|
+
method: 'POST',
|
25
|
+
jar: jar,
|
26
|
+
headers: {
|
27
|
+
'X-CSRF-TOKEN': xcsrf
|
28
|
+
},
|
29
|
+
resolveWithFullResponse: true
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
return http(httpOpt)
|
34
|
+
.then(function (res) {
|
35
|
+
const responseData = JSON.parse(res.body)
|
36
|
+
if (res.statusCode !== 200) {
|
37
|
+
let error = 'An unknown error has occurred.'
|
38
|
+
if (responseData && responseData.errors) {
|
39
|
+
error = responseData.errors.map((e) => e.message).join('\n')
|
40
|
+
}
|
41
|
+
reject(new Error(error))
|
42
|
+
} else {
|
43
|
+
resolve()
|
44
|
+
}
|
45
|
+
}).catch(error => reject(error))
|
46
|
+
})
|
47
|
+
}
|
48
|
+
|
49
|
+
exports.func = (args) => {
|
50
|
+
const jar = args.jar
|
51
|
+
|
52
|
+
return getGeneralToken({ jar: jar }).then((xcsrf) => {
|
53
|
+
return wearAssetId(args.assetId, jar, xcsrf)
|
54
|
+
})
|
55
|
+
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http').func
|
3
|
+
|
4
|
+
// Args
|
5
|
+
exports.required = ['userId', 'badgeId']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* ✅ Get the time the badge was awarded to a user.
|
10
|
+
* @category Badges
|
11
|
+
* @alias getAwardedTimestamps
|
12
|
+
* @param {number} userId - The userId of the user.
|
13
|
+
* @param {Array<number>} badgeId - The ids of the badges.
|
14
|
+
* @returns {Promise<UserBadgeStats>}
|
15
|
+
* @example const noblox = require("noblox.js")
|
16
|
+
* const badges = await noblox.getAwardedTimestamps(1, [1, 2, 3])
|
17
|
+
**/
|
18
|
+
|
19
|
+
// Define
|
20
|
+
const getAwardedTimestamps = (userId, badgeId) => {
|
21
|
+
return new Promise((resolve, reject) => {
|
22
|
+
const httpOpt = {
|
23
|
+
url: `https://badges.roblox.com/v1/users/${userId}/badges/awarded-dates?badgeIds=${badgeId.join(',')}`,
|
24
|
+
options: {
|
25
|
+
method: 'GET',
|
26
|
+
resolveWithFullResponse: true
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
return http(httpOpt)
|
31
|
+
.then(function (res) {
|
32
|
+
const responseData = JSON.parse(res.body)
|
33
|
+
if (res.statusCode !== 200) {
|
34
|
+
let error = 'An unknown error has occurred.'
|
35
|
+
if (responseData && responseData.errors) {
|
36
|
+
error = responseData.errors.map((e) => e.message).join('\n')
|
37
|
+
}
|
38
|
+
reject(new Error(error))
|
39
|
+
} else {
|
40
|
+
resolve(responseData)
|
41
|
+
}
|
42
|
+
})
|
43
|
+
})
|
44
|
+
}
|
45
|
+
|
46
|
+
exports.func = async (args) => {
|
47
|
+
if (isNaN(args.userId)) {
|
48
|
+
throw new Error('The provided User ID is not a number.')
|
49
|
+
}
|
50
|
+
|
51
|
+
return getAwardedTimestamps(args.userId, args.badgeId)
|
52
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http').func
|
3
|
+
|
4
|
+
// Args
|
5
|
+
exports.required = ['badgeId']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* ✅ Get the info of a badge.
|
10
|
+
* @category Badges
|
11
|
+
* @alias getBadgeInfo
|
12
|
+
* @param {number} badgeId - The badge's id.
|
13
|
+
* @returns {Promise<BadgeInfo>}
|
14
|
+
* @example const noblox = require("noblox.js")
|
15
|
+
* const badgeInfo = await noblox.getBadgeInfo(1)
|
16
|
+
**/
|
17
|
+
|
18
|
+
// Define
|
19
|
+
const badgeInfo = async (id) => {
|
20
|
+
return http({
|
21
|
+
url: `https://badges.roblox.com/v1/badges/${id}`,
|
22
|
+
options: {
|
23
|
+
resolveWithFullResponse: true,
|
24
|
+
method: 'GET'
|
25
|
+
}
|
26
|
+
}).then(res => {
|
27
|
+
if (res.statusCode === 200) {
|
28
|
+
const json = JSON.parse(res.body)
|
29
|
+
json.created = new Date(json.created)
|
30
|
+
json.updated = new Date(json.updated)
|
31
|
+
return json
|
32
|
+
} else {
|
33
|
+
throw new Error('Badge is invalid or does not exist.')
|
34
|
+
}
|
35
|
+
})
|
36
|
+
}
|
37
|
+
|
38
|
+
exports.func = async (args) => {
|
39
|
+
if (isNaN(args.badgeId)) {
|
40
|
+
throw new Error('The provided Badge ID is not a number.')
|
41
|
+
}
|
42
|
+
return badgeInfo(args.badgeId)
|
43
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http').func
|
3
|
+
|
4
|
+
// Args
|
5
|
+
exports.required = ['universeId']
|
6
|
+
exports.optional = ['limit', 'cursor', 'sortOrder']
|
7
|
+
|
8
|
+
// Docs
|
9
|
+
/**
|
10
|
+
* ✅ Get the badges in a specific game.
|
11
|
+
* @category Game
|
12
|
+
* @alias getGameBadges
|
13
|
+
* @param {number} universeId - The id of the universe.
|
14
|
+
* @param {Limit=} limit - The max number of badges to return.
|
15
|
+
* @param {string=} cursor - The page cursor.
|
16
|
+
* @param {SortOrder=} sortOrder - The order to sort badges in. (Asc/Desc)
|
17
|
+
* @returns {Promise<BadgeInfo>}
|
18
|
+
* @example const noblox = require("noblox.js")
|
19
|
+
* const badges = await noblox.getGameBadges(1)
|
20
|
+
**/
|
21
|
+
|
22
|
+
// Define
|
23
|
+
const gameBadges = async (id, limit, cursor, order) => {
|
24
|
+
return http({
|
25
|
+
url: `https://badges.roblox.com/v1/universes/${id}/badges?limit=${limit}&cursor=${cursor}&sortOrder=${order}`,
|
26
|
+
options: {
|
27
|
+
resolveWithFullResponse: true,
|
28
|
+
method: 'GET'
|
29
|
+
}
|
30
|
+
}).then(res => {
|
31
|
+
if (res.statusCode === 200) {
|
32
|
+
const json = JSON.parse(res.body)
|
33
|
+
json.data.map(badge => {
|
34
|
+
badge.created = new Date(badge.created)
|
35
|
+
badge.updated = new Date(badge.updated)
|
36
|
+
return badge
|
37
|
+
})
|
38
|
+
return json.data
|
39
|
+
} else {
|
40
|
+
throw new Error('The game is invalid or does not exist.')
|
41
|
+
}
|
42
|
+
})
|
43
|
+
}
|
44
|
+
exports.func = async (args) => {
|
45
|
+
if (isNaN(args.universeId)) {
|
46
|
+
throw new Error('The provided Universe ID is not a number.')
|
47
|
+
};
|
48
|
+
if (args.limit) {
|
49
|
+
if (![10, 25, 50, 100].includes(args.limit)) {
|
50
|
+
throw new Error('The allowed values are: 10, 25, 50 and 100.')
|
51
|
+
};
|
52
|
+
};
|
53
|
+
if (args.sortOrder) {
|
54
|
+
if (args.sortOrder.toLowerCase() !== 'asc' && args.sortOrder.toLowerCase() !== 'desc') {
|
55
|
+
throw new Error('Invalid sort order type.')
|
56
|
+
}
|
57
|
+
}
|
58
|
+
const limit = args.limit || 10
|
59
|
+
const sortOrder = args.sortOrder || 'Asc'
|
60
|
+
const cursor = args.cursor || ''
|
61
|
+
return gameBadges(args.universeId, limit, cursor, sortOrder)
|
62
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
// Includes
|
2
|
+
const getPageResults = require('../util/getPageResults.js').func
|
3
|
+
|
4
|
+
// Args
|
5
|
+
exports.required = ['userId']
|
6
|
+
exports.optional = ['limit', 'sortOrder', 'jar']
|
7
|
+
|
8
|
+
// Docs
|
9
|
+
/**
|
10
|
+
* ✅ Get the badges that a user has.
|
11
|
+
* @category User
|
12
|
+
* @alias getPlayerBadges
|
13
|
+
* @param {number} userId - The id of the user whose badges are being fetched.
|
14
|
+
* @param {number} [limit=10] - The amount of badges being returned each request.
|
15
|
+
* @param {SortOrder=} [sortOrder=Asc] - The order that the data will be returned in (Asc or Desc)
|
16
|
+
* @returns {Promise<Array<PlayerBadges>>}
|
17
|
+
* @example const noblox = require("noblox.js")
|
18
|
+
* let badges = noblox.getPlayerBadges(123456, 10, "Asc")
|
19
|
+
**/
|
20
|
+
|
21
|
+
exports.func = async (args) => {
|
22
|
+
return getPageResults({
|
23
|
+
jar: args.jar,
|
24
|
+
url: `//badges.roblox.com/v1/users/${args.userId}/badges`,
|
25
|
+
sortOrder: args.sortOrder,
|
26
|
+
limit: args.limit
|
27
|
+
})
|
28
|
+
}
|
@@ -0,0 +1,80 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http').func
|
3
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
4
|
+
|
5
|
+
// Args
|
6
|
+
exports.required = ['badgeId']
|
7
|
+
exports.optional = ['name', 'description', 'enabled', 'jar']
|
8
|
+
|
9
|
+
// Docs
|
10
|
+
/**
|
11
|
+
* 🔐 Configure a badge.
|
12
|
+
* @category Badges
|
13
|
+
* @alias updateBadgeInfo
|
14
|
+
* @param {number} badgeId - The badge's id.
|
15
|
+
* @param {string=} name - The new name of the badge.
|
16
|
+
* @param {string=} description - The new description of the badge.
|
17
|
+
* @param {boolean=} enabled - If the badge is enabled.
|
18
|
+
* @returns {Promise<void>}
|
19
|
+
* @example const noblox = require("noblox.js")
|
20
|
+
* // Login using your cookie
|
21
|
+
* noblox.updateBadgeInfo(1, "Badge", "A cool badge.", true)
|
22
|
+
**/
|
23
|
+
|
24
|
+
// Define
|
25
|
+
const updateInfo = (id, name, desc, enabled, xcrsf, jar) => {
|
26
|
+
return http({
|
27
|
+
url: `https://badges.roblox.com/v1/badges/${id}`,
|
28
|
+
options: {
|
29
|
+
resolveWithFullResponse: true,
|
30
|
+
method: 'PATCH',
|
31
|
+
jar: jar,
|
32
|
+
headers: {
|
33
|
+
'Content-Type': 'application/json',
|
34
|
+
'X-CSRF-TOKEN': xcrsf
|
35
|
+
},
|
36
|
+
body: JSON.stringify({
|
37
|
+
name: name,
|
38
|
+
description: desc,
|
39
|
+
enabled: enabled
|
40
|
+
})
|
41
|
+
}
|
42
|
+
}).then(res => {
|
43
|
+
if (res.statusCode === 200) {
|
44
|
+
return JSON.parse(res.body)
|
45
|
+
} else if (res.statusCode === 400) {
|
46
|
+
throw new Error('Text moderated.')
|
47
|
+
} else if (res.statusCode === 401) {
|
48
|
+
throw new Error('Authorization has been denied for this request.')
|
49
|
+
} else if (res.statusCode === 403) {
|
50
|
+
throw new Error('Token Validation failed or you do not have permission to manage this badge.')
|
51
|
+
} else if (res.statusCode === 404) {
|
52
|
+
throw new Error('Badge is invalid or does not exist.')
|
53
|
+
}
|
54
|
+
})
|
55
|
+
}
|
56
|
+
|
57
|
+
exports.func = async (args) => {
|
58
|
+
if (isNaN(args.badgeId)) {
|
59
|
+
throw new Error('The provided Badge ID is not a number.')
|
60
|
+
}
|
61
|
+
if (args.name) {
|
62
|
+
if (typeof args.name !== 'string') throw new Error('The name must be a string.')
|
63
|
+
} else if (args.description) {
|
64
|
+
if (typeof args.description !== 'string') throw new Error('The description must be a string.')
|
65
|
+
}
|
66
|
+
|
67
|
+
if (args.enabled) {
|
68
|
+
if (typeof args.enabled !== 'boolean') {
|
69
|
+
throw new Error('Enabled must be a boolean.')
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
const name = args.name || ''
|
74
|
+
const description = args.description || ''
|
75
|
+
const enabled = args.enabled || true
|
76
|
+
const jar = args.jar
|
77
|
+
|
78
|
+
const xcsrf = await getGeneralToken({ jar: jar })
|
79
|
+
return updateInfo(args.badgeId, name, description, enabled, xcsrf, jar)
|
80
|
+
}
|