1
1
const { ActivityFlags, Endpoints } = require ( '../util/Constants' ) ;
2
2
3
+ /**
4
+ * The status of this presence:
5
+ *
6
+ * * **`online`** - user is online
7
+ * * **`idle`** - user is AFK
8
+ * * **`offline`** - user is offline or invisible
9
+ * * **`dnd`** - user is in Do Not Disturb
10
+ * @typedef {string } PresenceStatus
11
+ */
12
+
3
13
/**
4
14
* Represents a user's presence.
5
15
*/
@@ -8,13 +18,8 @@ class Presence {
8
18
Object . defineProperty ( this , 'client' , { value : client } ) ;
9
19
10
20
/**
11
- * The status of the presence:
12
- *
13
- * * **`online`** - user is online
14
- * * **`offline`** - user is offline or invisible
15
- * * **`idle`** - user is AFK
16
- * * **`dnd`** - user is in Do not Disturb
17
- * @type {string }
21
+ * The status of this presence:
22
+ * @type {PresenceStatus }
18
23
*/
19
24
this . status = data . status || 'offline' ;
20
25
@@ -23,11 +28,21 @@ class Presence {
23
28
* @type {?Game }
24
29
*/
25
30
this . game = data . game ? new Game ( data . game , this ) : null ;
31
+
32
+ /**
33
+ * The devices this presence is on
34
+ * @type {?object }
35
+ * @property {PresenceStatus } web
36
+ * @property {PresenceStatus } mobile
37
+ * @property {PresenceStatus } desktop
38
+ */
39
+ this . clientStatus = data . client_status || null ;
26
40
}
27
41
28
42
update ( data ) {
29
43
this . status = data . status || this . status ;
30
44
this . game = data . game ? new Game ( data . game , this ) : null ;
45
+ this . clientStatus = data . client_status || null ;
31
46
}
32
47
33
48
/**
@@ -39,7 +54,10 @@ class Presence {
39
54
return this === presence || (
40
55
presence &&
41
56
this . status === presence . status &&
42
- this . game ? this . game . equals ( presence . game ) : ! presence . game
57
+ ( this . game ? this . game . equals ( presence . game ) : ! presence . game ) &&
58
+ this . clientStatus . web === presence . clientStatus . web &&
59
+ this . clientStatus . mobile === presence . clientStatus . mobile &&
60
+ this . clientStatus . desktop === presence . clientStatus . desktop
43
61
) ;
44
62
}
45
63
}
0 commit comments