File tree 1 file changed +52
-0
lines changed
1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Includes
2
+ var http = require ( '../util/http.js' ) . func
3
+ var getGeneralToken = require ( '../util/getGeneralToken.js' ) . func
4
+
5
+ // Args
6
+ exports . required = [ 'userIds' ]
7
+ exports . optional = [ ]
8
+
9
+ // Define
10
+ function getPresences ( userIds , jar , xcsrf ) {
11
+ return new Promise ( ( resolve , reject ) => {
12
+ var httpOpt = {
13
+ url : '//presence.roblox.com/v1/presence/users' ,
14
+ options : {
15
+ method : 'POST' ,
16
+ resolveWithFullResponse : true ,
17
+ jar : jar ,
18
+ headers : {
19
+ 'X-CSRF-TOKEN' : xcsrf ,
20
+ 'Content-Type' : 'application/json'
21
+ } ,
22
+ body : JSON . stringify ( {
23
+ userIds
24
+ } )
25
+ }
26
+ }
27
+
28
+ return http ( httpOpt )
29
+ . then ( function ( res ) {
30
+ const responseData = JSON . parse ( res . body )
31
+ if ( res . statusCode !== 200 ) {
32
+ let error = 'An unknown error has occurred.'
33
+ if ( responseData && responseData . errors ) {
34
+ error = responseData . errors . map ( ( e ) => e . message ) . join ( '\n' )
35
+ }
36
+ reject ( new Error ( error ) )
37
+ } else {
38
+ resolve ( responseData )
39
+ }
40
+ } )
41
+ . catch ( error => reject ( error ) )
42
+ } )
43
+ }
44
+
45
+ exports . func = function ( args ) {
46
+ const jar = args . jar
47
+ return getGeneralToken ( { jar : jar } )
48
+ . then ( function ( xcsrf ) {
49
+ console . log ( args . userIds )
50
+ return getPresences ( args . userIds , args . jar , xcsrf )
51
+ } )
52
+ }
You can’t perform that action at this time.
0 commit comments