diff --git a/API/src/main/java/me/braydon/tether/model/user/CustomStatus.java b/API/src/main/java/me/braydon/tether/model/user/CustomStatus.java index 0598aa3..2838a56 100644 --- a/API/src/main/java/me/braydon/tether/model/user/CustomStatus.java +++ b/API/src/main/java/me/braydon/tether/model/user/CustomStatus.java @@ -22,7 +22,7 @@ public class CustomStatus { @NonNull private final String value; /** - * The unicode emoji for this status. + * The unicode emoji for this status, null if none. */ private final String emoji; diff --git a/API/src/main/java/me/braydon/tether/model/user/avatar/DecorationAsset.java b/API/src/main/java/me/braydon/tether/model/user/avatar/DecorationAsset.java index 5421993..06e814f 100644 --- a/API/src/main/java/me/braydon/tether/model/user/avatar/DecorationAsset.java +++ b/API/src/main/java/me/braydon/tether/model/user/avatar/DecorationAsset.java @@ -14,12 +14,12 @@ public class DecorationAsset { private static final String DECORATION_URL = "https://cdn.discordapp.com/avatar-decoration-presets/%s.png"; /** - * The id of the clan badge. + * The id of this decoration asset. */ @NonNull private final String id; /** - * The URL of the clan badge. + * The URL of this decoration asset. */ @NonNull private final String url; diff --git a/use-tether/src/hook/websocket.ts b/use-tether/src/hook/websocket.ts index 8c52220..5307f3d 100644 --- a/use-tether/src/hook/websocket.ts +++ b/use-tether/src/hook/websocket.ts @@ -1,8 +1,8 @@ import { useEffect, useState } from "react"; import { Snowflake } from "@/types/snowflake"; import { TetherConfig } from "@/types/config"; -import { DiscordUser } from "@/types/user"; import { UserStatusPacket } from "@/types/socket"; +import { DiscordUser } from "@/types/user/discord-user"; /** * Connect to the WebSocket and listen diff --git a/use-tether/src/index.ts b/use-tether/src/index.ts index 4c9ccdc..721f258 100644 --- a/use-tether/src/index.ts +++ b/use-tether/src/index.ts @@ -4,4 +4,4 @@ export * from "@/hook/websocket"; // Types export * from "@/types/config"; export * from "@/types/snowflake"; -export * from "@/types/user"; +export * from "@/types/user/user"; diff --git a/use-tether/src/types/socket.ts b/use-tether/src/types/socket.ts index ad7fd20..47f3401 100644 --- a/use-tether/src/types/socket.ts +++ b/use-tether/src/types/socket.ts @@ -1,4 +1,4 @@ -import { DiscordUser } from "@/types/user"; +import { DiscordUser } from "@/types/user/user"; type SocketPacket = { /** diff --git a/use-tether/src/types/user.ts b/use-tether/src/types/user.ts deleted file mode 100644 index 6ffd4ff..0000000 --- a/use-tether/src/types/user.ts +++ /dev/null @@ -1,178 +0,0 @@ -export type DiscordUser = { - /** - * The unique snowflake of this user. - */ - snowflake: number; - - /** - * The username of this user. - */ - username: string; - - /** - * The display name of this user, if any. - */ - displayName: string | undefined; - - /** - * The flags of this user. - */ - flags: UserFlags; - - /** - * The avatar of this user. - */ - avatar: Avatar; - - /** - * The banner of this user, if any. - */ - banner: Banner | undefined; - - /** - * The accent color of this user. - */ - accentColor: string; - - /** - * The online status of this user, if known. - */ - onlineStatus: "ONLINE" | "IDLE" | "DO_NOT_DISTURB" | "OFFLINE"; - - /** - * The clients this user is active on, if known. - */ - activeClients: "DESKTOP" | "MOBILE" | "WEB" | undefined; - - /** - * The Spotify activity of this user, if known. - */ - spotify: SpotifyActivity | undefined; - - /** - * Is this user a bot? - */ - bot: boolean; - - /** - * The unix time of when this user joined Discord. - */ - createdAt: number; -}; - -/** - * A user's flags. - */ -export type UserFlags = { - /** - * The list of flags the user has. - */ - list: ( - | "STAFF" - | "PARTNER" - | "HYPESQUAD" - | "BUG_HUNTER_LEVEL_1" - | "HYPESQUAD_BRAVERY" - | "HYPESQUAD_BRILLIANCE" - | "HYPESQUAD_BALANCE" - | "EARLY_SUPPORTER" - | "TEAM_USER" - | "BUGHUNTER_LEVEL_2" - | "VERIFIED_BOT" - | "VERIFIED_DEVELOPER" - | "CERTIFIED_MODERATOR" - | "BOT_HTTP_INTERACTIONS" - | "ACTIVE_DEVELOPER" - | "UNKNOWN" - )[]; - - /** - * The raw flags the user has. - */ - raw: number; -}; - -/** - * A user's avatar. - */ -export type Avatar = { - /** - * The id of the user's avatar. - */ - id: string; - - /** - * The URL of the user's avatar. - */ - url: string; -}; - -/** - * A user's banner. - */ -export type Banner = { - /** - * The id of the user's avatar. - */ - id: string; - - /** - * The URL of the user's avatar. - */ - url: string; -}; - -/** - * A user's Spotify activity data. - */ -export type SpotifyActivity = { - /** - * The ID of the currently playing track. - */ - trackId: string; - - /** - * The name of the currently playing track. - */ - song: string; - - /** - * The currently playing artist. - */ - artist: string; - - /** - * The album the song is from. - */ - album: string; - - /** - * The URL to the art for the currently playing album. - */ - albumArtUrl: string; - - /** - * The URL to the playing track. - */ - trackUrl: string; - - /** - * The current progress of the track (in millis). - */ - trackProgress: number; - - /** - * The total length of the track (in millis). - */ - trackLength: number; - - /** - * The unix time of when this track started playing. - */ - started: number; - - /** - * The unix time of when this track stops playing. - */ - ends: number; -}; diff --git a/use-tether/src/types/user/avatar/avatar-decoration.ts b/use-tether/src/types/user/avatar/avatar-decoration.ts new file mode 100644 index 0000000..2cfd3da --- /dev/null +++ b/use-tether/src/types/user/avatar/avatar-decoration.ts @@ -0,0 +1,21 @@ +import { DecorationAsset } from "@/types/user/avatar/decoration-asset"; + +/** + * The decoration for a {@link Avatar}. + */ +export type AvatarDecoration = { + /** + * The asset of this decoration. + */ + asset: DecorationAsset; + + /** + * The id of the decoration sku. + */ + skuId: string; + + /** + * The unix time of when this decorations expires, undefined if permanent. + */ + expires: number | undefined; +}; diff --git a/use-tether/src/types/user/avatar/avatar.ts b/use-tether/src/types/user/avatar/avatar.ts new file mode 100644 index 0000000..c1986ed --- /dev/null +++ b/use-tether/src/types/user/avatar/avatar.ts @@ -0,0 +1,14 @@ +/** + * An avatar for a {@link DiscordUser}. + */ +export type Avatar = { + /** + * The id of the user's avatar. + */ + id: string; + + /** + * The URL of the user's avatar. + */ + url: string; +}; diff --git a/use-tether/src/types/user/avatar/decoration-asset.ts b/use-tether/src/types/user/avatar/decoration-asset.ts new file mode 100644 index 0000000..e763101 --- /dev/null +++ b/use-tether/src/types/user/avatar/decoration-asset.ts @@ -0,0 +1,14 @@ +/** + * The decoration asset for a {@link AvatarDecoration}. + */ +export type DecorationAsset = { + /** + * The id of this decoration asset. + */ + id: string; + + /** + * The URL of this decoration asset. + */ + url: string; +}; diff --git a/use-tether/src/types/user/badge/user-badge-icon.ts b/use-tether/src/types/user/badge/user-badge-icon.ts new file mode 100644 index 0000000..180f6a9 --- /dev/null +++ b/use-tether/src/types/user/badge/user-badge-icon.ts @@ -0,0 +1,14 @@ +/** + * The icon of a {@link UserBadge}. + */ +export type UserBadgeIcon = { + /** + * The id of the user's badge. + */ + id: string; + + /** + * The URL of the user's badge. + */ + url: string; +}; diff --git a/use-tether/src/types/user/badge/user-badge.ts b/use-tether/src/types/user/badge/user-badge.ts new file mode 100644 index 0000000..0fedd18 --- /dev/null +++ b/use-tether/src/types/user/badge/user-badge.ts @@ -0,0 +1,26 @@ +import { UserBadgeIcon } from "@/types/user/badge/user-badge-icon"; + +/** + * The badge of a {@link DiscordUser}. + */ +export type UserBadge = { + /** + * The id of this user badge. + */ + id: string; + + /** + * The description of this user badge. + */ + description: string; + + /** + * The icon of this user badge. + */ + icon: UserBadgeIcon; + + /** + * The link to this user badge, if any. + */ + link: string | undefined; +}; diff --git a/use-tether/src/types/user/banner.ts b/use-tether/src/types/user/banner.ts new file mode 100644 index 0000000..091c4bd --- /dev/null +++ b/use-tether/src/types/user/banner.ts @@ -0,0 +1,14 @@ +/** + * A banner for a {@link DiscordUser}. + */ +export type Banner = { + /** + * The id of the user's avatar. + */ + id: string; + + /** + * The URL of the user's avatar. + */ + url: string; +}; diff --git a/use-tether/src/types/user/clan/clan-badge.ts b/use-tether/src/types/user/clan/clan-badge.ts new file mode 100644 index 0000000..505d095 --- /dev/null +++ b/use-tether/src/types/user/clan/clan-badge.ts @@ -0,0 +1,14 @@ +/** + * The badge of a {@link Clan}. + */ +export type ClanBadge = { + /** + * The id of the clan badge. + */ + id: string; + + /** + * The URL of the clan badge. + */ + url: string; +}; diff --git a/use-tether/src/types/user/clan/clan.ts b/use-tether/src/types/user/clan/clan.ts new file mode 100644 index 0000000..96d5d29 --- /dev/null +++ b/use-tether/src/types/user/clan/clan.ts @@ -0,0 +1,26 @@ +import { ClanBadge } from "@/types/user/clan/clan-badge"; + +/** + * A clan a {@link DiscordUser} is in. + */ +export type Clan = { + /** + * The snowflake of the Guild this clan belongs to. + */ + guildSnowflake: number; + + /** + * The tag of this clan. + */ + tag: string; + + /** + * The badge for this clan. + */ + clanBadge: ClanBadge; + + /** + * Whether the identity is enabled for this clan. + */ + identityEnabled: boolean; +}; diff --git a/use-tether/src/types/user/connected-account.ts b/use-tether/src/types/user/connected-account.ts new file mode 100644 index 0000000..df6ff25 --- /dev/null +++ b/use-tether/src/types/user/connected-account.ts @@ -0,0 +1,31 @@ +/** + * A connected account of a {@link DiscordUser}. + */ +export type ConnectedAccount = { + /** + * The id of this account. + */ + id: string; + + /** + * The type of this account. + */ + type: string; + + /** + * The name of this account. + */ + name: string; + + /** + * The metadata for this account. + */ + metadata: { + [key: string]: string; + }; + + /** + * Whether this account is verified. + */ + verified: boolean; +}; diff --git a/use-tether/src/types/user/custom-status.ts b/use-tether/src/types/user/custom-status.ts new file mode 100644 index 0000000..eed2294 --- /dev/null +++ b/use-tether/src/types/user/custom-status.ts @@ -0,0 +1,14 @@ +/** + * The custom status of a {@link DiscordUser}. + */ +export type CustomStatus = { + /** + * The value of this status. + */ + value: string; + + /** + * The unicode emoji for this status, undefined if none. + */ + emoji: string | undefined; +}; diff --git a/use-tether/src/types/user/discord-user.ts b/use-tether/src/types/user/discord-user.ts new file mode 100644 index 0000000..35823da --- /dev/null +++ b/use-tether/src/types/user/discord-user.ts @@ -0,0 +1,127 @@ +import { UserFlags } from "@/types/user/user-flags"; +import { Avatar } from "@/types/user/avatar/avatar"; +import { Banner } from "@/types/user/banner"; +import { AvatarDecoration } from "@/types/user/avatar/avatar-decoration"; +import { CustomStatus } from "@/types/user/custom-status"; +import { SpotifyActivity } from "@/types/user/spotify-activity"; +import { UserBadge } from "@/types/user/badge/user-badge"; +import { ConnectedAccount } from "@/types/user/connected-account"; +import { Clan } from "@/types/user/clan/clan"; +import { NitroSubscription } from "@/types/user/nitro-subscription"; + +export type DiscordUser = { + /** + * The unique snowflake of this user. + */ + snowflake: number; + + /** + * The username of this user. + */ + username: string; + + /** + * This user's legacy username, if any. + */ + legacyUsername: string | undefined; + + /** + * The display name of this user, if any. + */ + displayName: string | undefined; + + /** + * The user's discriminator, 0 if not legacy. + */ + discriminator: number; + + /** + * The flags of this user. + */ + flags: UserFlags; + + /** + * The avatar of this user. + */ + avatar: Avatar; + + /** + * The avatar decoration of this user, if any. + */ + avatarDecoration: AvatarDecoration | undefined; + + /** + * The banner of this user, if any. + */ + banner: Banner | undefined; + + /** + * The banner color (hex) of this user, if any. + */ + bannerColor: string | undefined; + + /** + * The custom status of this user, if any. + */ + customStatus: CustomStatus | undefined; + + /** + * The user's bio, if any. + */ + bio: string | undefined; + + /** + * The user's pronouns, if any. + */ + pronouns: string | undefined; + + /** + * The accent color of this user. + */ + accentColor: string; + + /** + * The online status of this user, if known. + */ + onlineStatus: "ONLINE" | "IDLE" | "DO_NOT_DISTURB" | "OFFLINE"; + + /** + * The clients this user is active on, if known. + */ + activeClients: "DESKTOP" | "MOBILE" | "WEB" | undefined; + + /** + * The Spotify activity of this user, if known. + */ + spotify: SpotifyActivity | undefined; + + /** + * The badges this user has. + */ + badges: UserBadge[]; + + /** + * The connected accounts of this user. + */ + connectedAccounts: ConnectedAccount[]; + + /** + * The clan this user is in, if any. + */ + clan: Clan | undefined; + + /** + * This user's Nitro subscription, if any. + */ + nitroSubscription: NitroSubscription | undefined; + + /** + * Is this user a bot? + */ + bot: boolean; + + /** + * The unix time of when this user joined Discord. + */ + createdAt: number; +}; diff --git a/use-tether/src/types/user/nitro-subscription.ts b/use-tether/src/types/user/nitro-subscription.ts new file mode 100644 index 0000000..4cce954 --- /dev/null +++ b/use-tether/src/types/user/nitro-subscription.ts @@ -0,0 +1,14 @@ +/** + * A Nitro subscription for a {@link DiscordUser}. + */ +export type NitroSubscription = { + /** + * The type of this subscription. + */ + type: "CLASSIC" | "NITRO" | "BASIC" | "UNKNOWN"; + + /** + * The unix time this subscription was started. + */ + subscribed: number; +}; diff --git a/use-tether/src/types/user/spotify-activity.ts b/use-tether/src/types/user/spotify-activity.ts new file mode 100644 index 0000000..321dab9 --- /dev/null +++ b/use-tether/src/types/user/spotify-activity.ts @@ -0,0 +1,54 @@ +/** + * The Spotify activity for a {@link DiscordUser}. + */ +export type SpotifyActivity = { + /** + * The ID of the currently playing track. + */ + trackId: string; + + /** + * The name of the currently playing track. + */ + song: string; + + /** + * The currently playing artist. + */ + artist: string; + + /** + * The album the song is from. + */ + album: string; + + /** + * The URL to the art for the currently playing album. + */ + albumArtUrl: string; + + /** + * The URL to the playing track. + */ + trackUrl: string; + + /** + * The current progress of the track (in millis). + */ + trackProgress: number; + + /** + * The total length of the track (in millis). + */ + trackLength: number; + + /** + * The unix time of when this track started playing. + */ + started: number; + + /** + * The unix time of when this track stops playing. + */ + ends: number; +}; diff --git a/use-tether/src/types/user/user-flags.ts b/use-tether/src/types/user/user-flags.ts new file mode 100644 index 0000000..61761d4 --- /dev/null +++ b/use-tether/src/types/user/user-flags.ts @@ -0,0 +1,31 @@ +/** + * The flags of a {@link DiscordUser}. + */ +export type UserFlags = { + /** + * The list of flags the user has. + */ + list: ( + | "STAFF" + | "PARTNER" + | "HYPESQUAD" + | "BUG_HUNTER_LEVEL_1" + | "HYPESQUAD_BRAVERY" + | "HYPESQUAD_BRILLIANCE" + | "HYPESQUAD_BALANCE" + | "EARLY_SUPPORTER" + | "TEAM_USER" + | "BUGHUNTER_LEVEL_2" + | "VERIFIED_BOT" + | "VERIFIED_DEVELOPER" + | "CERTIFIED_MODERATOR" + | "BOT_HTTP_INTERACTIONS" + | "ACTIVE_DEVELOPER" + | "UNKNOWN" + )[]; + + /** + * The raw flags the user has. + */ + raw: number; +};