Skip to content

Commit fe017dd

Browse files
committed
feat(structures): add connection and reorganize
1 parent ac28aed commit fe017dd

File tree

4 files changed

+82
-3
lines changed

4 files changed

+82
-3
lines changed

packages/structures/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './users';
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import type { APIConnection } from 'discord-api-types/v10';
2+
3+
/**
4+
* Represents a user's connection on Discord.
5+
*/
6+
export class Connection {
7+
public constructor(
8+
/**
9+
* The raw data received from the API for the connection
10+
*/
11+
protected raw: APIConnection,
12+
) {}
13+
14+
/**
15+
* The id of the connection account
16+
*/
17+
public get id() {
18+
return this.raw.id;
19+
}
20+
21+
/**
22+
* The username of the connection account
23+
*/
24+
public get name() {
25+
return this.raw.name;
26+
}
27+
28+
/**
29+
* The type of service this connection is for
30+
*/
31+
public get type() {
32+
return this.raw.type;
33+
}
34+
35+
/**
36+
* Whether the connection is revoked
37+
*/
38+
public get revoked() {
39+
return this.raw.revoked ?? false;
40+
}
41+
42+
/**
43+
* Any integrations associated with this connection
44+
*/
45+
public get integrations() {
46+
return this.raw.integrations ?? null;
47+
}
48+
49+
/**
50+
* Whether the connection is verified
51+
*/
52+
public get verified() {
53+
return this.raw.verified;
54+
}
55+
56+
/**
57+
* Whether friend sync is enabled for this connection
58+
*/
59+
public get friendSync() {
60+
return this.raw.friend_sync;
61+
}
62+
63+
/**
64+
* Whether activities related to this connection are shown in the users presence
65+
*/
66+
public get showActivity() {
67+
return this.raw.show_activity;
68+
}
69+
70+
/**
71+
* The visibilty state for this connection
72+
*/
73+
public get visibility() {
74+
return this.raw.visibility;
75+
}
76+
}

packages/structures/src/User.ts renamed to packages/structures/src/users/User.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ export class User {
4444
* Whether or not the user is a bot
4545
*/
4646
public get bot() {
47-
return Boolean(this.raw.bot);
47+
return this.raw.bot ?? false;
4848
}
4949

5050
/**
5151
* Whether the user is an Official Discord System user
5252
*/
5353
public get system() {
54-
return Boolean(this.raw.system);
54+
return this.raw.system ?? false;
5555
}
5656

5757
/**
@@ -79,7 +79,7 @@ export class User {
7979
}
8080

8181
/**
82-
* Whether the user has mfa enabled
82+
* The user's primary discord language
8383
* <info>This property is only set when the user was fetched with an Oauth2 token and the `identify` scope</info>
8484
*/
8585
public get locale() {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './Connection';
2+
export * from './User';

0 commit comments

Comments
 (0)