diff --git a/packages/structures/src/users/Connection.ts b/packages/structures/src/users/Connection.ts new file mode 100644 index 000000000000..8b4baba3e592 --- /dev/null +++ b/packages/structures/src/users/Connection.ts @@ -0,0 +1,89 @@ +import type { APIConnection } from 'discord-api-types/v10'; +import { Structure } from '../Structure.js'; +import { kData } from '../utils/symbols.js'; + +/** + * Represents a user's connection on Discord. + */ +export class Connection extends Structure { + /** + * The template used for removing data from the raw data stored for each Connection + */ + public static DataTemplate: Partial = {}; + + public constructor( + /** + * The raw data received from the API for the connection + */ + data: Omit, + ) { + super(data, { template: Connection.DataTemplate }); + } + + public override _patch(data: Partial) { + return super._patch(data, { template: Connection.DataTemplate }); + } + + /** + * The id of the connection account + */ + public get id() { + return this[kData].id; + } + + /** + * The username of the connection account + */ + public get name() { + return this[kData].name; + } + + /** + * The type of service this connection is for + */ + public get type() { + return this[kData].type; + } + + /** + * Whether the connection is revoked + */ + public get revoked() { + return this[kData].revoked ?? false; + } + + /** + * Whether the connection is verified + */ + public get verified() { + return this[kData].verified; + } + + /** + * Whether friend sync is enabled for this connection + */ + public get friendSync() { + return this[kData].friend_sync; + } + + /** + * Whether activities related to this connection are shown in the users presence + */ + public get showActivity() { + return this[kData].show_activity; + } + + /** + * Whether this connection has an Oauth2 token for console voice transfer + */ + public get twoWayLink() { + return this[kData].two_way_link; + } + + /** + * The visibilty state for this connection + */ + public get visibility() { + return this[kData].visibility; + } +}