1
+ local HttpService = game :GetService ("HttpService" )
2
+
3
+ local Console = require (script .Parent .Parent .Packages .Console )
4
+ local Promise = require (script .Parent .Parent .Packages .Promise )
5
+
6
+ local ApiService = require (script .Parent .ApiService )
7
+
8
+ local ApiPaths = require (script .Parent .Parent .Data .ApiPaths )
9
+
10
+ local UserService = { }
11
+
12
+ UserService .Priority = 0
13
+ UserService .Reporter = Console .new (`{script .Name }` )
14
+
15
+ UserService .UserStore = {} :: { [number ]: User }
16
+
17
+ function UserService .GetUserAsync (self : UserService , userId : number )
18
+ return Promise .new (function (resolve , reject )
19
+ if self .UserStore [userId ] then
20
+ return resolve (self .UserStore [userId ])
21
+ end
22
+
23
+ ApiService :GetAsync (string.format (ApiPaths .GetUserInformation , ApiService .ProjectId , userId ), { }):andThen (function (response )
24
+ local userInformation = HttpService :JSONDecode (response .Body )
25
+
26
+ self .UserStore [userId ] = {
27
+ Description = userInformation .description ,
28
+ Created = DateTime .fromIsoDate (userInformation .created ),
29
+ IsBanned = userInformation .IsBanned ,
30
+ ExternalAppDisplayName = userInformation .ExternalAppDisplayName ,
31
+ HasVerifiedBadge = userInformation .HasVerifiedBadge ,
32
+ Id = userInformation .Id ,
33
+ Name = userInformation .Name ,
34
+ DisplayName = userInformation .DisplayName
35
+ }
36
+
37
+ resolve (self .UserStore [userId ])
38
+ end )
39
+
40
+ return
41
+ end )
42
+ end
43
+
44
+ export type UserService = typeof (UserService )
45
+ export type User = {
46
+ Description : string ,
47
+ Created : DateTime ,
48
+ IsBanned : boolean ,
49
+ ExternalAppDisplayName : string ? ,
50
+ HasVerifiedBadge : boolean ,
51
+ Id : number ,
52
+ Name : string ,
53
+ DisplayName : string
54
+ }
55
+
56
+ return UserService
0 commit comments