Skip to content

Commit

Permalink
feat(structures): add connection and reorganize
Browse files Browse the repository at this point in the history
  • Loading branch information
ckohen committed Aug 3, 2022
1 parent ac28aed commit fe017dd
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/structures/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './users';
76 changes: 76 additions & 0 deletions packages/structures/src/users/Connection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import type { APIConnection } from 'discord-api-types/v10';

/**
* Represents a user's connection on Discord.
*/
export class Connection {
public constructor(
/**
* The raw data received from the API for the connection
*/
protected raw: APIConnection,
) {}

/**
* The id of the connection account
*/
public get id() {
return this.raw.id;
}

/**
* The username of the connection account
*/
public get name() {
return this.raw.name;
}

/**
* The type of service this connection is for
*/
public get type() {
return this.raw.type;
}

/**
* Whether the connection is revoked
*/
public get revoked() {
return this.raw.revoked ?? false;
}

/**
* Any integrations associated with this connection
*/
public get integrations() {
return this.raw.integrations ?? null;
}

/**
* Whether the connection is verified
*/
public get verified() {
return this.raw.verified;
}

/**
* Whether friend sync is enabled for this connection
*/
public get friendSync() {
return this.raw.friend_sync;
}

/**
* Whether activities related to this connection are shown in the users presence
*/
public get showActivity() {
return this.raw.show_activity;
}

/**
* The visibilty state for this connection
*/
public get visibility() {
return this.raw.visibility;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ export class User {
* Whether or not the user is a bot
*/
public get bot() {
return Boolean(this.raw.bot);
return this.raw.bot ?? false;
}

/**
* Whether the user is an Official Discord System user
*/
public get system() {
return Boolean(this.raw.system);
return this.raw.system ?? false;
}

/**
Expand Down Expand Up @@ -79,7 +79,7 @@ export class User {
}

/**
* Whether the user has mfa enabled
* The user's primary discord language
* <info>This property is only set when the user was fetched with an Oauth2 token and the `identify` scope</info>
*/
public get locale() {
Expand Down
2 changes: 2 additions & 0 deletions packages/structures/src/users/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './Connection';
export * from './User';

0 comments on commit fe017dd

Please sign in to comment.