discord-api-ts 0.0.1-security → 4.6.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of discord-api-ts 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 +166 -3
- 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 +91 -3
- 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,53 @@
|
|
1
|
+
const events = require('events')
|
2
|
+
|
3
|
+
const onNotification = require('../client/onNotification.js').func
|
4
|
+
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 An event for when someone messages you via. chat. This event will only emit for messages sent via. chat windows on
|
10
|
+
* the website - those in the pop-up/overlay window. To handle messages sent via. the older email-like
|
11
|
+
* message function, see onMessage.
|
12
|
+
* @see [onMessage()](global.html#onMessage)
|
13
|
+
* @category Chat
|
14
|
+
* @alias onNewMessage
|
15
|
+
* @returns An EventEmitter that emits when someone messages you.
|
16
|
+
* @example const noblox = require("noblox.js")
|
17
|
+
* // Login using your cookie
|
18
|
+
* const messageEvent = noblox.onNewMessage()
|
19
|
+
* messageEvent.on("data", function(data) {
|
20
|
+
* console.log("New chat message! ", data)
|
21
|
+
* })
|
22
|
+
* messageEvent.on("error", function(err) {
|
23
|
+
* console.error("Something went wrong: ", err)
|
24
|
+
* // Handle error as needed
|
25
|
+
* })
|
26
|
+
**/
|
27
|
+
|
28
|
+
exports.func = (args) => {
|
29
|
+
const jar = args.jar
|
30
|
+
const newEvent = new events.EventEmitter()
|
31
|
+
const notifications = onNotification({ jar: jar })
|
32
|
+
|
33
|
+
notifications.on('data', (name, message) => {
|
34
|
+
if (name === 'ChatNotifications' && message.Type === 'NewMessage') {
|
35
|
+
newEvent.emit('data', message.ConversationId)
|
36
|
+
}
|
37
|
+
})
|
38
|
+
|
39
|
+
notifications.on('error', (err) => {
|
40
|
+
newEvent.emit('error', err)
|
41
|
+
})
|
42
|
+
|
43
|
+
notifications.on('connect', () => {
|
44
|
+
newEvent.emit('connect')
|
45
|
+
})
|
46
|
+
|
47
|
+
notifications.on('close', (internal) => {
|
48
|
+
if (internal) return
|
49
|
+
notifications.emit('close', true)
|
50
|
+
})
|
51
|
+
|
52
|
+
return newEvent
|
53
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
const events = require('events')
|
2
|
+
|
3
|
+
const onNotification = require('../client/onNotification.js').func
|
4
|
+
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 An event for when you send a new message.
|
10
|
+
* @category Chat
|
11
|
+
* @alias onNewMessageBySelf
|
12
|
+
* @returns An EventEmitter that emits when you send a new message.
|
13
|
+
* @example const noblox = require("noblox.js")
|
14
|
+
* // Login using your cookie
|
15
|
+
* const messageSent = noblox.onNewMessageBySelf()
|
16
|
+
* messageSent.on("data", function(data) {
|
17
|
+
* console.log("Sent chat message! ", data)
|
18
|
+
* })
|
19
|
+
* messageSent.on("error", function(err) {
|
20
|
+
* console.error("Something went wrong: ", err)
|
21
|
+
* // Handle error as needed
|
22
|
+
* })
|
23
|
+
**/
|
24
|
+
|
25
|
+
exports.func = (args) => {
|
26
|
+
const jar = args.jar
|
27
|
+
const newEvent = new events.EventEmitter()
|
28
|
+
const notifications = onNotification({ jar: jar })
|
29
|
+
|
30
|
+
notifications.on('data', (name, message) => {
|
31
|
+
if (name === 'ChatNotifications' && message.Type === 'NewMessageBySelf') {
|
32
|
+
newEvent.emit('data', message.ConversationId)
|
33
|
+
}
|
34
|
+
})
|
35
|
+
|
36
|
+
notifications.on('error', (err) => {
|
37
|
+
newEvent.emit('error', err)
|
38
|
+
})
|
39
|
+
|
40
|
+
notifications.on('connect', () => {
|
41
|
+
newEvent.emit('connect')
|
42
|
+
})
|
43
|
+
|
44
|
+
notifications.on('close', (internal) => {
|
45
|
+
if (internal) return
|
46
|
+
notifications.emit('close', true)
|
47
|
+
})
|
48
|
+
|
49
|
+
return newEvent
|
50
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
const events = require('events')
|
2
|
+
|
3
|
+
const onNotification = require('../client/onNotification.js').func
|
4
|
+
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 An event for when someone comes online.
|
10
|
+
* @category Chat
|
11
|
+
* @alias onUserOnline
|
12
|
+
* @returns An EventEmitter that emits when someone comes online.
|
13
|
+
* @example const noblox = require("noblox.js")
|
14
|
+
* // Login using your cookie
|
15
|
+
* const userOnlineEvent = noblox.onUserOnline()
|
16
|
+
* userOnlineEvent.on("data", function(data) {
|
17
|
+
* console.log("User online! ", data)
|
18
|
+
* })
|
19
|
+
* userOnlineEvent.on("error", function(err) {
|
20
|
+
* console.error("Something went wrong: ", err)
|
21
|
+
* // Handle error as needed
|
22
|
+
* })
|
23
|
+
**/
|
24
|
+
|
25
|
+
exports.func = (args) => {
|
26
|
+
const jar = args.jar
|
27
|
+
const newEvent = new events.EventEmitter()
|
28
|
+
const notifications = onNotification({ jar: jar })
|
29
|
+
|
30
|
+
notifications.on('data', (name, message) => {
|
31
|
+
if (name === 'PresenceNotifications' && message.Type === 'UserOnline') {
|
32
|
+
newEvent.emit('data', message.UserId)
|
33
|
+
}
|
34
|
+
})
|
35
|
+
|
36
|
+
notifications.on('error', (err) => {
|
37
|
+
newEvent.emit('error', err)
|
38
|
+
})
|
39
|
+
|
40
|
+
notifications.on('connect', () => {
|
41
|
+
newEvent.emit('connect')
|
42
|
+
})
|
43
|
+
|
44
|
+
notifications.on('close', (internal) => {
|
45
|
+
if (internal) return
|
46
|
+
notifications.emit('close', true)
|
47
|
+
})
|
48
|
+
|
49
|
+
return newEvent
|
50
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
const events = require('events')
|
2
|
+
|
3
|
+
const onNotification = require('../client/onNotification.js').func
|
4
|
+
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 An event for when someone starts typing in a chat.
|
10
|
+
* @category Chat
|
11
|
+
* @alias onUserTyping
|
12
|
+
* @returns An EventEmitter that emits when someone starts typing in a chat.
|
13
|
+
* @example const noblox = require("noblox.js")
|
14
|
+
* // Login using your cookie
|
15
|
+
* const userTyping = noblox.onUserTyping()
|
16
|
+
* userTyping.on("data", function(data) {
|
17
|
+
* console.log("User typing! ", data)
|
18
|
+
* })
|
19
|
+
* userTyping.on("error", function(err) {
|
20
|
+
* console.error("Something went wrong: ", err)
|
21
|
+
* // Handle error as needed
|
22
|
+
* })
|
23
|
+
**/
|
24
|
+
|
25
|
+
exports.func = (args) => {
|
26
|
+
const jar = args.jar
|
27
|
+
const newEvent = new events.EventEmitter()
|
28
|
+
const notifications = onNotification({ jar: jar })
|
29
|
+
|
30
|
+
notifications.on('data', (name, message) => {
|
31
|
+
if (name === 'ChatNotifications' && message.Type === 'ParticipantTyping') {
|
32
|
+
newEvent.emit('data', {
|
33
|
+
UserId: message.UserId,
|
34
|
+
ConversationId: message.ConversationId,
|
35
|
+
IsTyping: message.IsTyping
|
36
|
+
})
|
37
|
+
}
|
38
|
+
})
|
39
|
+
|
40
|
+
notifications.on('error', (err) => {
|
41
|
+
newEvent.emit('error', err)
|
42
|
+
})
|
43
|
+
|
44
|
+
notifications.on('connect', () => {
|
45
|
+
newEvent.emit('connect')
|
46
|
+
})
|
47
|
+
|
48
|
+
notifications.on('close', (internal) => {
|
49
|
+
if (internal) return
|
50
|
+
notifications.emit('close', true)
|
51
|
+
})
|
52
|
+
|
53
|
+
return newEvent
|
54
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
const http = require('../util/http.js').func
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
3
|
+
|
4
|
+
exports.required = ['conversationId', 'userId']
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 Remove a user from the group conversation.
|
10
|
+
* @category Chat
|
11
|
+
* @alias removeFromGroupConversation
|
12
|
+
* @param {number} conversationId - The id of the conversation.
|
13
|
+
* @param {number} userId - The id of the user.
|
14
|
+
* @returns {Promise<ConversationRemoveResponse>}
|
15
|
+
* @example const noblox = require("noblox.js")
|
16
|
+
* // Login using your cookie
|
17
|
+
* noblox.removeFromGroupConversation(1, 2)
|
18
|
+
**/
|
19
|
+
|
20
|
+
function removeFromGroupConversation (conversationId, userId, jar, token) {
|
21
|
+
return new Promise((resolve, reject) => {
|
22
|
+
const httpOpt = {
|
23
|
+
url: '//chat.roblox.com/v2/remove-from-conversation',
|
24
|
+
options: {
|
25
|
+
method: 'POST',
|
26
|
+
jar: jar,
|
27
|
+
headers: {
|
28
|
+
'X-CSRF-TOKEN': token
|
29
|
+
},
|
30
|
+
json: {
|
31
|
+
conversationId: conversationId,
|
32
|
+
participantUserId: userId
|
33
|
+
},
|
34
|
+
resolveWithFullResponse: true
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
return http(httpOpt).then((res) => {
|
39
|
+
if (res.statusCode === 200) {
|
40
|
+
if (!res.body.resultType === 'Success') {
|
41
|
+
reject(new Error(res.body.statusMessage))
|
42
|
+
} else {
|
43
|
+
resolve(res.body)
|
44
|
+
}
|
45
|
+
} else {
|
46
|
+
let error = 'An unknown error has occurred.'
|
47
|
+
if (res.body && res.body.errors) {
|
48
|
+
error = res.body.errors.map((e) => e.message).join('\n')
|
49
|
+
}
|
50
|
+
reject(new Error(error))
|
51
|
+
}
|
52
|
+
}).catch(error => reject(error))
|
53
|
+
})
|
54
|
+
}
|
55
|
+
|
56
|
+
exports.func = (args) => {
|
57
|
+
const jar = args.jar
|
58
|
+
|
59
|
+
return getGeneralToken({ jar: jar }).then((xcsrf) => {
|
60
|
+
return removeFromGroupConversation(args.conversationId, args.userId, jar, xcsrf)
|
61
|
+
})
|
62
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
const http = require('../util/http.js').func
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
3
|
+
|
4
|
+
exports.required = ['conversationId', 'title']
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 Rename a group conversation.
|
10
|
+
* @category Chat
|
11
|
+
* @alias renameGroupConversation
|
12
|
+
* @param {number} conversationId - The id of the conversation.
|
13
|
+
* @param {string} title - The new title of the group.
|
14
|
+
* @returns {Promise<ConversationRenameResponse>}
|
15
|
+
* @example const noblox = require("noblox.js")
|
16
|
+
* // Login using your cookie
|
17
|
+
* noblox.renameGroupConversation(1, "A cool group.")
|
18
|
+
**/
|
19
|
+
|
20
|
+
function renameGroupConversation (conversationId, newTitle, jar, token) {
|
21
|
+
return new Promise((resolve, reject) => {
|
22
|
+
const httpOpt = {
|
23
|
+
url: '//chat.roblox.com/v2/rename-group-conversation',
|
24
|
+
options: {
|
25
|
+
method: 'POST',
|
26
|
+
jar: jar,
|
27
|
+
headers: {
|
28
|
+
'X-CSRF-TOKEN': token
|
29
|
+
},
|
30
|
+
json: {
|
31
|
+
conversationId: conversationId,
|
32
|
+
newTitle: newTitle
|
33
|
+
},
|
34
|
+
resolveWithFullResponse: true
|
35
|
+
}
|
36
|
+
}
|
37
|
+
return http(httpOpt).then((res) => {
|
38
|
+
if (res.statusCode === 200) {
|
39
|
+
if (!res.body.resultType === 'Success') {
|
40
|
+
reject(new Error(res.body.statusMessage))
|
41
|
+
} else {
|
42
|
+
resolve(res.body)
|
43
|
+
}
|
44
|
+
} else {
|
45
|
+
reject(new Error('Rename group chat failed'))
|
46
|
+
}
|
47
|
+
}).catch(error => reject(error))
|
48
|
+
})
|
49
|
+
}
|
50
|
+
|
51
|
+
exports.func = (args) => {
|
52
|
+
const jar = args.jar
|
53
|
+
|
54
|
+
return getGeneralToken({ jar: jar }).then((xcsrf) => {
|
55
|
+
return renameGroupConversation(args.conversationId, args.title, jar, xcsrf)
|
56
|
+
})
|
57
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
const http = require('../util/http.js').func
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
3
|
+
|
4
|
+
exports.required = ['conversationId', 'message']
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 Send a message in a chat.
|
10
|
+
* @category Chat
|
11
|
+
* @alias sendChatMessage
|
12
|
+
* @param {number} conversationId - The id of the conversation.
|
13
|
+
* @param {string} message - The message to send.
|
14
|
+
* @returns {Promise<SendChatResponse>}
|
15
|
+
* @example const noblox = require("noblox.js")
|
16
|
+
* // Login using your cookie
|
17
|
+
* noblox.sendChatMessage(1, "Hello world!")
|
18
|
+
**/
|
19
|
+
|
20
|
+
function sendChatMessage (conversationId, messageText, jar, token) {
|
21
|
+
return new Promise((resolve, reject) => {
|
22
|
+
const httpOpt = {
|
23
|
+
url: '//chat.roblox.com/v2/send-message',
|
24
|
+
options: {
|
25
|
+
method: 'POST',
|
26
|
+
jar: jar,
|
27
|
+
headers: {
|
28
|
+
'X-CSRF-TOKEN': token
|
29
|
+
},
|
30
|
+
json: {
|
31
|
+
conversationId: conversationId,
|
32
|
+
message: messageText
|
33
|
+
},
|
34
|
+
resolveWithFullResponse: true
|
35
|
+
}
|
36
|
+
}
|
37
|
+
return http(httpOpt).then((res) => {
|
38
|
+
if (res.statusCode === 200) {
|
39
|
+
if (!res.body.resultType === 'Success') {
|
40
|
+
reject(new Error(res.body.statusMessage))
|
41
|
+
} else {
|
42
|
+
resolve(res.body)
|
43
|
+
}
|
44
|
+
} else {
|
45
|
+
throw new Error('Send chat message failed')
|
46
|
+
}
|
47
|
+
}).catch(error => reject(error))
|
48
|
+
})
|
49
|
+
}
|
50
|
+
|
51
|
+
exports.func = (args) => {
|
52
|
+
const jar = args.jar
|
53
|
+
|
54
|
+
return getGeneralToken({ jar: jar }).then((xcsrf) => {
|
55
|
+
return sendChatMessage(args.conversationId, args.message, jar, xcsrf)
|
56
|
+
})
|
57
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
const http = require('../util/http.js').func
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
3
|
+
|
4
|
+
exports.required = ['conversationId', 'isTyping']
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 Trigger the typing action in a conversation.
|
10
|
+
* @category Chat
|
11
|
+
* @alias setChatUserTyping
|
12
|
+
* @param {number} conversationId - The id of the conversation.
|
13
|
+
* @param {boolean} isTyping - If the user is typing.
|
14
|
+
* @returns {Promise<UpdateTypingResponse>}
|
15
|
+
* @example const noblox = require("noblox.js")
|
16
|
+
* // Login using your cookie
|
17
|
+
* noblox.setChatUserTyping(1, true)
|
18
|
+
**/
|
19
|
+
|
20
|
+
function setChatUserTyping (conversationId, isTyping, jar, token) {
|
21
|
+
return new Promise((resolve, reject) => {
|
22
|
+
const httpOpt = {
|
23
|
+
url: '//chat.roblox.com/v2/update-user-typing-status',
|
24
|
+
options: {
|
25
|
+
method: 'POST',
|
26
|
+
jar: jar,
|
27
|
+
headers: {
|
28
|
+
'X-CSRF-TOKEN': token
|
29
|
+
},
|
30
|
+
json: {
|
31
|
+
conversationId: conversationId,
|
32
|
+
isTyping: isTyping
|
33
|
+
},
|
34
|
+
resolveWithFullResponse: true
|
35
|
+
}
|
36
|
+
}
|
37
|
+
return http(httpOpt).then((res) => {
|
38
|
+
if (res.statusCode === 200) {
|
39
|
+
if (!res.body.resultType === 'Success') {
|
40
|
+
reject(new Error(res.body.statusMessage))
|
41
|
+
} else {
|
42
|
+
resolve(res.body)
|
43
|
+
}
|
44
|
+
} else {
|
45
|
+
let error = 'An unknown error has occurred.'
|
46
|
+
if (res.body && res.body.errors) {
|
47
|
+
error = res.body.errors.map((e) => e.message).join('\n')
|
48
|
+
}
|
49
|
+
reject(new Error(error))
|
50
|
+
}
|
51
|
+
}).catch(error => reject(error))
|
52
|
+
})
|
53
|
+
}
|
54
|
+
|
55
|
+
exports.func = (args) => {
|
56
|
+
const jar = args.jar
|
57
|
+
|
58
|
+
return getGeneralToken({ jar: jar }).then((xcsrf) => {
|
59
|
+
return setChatUserTyping(args.conversationId, args.isTyping, jar, xcsrf)
|
60
|
+
})
|
61
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
const http = require('../util/http.js').func
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
3
|
+
|
4
|
+
exports.required = ['userId']
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 Start a conversation with another user.
|
10
|
+
* @category Chat
|
11
|
+
* @alias start121Conversation
|
12
|
+
* @param {number} userId - The id of the user.
|
13
|
+
* @returns {Promise<void>}
|
14
|
+
* @example const noblox = require("noblox.js")
|
15
|
+
* // Login using your cookie
|
16
|
+
* noblox.start121Conversation(1)
|
17
|
+
**/
|
18
|
+
|
19
|
+
const nextFunction = (jar, token, userId) => {
|
20
|
+
return http({
|
21
|
+
url: '//chat.roblox.com/v2/start-one-to-one-conversation',
|
22
|
+
options: {
|
23
|
+
method: 'POST',
|
24
|
+
jar: jar,
|
25
|
+
headers: {
|
26
|
+
'X-CSRF-TOKEN': token
|
27
|
+
},
|
28
|
+
json: {
|
29
|
+
participantUserId: userId
|
30
|
+
},
|
31
|
+
resolveWithFullResponse: true
|
32
|
+
}
|
33
|
+
}).then((res) => {
|
34
|
+
if (res.statusCode === 200) {
|
35
|
+
if (!res.body.resultType === 'Success') {
|
36
|
+
throw new Error(res.body.statusMessage)
|
37
|
+
}
|
38
|
+
} else {
|
39
|
+
throw new Error('Start conversation 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.userId)
|
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 = ['placeId']
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 Start a Cloud Edit/Team Create conversation.
|
10
|
+
* @category Chat
|
11
|
+
* @alias startCloudEditConversation
|
12
|
+
* @param {number} placeId - The id of the place.
|
13
|
+
* @returns {Promise<void>}
|
14
|
+
* @example const noblox = require("noblox.js")
|
15
|
+
* // Login using your cookie
|
16
|
+
* noblox.startCloudEditConversation(1117747196)
|
17
|
+
**/
|
18
|
+
|
19
|
+
const nextFunction = (jar, token, placeId) => {
|
20
|
+
return http({
|
21
|
+
url: '//chat.roblox.com/v2/start-cloud-edit-conversation',
|
22
|
+
options: {
|
23
|
+
method: 'POST',
|
24
|
+
jar: jar,
|
25
|
+
headers: {
|
26
|
+
'X-CSRF-TOKEN': token
|
27
|
+
},
|
28
|
+
json: {
|
29
|
+
placeId: placeId
|
30
|
+
},
|
31
|
+
resolveWithFullResponse: true
|
32
|
+
}
|
33
|
+
}).then((res) => {
|
34
|
+
if (res.statusCode === 200) {
|
35
|
+
if (!res.body.resultType === 'Success') {
|
36
|
+
throw new Error(res.body.statusMessage)
|
37
|
+
}
|
38
|
+
} else {
|
39
|
+
throw new Error('Start cloud edit chat 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.placeId)
|
49
|
+
})
|
50
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
const http = require('../util/http.js').func
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
3
|
+
|
4
|
+
exports.required = ['userIds', 'title']
|
5
|
+
exports.optional = ['jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 Start a group conversation.
|
10
|
+
* @category Chat
|
11
|
+
* @alias startGroupConversation
|
12
|
+
* @param {Array<number>} userIds - An array of userIds to add.
|
13
|
+
* @param {string} title - The title of the group.
|
14
|
+
* @returns {Promise<StartGroupConversationResponse>}
|
15
|
+
* @example const noblox = require("noblox.js")
|
16
|
+
* // Login using your cookie
|
17
|
+
* noblox.startGroupConversation([1, 2, 3], "A group conversation.")
|
18
|
+
**/
|
19
|
+
|
20
|
+
function startGroupConversation (userIds, chatTitle, jar, token) {
|
21
|
+
return new Promise((resolve, reject) => {
|
22
|
+
const httpOpt = {
|
23
|
+
url: '//chat.roblox.com/v2/start-group-conversation',
|
24
|
+
options: {
|
25
|
+
method: 'POST',
|
26
|
+
jar: jar,
|
27
|
+
headers: {
|
28
|
+
'X-CSRF-TOKEN': token
|
29
|
+
},
|
30
|
+
json: {
|
31
|
+
participantUserIds: userIds,
|
32
|
+
title: chatTitle
|
33
|
+
},
|
34
|
+
resolveWithFullResponse: true
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
return http(httpOpt).then((res) => {
|
39
|
+
if (res.statusCode === 200) {
|
40
|
+
if (!res.body.resultType === 'Success') {
|
41
|
+
reject(new Error(res.body.statusMessage))
|
42
|
+
} else {
|
43
|
+
resolve(res.body)
|
44
|
+
}
|
45
|
+
} else {
|
46
|
+
let error = 'An unknown error has occurred.'
|
47
|
+
if (res.body && res.body.errors) {
|
48
|
+
error = res.body.errors.map((e) => e.message).join('\n')
|
49
|
+
}
|
50
|
+
reject(new Error(error))
|
51
|
+
}
|
52
|
+
}).catch(error => reject(error))
|
53
|
+
})
|
54
|
+
}
|
55
|
+
|
56
|
+
exports.func = (args) => {
|
57
|
+
const jar = args.jar
|
58
|
+
|
59
|
+
return getGeneralToken({ jar: jar }).then((xcsrf) => {
|
60
|
+
return startGroupConversation(args.userIds, args.title, jar, xcsrf)
|
61
|
+
})
|
62
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
// Dependencies
|
2
|
+
const SignalR = require('signalr-client').client
|
3
|
+
const events = require('events')
|
4
|
+
|
5
|
+
// Includes
|
6
|
+
const getSession = require('../util/getSession.js').func
|
7
|
+
const settings = require('../../settings.json')
|
8
|
+
|
9
|
+
// Args
|
10
|
+
exports.optional = ['jar']
|
11
|
+
|
12
|
+
// Docs
|
13
|
+
/**
|
14
|
+
* 🔐 An event for when you get a notification.
|
15
|
+
* @category Client
|
16
|
+
* @alias onNotification
|
17
|
+
* @returns An EventEmitter that emits when you get a notification.
|
18
|
+
* @example const noblox = require("noblox.js")
|
19
|
+
* // Login using your cookie
|
20
|
+
* const notification = noblox.onNotification()
|
21
|
+
* notification.on("data", function(data) {
|
22
|
+
* console.log("New notification! ", data)
|
23
|
+
* })
|
24
|
+
* notification.on("error", function(err) {
|
25
|
+
* console.error("Something went wrong: ", err)
|
26
|
+
* // Handle error as needed
|
27
|
+
* })
|
28
|
+
**/
|
29
|
+
|
30
|
+
// Define
|
31
|
+
exports.func = function (args) {
|
32
|
+
const max = settings.event.maxRetries
|
33
|
+
const notifications = new events.EventEmitter()
|
34
|
+
function connect (retries) {
|
35
|
+
if (typeof args.jar === 'string') {
|
36
|
+
args.jar = { session: args.jar }
|
37
|
+
}
|
38
|
+
const session = getSession({ jar: args.jar })
|
39
|
+
const client = new SignalR('wss://realtime.roblox.com/notifications', ['usernotificationhub'], 3, true) // wss for https
|
40
|
+
client.headers.Cookie = '.ROBLOSECURITY=' + session + ';'
|
41
|
+
client.on('usernotificationhub', 'notification', function (name, message) {
|
42
|
+
notifications.emit('data', name, JSON.parse(message))
|
43
|
+
})
|
44
|
+
notifications.on('close', client.end)
|
45
|
+
client.serviceHandlers.connectFailed = function (err) {
|
46
|
+
notifications.emit('error', new Error('Connection failed: ' + err.message))
|
47
|
+
if (retries !== -1) {
|
48
|
+
if (retries > max) {
|
49
|
+
notifications.emit('close', new Error('Max retries reached'))
|
50
|
+
} else {
|
51
|
+
setTimeout(connect, 5000, retries + 1)
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
client.serviceHandlers.onerror = function (err) {
|
56
|
+
notifications.emit('error', err)
|
57
|
+
}
|
58
|
+
client.serviceHandlers.connected = function (connection) {
|
59
|
+
notifications.emit('connect', connection)
|
60
|
+
}
|
61
|
+
client.serviceHandlers.reconnecting = function () {
|
62
|
+
setTimeout(connect, 5000, 0)
|
63
|
+
notifications.emit('error', new Error('Lost connection, reconnecting'))
|
64
|
+
return true // Abort reconnection
|
65
|
+
}
|
66
|
+
client.start()
|
67
|
+
}
|
68
|
+
connect(-1)
|
69
|
+
return notifications
|
70
|
+
}
|