diff --git a/packages/structures/src/index.ts b/packages/structures/src/index.ts index e69de29bb2d1d..b18bf4caef965 100644 --- a/packages/structures/src/index.ts +++ b/packages/structures/src/index.ts @@ -0,0 +1 @@ +export * from './users'; diff --git a/packages/structures/src/users/Connection.ts b/packages/structures/src/users/Connection.ts new file mode 100644 index 0000000000000..703d0c736d815 --- /dev/null +++ b/packages/structures/src/users/Connection.ts @@ -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; + } +} diff --git a/packages/structures/src/User.ts b/packages/structures/src/users/User.ts similarity index 96% rename from packages/structures/src/User.ts rename to packages/structures/src/users/User.ts index 286f3a2916a03..4d1beb22d9ce8 100644 --- a/packages/structures/src/User.ts +++ b/packages/structures/src/users/User.ts @@ -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; } /** @@ -79,7 +79,7 @@ export class User { } /** - * Whether the user has mfa enabled + * The user's primary discord language * This property is only set when the user was fetched with an Oauth2 token and the `identify` scope */ public get locale() { diff --git a/packages/structures/src/users/index.ts b/packages/structures/src/users/index.ts new file mode 100644 index 0000000000000..9e5646ccd73c8 --- /dev/null +++ b/packages/structures/src/users/index.ts @@ -0,0 +1,2 @@ +export * from './Connection'; +export * from './User';