diff --git a/src/types/channels/channel_pins_update.ts b/src/types/channels/channel_pins_update.ts new file mode 100644 index 000000000..df38298c3 --- /dev/null +++ b/src/types/channels/channel_pins_update.ts @@ -0,0 +1,13 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface ChannelPinsUpdate { + /** The id of the guild */ + guildId?: string; + /** The id of the channel */ + channelId: string; + /** The time at which the most recent pinned message was pinned */ + lastPinTimestamp?: string | null; +} + +/** https://discord.com/developers/docs/topics/gateway#channel-pins-update */ +export type DiscordChannelPinsUpdate = SnakeCaseProps; diff --git a/src/types/emojis/guild_emojis_update.ts b/src/types/emojis/guild_emojis_update.ts new file mode 100644 index 000000000..2889278ad --- /dev/null +++ b/src/types/emojis/guild_emojis_update.ts @@ -0,0 +1,12 @@ +import { Emoji } from "../emojis/emoji.ts"; +import { SnakeCaseProps } from "../util.ts"; + +/** https://discord.com/developers/docs/topics/gateway#guild-emojis-update */ +export interface GuildEmojisUpdate { + /** id of the guild */ + guild_id: string; + /** Array of emojis */ + emojis: Emoji[]; +} + +export type DiscordGuildEmojisUpdate = SnakeCaseProps; diff --git a/src/types/gateway.ts b/src/types/gateway.ts deleted file mode 100644 index bd992bed2..000000000 --- a/src/types/gateway.ts +++ /dev/null @@ -1,583 +0,0 @@ -/** https://discord.com/developers/docs/topics/gateway#payloads-gateway-payload-structure */ -export interface DiscordGatewayPayload { - /** opcode for the payload */ - op: number; - /** Event data */ - d: unknown | null; - /** Sequence number, used for resuming sessions and heartbeats */ - s: number | null; - /** The event name for this payload */ - t: string | null; -} - -/** https://discord.com/developers/docs/topics/gateway#connecting-gateway-url-params */ -export interface DiscordGatewayURLParams { - /** Gateway version to use */ - v: string; - /** The encoding of received gateway packets */ - encoding: string; - /** The (optional) compression of gateway packets */ - compress?: string; -} - -/** https://discord.com/developers/docs/topics/gateway#gateway-intents */ -export enum DiscordGatewayIntents { - /** - * - GUILD_CREATE - * - GUILD_UPDATE - * - GUILD_DELETE - * - GUILD_ROLE_CREATE - * - GUILD_ROLE_UPDATE - * - GUILD_ROLE_DELETE - * - CHANNEL_CREATE - * - CHANNEL_UPDATE - * - CHANNEL_DELETE - * - CHANNEL_PINS_UPDATE - */ - GUILDS = 1 << 0, - /** - * - GUILD_MEMBER_ADD - * - GUILD_MEMBER_UPDATE - * - GUILD_MEMBER_REMOVE - */ - GUILD_MEMBERS = 1 << 1, - /** - * - GUILD_BAN_ADD - * - GUILD_BAN_REMOVE - */ - GUILD_BANS = 1 << 2, - /** - GUILD_EMOJIS_UPDATE */ - GUILD_EMOJIS = 1 << 3, - /** - GUILD_INTEGRATIONS_UPDATE */ - GUILD_INTEGRATIONS = 1 << 4, - /** - WEBHOOKS_UPDATE */ - GUILD_WEBHOOKS = 1 << 5, - /** - * - INVITE_CREATE - * - INVITE_DELETE - */ - GUILD_INVITES = 1 << 6, - /** - VOICE_STATE_UPDATE */ - GUILD_VOICE_STATES = 1 << 7, - /** - PRESENCE_UPDATE */ - GUILD_PRESENCES = 1 << 8, - /** - * - MESSAGE_CREATE - * - MESSAGE_UPDATE - * - MESSAGE_DELETE - * - MESSAGE_DELETE_BULK - */ - GUILD_MESSAGES = 1 << 9, - /** - * - MESSAGE_REACTION_ADD - * - MESSAGE_REACTION_REMOVE - * - MESSAGE_REACTION_REMOVE_ALL - * - MESSAGE_REACTION_REMOVE_EMOJI - */ - GUILD_MESSAGE_REACTIONS = 1 << 10, - /** - TYPING_START */ - GUILD_MESSAGE_TYPING = 1 << 11, - /** - * - MESSAGE_CREATE - * - MESSAGE_UPDATE - * - MESSAGE_DELETE - * - CHANNEL_PINS_UPDATE - */ - DIRECT_MESSAGES = 1 << 12, - /** - * - MESSAGE_REACTION_ADD - * - MESSAGE_REACTION_REMOVE - * - MESSAGE_REACTION_REMOVE_ALL - * - MESSAGE_REACTION_REMOVE_EMOJI - */ - DIRECT_MESSAGE_REACTIONS = 1 << 13, - /** - TYPING_START */ - DIRECT_MESSAGE_TYPING = 1 << 14, -} - -/** https://discord.com/developers/docs/topics/gateway#identify */ -export interface DiscordIdentify { - /** Authentication token */ - token: string; - /** Connection properties */ - properties: DiscordIdentifyConnectionProperties; - /** Whether this connection supports compression of packets */ - compress?: boolean; - /** Value between 50 and 250, total number of members where the gateway will stop sending offline members in the guild member list */ - large_threshold?: number; - /** Used for Guild Sharding */ - shard?: [number, number]; - /** Presence structure for initial presence information */ - presence?: DiscordUpdateStatus; - /** Enables dispatching of guild subscription events (presence and typing events) */ - guild_subscriptions?: boolean; - /** The Gateway Intents you wish to receive */ - intents: number; -} - -/** https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties */ -export interface DiscordIdentifyConnectionProperties { - /** Operating system */ - $os: string; - /** Library name */ - $browser: string; - /** Library name */ - $device: string; -} - -/** https://discord.com/developers/docs/topics/gateway#resume */ -export interface DiscordResume { - /** Session token */ - token: string; - /** Session id */ - session_id: string; - /** Last sequence number received */ - seq: number; -} - -/** https://discord.com/developers/docs/topics/gateway#request-guild-members */ -export interface DiscordRequestGuildMembers { - /** id of the guild to get members for */ - guild_id: string; - /** String that username starts with, or an empty string to return all members */ - query?: string; - /** Maximum number of members to send matching the query; a limit of 0 can be used with an empty string query to return all members */ - limit: number; - /** Used to specify if we want the presences of the matched members */ - presences?: boolean; - /** Used to specify which users you wish to fetch */ - user_ids?: string[]; - /** Nonce to identify the Guild Members Chunk response */ - nonce?: string; -} - -/** https://discord.com/developers/docs/topics/gateway#update-voice-state */ -export interface DiscordUpdateVoiceState { - /** id of the guild */ - guild_id: string; - /** id of the voice channel client wants to join (null if disconnecting) */ - channel_id: string | null; - /** Is the client muted */ - self_mute: boolean; - /** Is the client deafened */ - self_deaf: boolean; -} - -/** https://discord.com/developers/docs/topics/gateway#update-status */ -export interface DiscordUpdateStatus { - /** Unix time (in milliseconds) of when the client went idle, or null if the client is not idle */ - since: number | null; - /** null, or the user's activities */ - activities: DiscordActivity[] | null; - /** The user's new status */ - status: DiscordStatusTypes; - /** Whether or not the client is afk */ - afk: boolean; -} - -/** https://discord.com/developers/docs/topics/gateway#update-status-status-types */ -export type DiscordStatusTypes = - | "online" - | "dnd" - | "idle" - | "invisible" - | "offline"; - -/** https://discord.com/developers/docs/topics/gateway#hello */ -export interface DiscordHello { - /** The interval (in milliseconds) the client should heartbeat with */ - heartbeat_interval: number; -} - -/** https://discord.com/developers/docs/topics/gateway#ready */ -export interface DiscordReady { - /** Gateway version */ - v: number; - /** Information about the user including email */ - user: DiscordUser; - /** Empty array */ - private_channels: []; - /** The guilds the user is in */ - guilds: DiscordUnavailableGuild[]; - /** Used for resuming connections */ - session_id: string; - /** The shard information associated with this session, if sent when identifying */ - shard?: [number, number]; - /** Contains id and flags */ - application: - & Partial - & Pick; -} - -/** https://discord.com/developers/docs/topics/gateway#channel-pins-update */ -export interface DiscordChannelPinsUpdate { - /** The id of the guild */ - guild_id?: string; - /** The id of the channel */ - channel_id: string; - /** The time at which the most recent pinned message was pinned */ - last_pin_timestamp?: string | null; -} - -/** https://discord.com/developers/docs/topics/gateway#guild-ban-add */ -export interface DiscordGuildBanAddRemove { - /** id of the guild */ - guild_id: string; - /** The (un)banned user */ - user: DiscordUser; -} - -/** https://discord.com/developers/docs/topics/gateway#guild-emojis-update */ -export interface DiscordGuildEmojisUpdate { - /** id of the guild */ - guild_id: string; - /** Array of emojis */ - emojis: DiscordEmoji[]; -} - -/** https://discord.com/developers/docs/topics/gateway#guild-integrations-update */ -export interface DiscordGuildIntegrationsUpdate { - /** id of the guild whose integrations were updated */ - guild_id: string; -} - -/** https://discord.com/developers/docs/topics/gateway#guild-member-add */ -export interface DiscordGuildMemberAdd extends DiscordMember { - /** id of the guild */ - guild_id: string; -} - -/** https://discord.com/developers/docs/topics/gateway#guild-member-remove */ -export interface DiscordGuildMemberRemove { - /** The id of the guild */ - guild_id: string; - /** The user who was removed */ - user: DiscordUser; -} - -/** https://discord.com/developers/docs/topics/gateway#guild-member-update */ -export interface DiscordGuildMemberUpdate { - /** The id of the guild */ - guild_id: string; - /** User role ids */ - roles: string[]; - /** The user */ - user: DiscordUser; - /** Nickname of the user in the guild */ - nick?: string | null; - /** When the user joined the guild */ - joined_at: string; - /** When the user starting boosting the guild */ - premium_since?: string | null; - /** Whether the user has not yet passed the guild's Membership Screening requirements */ - pending?: boolean; -} - -/** https://discord.com/developers/docs/topics/gateway#guild-members-chunk */ -export interface DiscordGuildMembersChunk { - /** The id of the guild */ - guild_id: string; - /** Set of guild members */ - members: DiscordMember[]; - /** The chunk index in the expected chunks for this response (0 <= chunk_index < chunk_count) */ - chunk_index: number; - /** The total number of expected chunks for this response */ - chunk_count: number; - /** If passing an invalid id to `REQUEST_GUILD_MEMBERS`, it will be returned here */ - not_found?: string[]; - /** If passing true to `REQUEST_GUILD_MEMBERS`, presences of the returned members will be here */ - presences?: DiscordPresence[]; - /** The nonce used in the Guild Members Request */ - nonce?: string; -} - -/** https://discord.com/developers/docs/topics/gateway#guild-role-create */ -export interface DiscordGuildRoleCreateUpdate { - /** The id of the guild */ - guild_id: string; - /** The role created/updated */ - role: DiscordRole; -} - -/** https://discord.com/developers/docs/topics/gateway#guild-role-delete */ -export interface DiscordGuildRoleDelete { - /** id of the guild */ - guild_id: string; - /** id of the role */ - role_id: string; -} - -/** https://discord.com/developers/docs/topics/gateway#invite-create */ -export interface DiscordInviteCreate { - /** The channel the invite is for */ - channel_id: string; - /** The unique invite code */ - code: string; - /** The time at which the invite was created */ - created_at: string; - /** The guild of the invite */ - guild_id?: string; - /** The user that created the invite */ - inviter?: DiscordUser; - /** How long the invite is valid for (in seconds) */ - max_age: number; - /** The maximum number of times the invite can be used */ - max_uses: number; - /** The target user for this invite */ - target_user?: Partial; - /** The type of user target for this invite */ - target_user_type?: number; - /** Whether or not the invite is temporary (invited users will be kicked on disconnect unless they're assigned a role) */ - temporary: boolean; - /** How many times the invite has been used (always will be 0) */ - uses: number; -} - -/** https://discord.com/developers/docs/topics/gateway#invite-delete */ -export interface DiscordInviteDelete { - /** The channel of the invite */ - channel_id: string; - /** The guild of the invite */ - guild_id?: string; - /** The unique invite code */ - code: string; -} - -/** https://discord.com/developers/docs/topics/gateway#message-delete */ -export interface DiscordMessageDelete { - /** The id of the message */ - id: string; - /** The id of the channel */ - channel_id: string; - /** The id of the guild */ - guild_id?: string; -} - -/** https://discord.com/developers/docs/topics/gateway#message-delete-bulk */ -export interface DiscordMessageDeleteBulk { - /** The ids of the messages */ - ids: string[]; - /** The id of the channel */ - channel_id: string; - /** The id of the guild */ - guild_id?: string; -} - -/** https://discord.com/developers/docs/topics/gateway#message-reaction-add */ -export interface DiscordMessageReactionAdd { - /** The id of the user */ - user_id: string; - /** The id of the channel */ - channel_id: string; - /** The id of the message */ - message_id: string; - /** The id of the guild */ - guild_id?: string; - /** The member who reacted if this happened in a guild */ - member?: DiscordMember; - /** The emoji used to react */ - emoji: Partial; -} - -/** https://discord.com/developers/docs/topics/gateway#message-reaction-remove */ -export type DiscordMessageReactionRemove = Omit< - DiscordMessageReactionAdd, - "member" ->; - -/** https://discord.com/developers/docs/topics/gateway#message-reaction-remove-all */ -export type DiscordMessageReactionRemoveAll = Pick< - DiscordMessageReactionAdd, - "channel_id" | "message_id" | "guild_id" ->; - -/** https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji */ -export type DiscordMessageReactionRemoveEmoji = Pick< - DiscordMessageReactionAdd, - "channel_id" | "guild_id" | "message_id" | "emoji" ->; - -/** https://discord.com/developers/docs/topics/gateway#presence-update */ -export interface DiscordPresenceUpdate { - /** The user presence is being updated for */ - user: DiscordUser; - /** id of the guild */ - guild_id: string; - /** Either "idle", "dnd", "online", or "offline" */ - status: "idle" | "dnd" | "online" | "offline"; - /** User's current activities */ - activities: DiscordActivity[]; - /** User's platform-dependent status */ - client_status: DiscordClientStatus; -} - -/** https://discord.com/developers/docs/topics/gateway#client-status-object */ -export interface DiscordClientStatus { - /** The user's status set for an active desktop (Windows, Linux, Mac) application session */ - desktop?: string; - /** The user's status set for an active mobile (iOS, Android) application session */ - mobile?: string; - /** The user's status set for an active web (browser, bot account) application session */ - web?: string; -} - -/** https://discord.com/developers/docs/topics/gateway#activity-object */ -export interface DiscordActivity { - /** The activity's name */ - name: string; - /** Activity type */ - type: DiscordActivityTypes; - /** Stream url, is validated when type is 1 */ - url?: string | null; - /** Unix timestamp of when the activity was added to the user's session */ - created_at: number; - /** Unix timestamps for start and/or end of the game */ - timestamps?: DiscordActivityTimestamps; - /** Application id for the game */ - application_id?: string; - /** What the player is currently doing */ - details?: string | null; - /** The user's current party status */ - state?: string | null; - /** The emoji used for a custom status */ - emoji?: DiscordActivityEmoji | null; - /** Information for the current party of the player */ - party?: DiscordActivityParty; - /** Images for the presence and their hover texts */ - assets?: DiscordActivityAssets; - /** Secrets for Rich Presence joining and spectating */ - secrets?: DiscordActivitySecrets; - /** Whether or not the activity is an instanced game session */ - instance?: boolean; - /** Activity flags `OR`d together, describes what the payload includes */ - flags?: number; -} - -/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-types */ -export enum DiscordActivityTypes { - Game, - Streaming, - Listening, - Custom = 4, - Competing, -} - -/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-timestamps */ -export interface DiscordActivityTimestamps { - /** Unix time (in milliseconds) of when the activity started */ - start?: number; - /** Unix time (in milliseconds) of when the activity ends */ - end?: number; -} - -/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji */ -export interface DiscordActivityEmoji { - /** The name of the emoji */ - name: string; - /** The id of the emoji */ - id?: string; - /** Whether this emoji is animated */ - animated?: boolean; -} - -/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-party */ -export interface DiscordActivityParty { - /** The id of the party */ - id?: string; - /** Used to show the party's current and maximum size */ - size?: [current_size: number, max_size: number]; -} - -/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-assets */ -export interface DiscordActivityAssets { - /** The id for a large asset of the activity, usually a snowflake */ - large_image?: string; - /** Text displayed when hovering over the large image of the activity */ - large_text?: string; - /** The id for a small asset of the activity, usually a snowflake */ - small_image?: string; - /** Text displayed when hovering over the small image of the activity */ - small_text?: string; -} - -/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-secrets */ -export interface DiscordActivitySecrets { - /** The secret for joining a party */ - join?: string; - /** The secret for spectating a game */ - spectate?: string; - /** The secret for a specific instanced match */ - match?: string; -} - -/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags */ -export enum ActivityFlags { - INSTANCE = 1 << 0, - JOIN = 1 << 1, - SPECTATE = 1 << 2, - JOIN_REQUEST = 1 << 3, - SYNC = 1 << 4, - PLAY = 1 << 5, -} - -/** https://discord.com/developers/docs/topics/gateway#typing-start */ -export interface DiscordTypingStart { - /** id of the channel */ - channel_id: string; - /** id of the guild */ - guild_id?: string; - /** id of the user */ - user_id: string; - /** Unix time (in seconds) of when the user started typing */ - timestamp: number; - /** The member who started typing if this happened in a guild */ - member?: DiscordMember; -} - -/** https://discord.com/developers/docs/topics/gateway#voice-server-update */ -export interface DiscordVoiceServerUpdate { - /** Voice connection token */ - token: string; - /** The guild this voice server update is for */ - guild_id: string; - /** The voice server host */ - endpoint: string; -} - -/** https://discord.com/developers/docs/topics/gateway#webhooks-update */ -export interface DiscordWebhooksUpdate { - /** id of the guild */ - guild_id: string; - /** id of the channel */ - channel_id: string; -} - -/** https://discord.com/developers/docs/topics/gateway#commands */ -export type DiscordApplicationCommandCreateUpdateDelete = - & DiscordApplicationCommand - & { - /** id of the guild the command is in */ - guild_id: string; - }; - -/** https://discord.com/developers/docs/topics/gateway#get-gateway-bot */ -export interface DiscordGetGatewayBot { - /** The WSS URL that can be used for connecting to the gateway */ - url: string; - /** The recommended number of shards to use when connecting */ - shards: number; - /** Information on the current session start limit */ - session_start_limit: DiscordSessionStartLimit; -} - -/** https://discord.com/developers/docs/topics/gateway#session-start-limit-object */ -export interface DiscordSessionStartLimit { - /** The total number of session starts the current user is allowed */ - total: number; - /** The remaining number of session starts the current user is allowed */ - remaining: number; - /** The number of milliseconds after which the limit resets */ - reset_after: number; - /** The number of identify requests allowed per 5 seconds */ - max_concurrency: number; -} diff --git a/src/types/gateway/gateway_intents.ts b/src/types/gateway/gateway_intents.ts new file mode 100644 index 000000000..411ee7aa6 --- /dev/null +++ b/src/types/gateway/gateway_intents.ts @@ -0,0 +1,90 @@ +/** https://discord.com/developers/docs/topics/gateway#list-of-intents */ +export enum DiscordGatewayIntents { + /** + * - GUILD_CREATE + * - GUILD_DELETE + * - GUILD_ROLE_CREATE + * - GUILD_ROLE_UPDATE + * - GUILD_ROLE_DELETE + * - CHANNEL_CREATE + * - CHANNEL_UPDATE + * - CHANNEL_DELETE + * - CHANNEL_PINS_UPDATE + */ + GUILDS = 1 << 0, + /** + * - GUILD_MEMBER_ADD + * - GUILD_MEMBER_UPDATE + * - GUILD_MEMBER_REMOVE + */ + GUILD_MEMBERS = 1 << 1, + /** + * - GUILD_BAN_ADD + * - GUILD_BAN_REMOVE + */ + GUILD_BANS = 1 << 2, + /** + * - GUILD_EMOJIS_UPDATE + */ + GUILD_EMOJIS = 1 << 3, + /** + * - GUILD_INTEGRATIONS_UPDATE + * - INTEGRATION_CREATE + * - INTEGRATION_UPDATE + * - INTEGRATION_DELETE + */ + GUILD_INTEGRATIONS = 1 << 4, + /** Enables the following events: + * - WEBHOOKS_UPDATE + */ + GUILD_WEBHOOKS = 1 << 5, + /** + * - INVITE_CREATE + * - INVITE_DELETE + */ + GUILD_INVITES = 1 << 6, + /** + * - VOICE_STATE_UPDATE + */ + GUILD_VOICE_STATES = 1 << 7, + /** + * - PRESENCE_UPDATE + */ + GUILD_PRESENCES = 1 << 8, + /** + * - MESSAGE_CREATE + * - MESSAGE_UPDATE + * - MESSAGE_DELETE + */ + GUILD_MESSAGES = 1 << 9, + /** + * - MESSAGE_REACTION_ADD + * - MESSAGE_REACTION_REMOVE + * - MESSAGE_REACTION_REMOVE_ALL + * - MESSAGE_REACTION_REMOVE_EMOJI + */ + GUILD_MESSAGE_REACTIONS = 1 << 10, + /** + * - TYPING_START + */ + GUILD_MESSAGE_TYPING = 1 << 11, + /** + * - CHANNEL_CREATE + * - MESSAGE_CREATE + * - MESSAGE_UPDATE + * - MESSAGE_DELETE + * - CHANNEL_PINS_UPDATE + */ + DIRECT_MESSAGES = 1 << 12, + /** + * - MESSAGE_REACTION_ADD + * - MESSAGE_REACTION_REMOVE + * - MESSAGE_REACTION_REMOVE_ALL + * - MESSAGE_REACTION_REMOVE_EMOJI + */ + DIRECT_MESSAGE_REACTIONS = 1 << 13, + /** + * - TYPING_START + */ + DIRECT_MESSAGE_TYPING = 1 << 14, +} diff --git a/src/types/gateway/opcodes.ts b/src/types/gateway/gateway_opcodes.ts similarity index 100% rename from src/types/gateway/opcodes.ts rename to src/types/gateway/gateway_opcodes.ts diff --git a/src/types/gateway/gateway_payload.ts b/src/types/gateway/gateway_payload.ts new file mode 100644 index 000000000..0bb92461c --- /dev/null +++ b/src/types/gateway/gateway_payload.ts @@ -0,0 +1,13 @@ +export interface GatewayPayload { + /** opcode for the payload */ + op: number; + /** Event data */ + d: unknown | null; + /** Sequence number, used for resuming sessions and heartbeats */ + s: number | null; + /** The event name for this payload */ + t: string | null; +} + +/** https://discord.com/developers/docs/topics/gateway#payloads-gateway-payload-structure */ +export type DiscordGatewayPayload = GatewayPayload; diff --git a/src/types/gateway/gateway_url_params.ts b/src/types/gateway/gateway_url_params.ts new file mode 100644 index 000000000..67be76115 --- /dev/null +++ b/src/types/gateway/gateway_url_params.ts @@ -0,0 +1,11 @@ +export interface GatewayURLParams { + /** Gateway version to use */ + v: string; + /** The encoding of received gateway packets */ + encoding: string; + /** The (optional) compression of gateway packets */ + compress?: string; +} + +/** https://discord.com/developers/docs/topics/gateway#connecting-gateway-url-params */ +export type DiscordGatewayURLParams = GatewayURLParams; diff --git a/src/types/gateway/get_gateway_bot.ts b/src/types/gateway/get_gateway_bot.ts new file mode 100644 index 000000000..518f29477 --- /dev/null +++ b/src/types/gateway/get_gateway_bot.ts @@ -0,0 +1,13 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface GetGatewayBot { + /** The WSS URL that can be used for connecting to the gateway */ + url: string; + /** The recommended number of shards to use when connecting */ + shards: number; + /** Information on the current session start limit */ + sessionStartLimit: SessionStartLimit; +} + +/** https://discord.com/developers/docs/topics/gateway#get-gateway-bot */ +export type DiscordGetGatewayBot = SnakeCaseProps; diff --git a/src/types/gateway/hello.ts b/src/types/gateway/hello.ts new file mode 100644 index 000000000..e0def4c01 --- /dev/null +++ b/src/types/gateway/hello.ts @@ -0,0 +1,9 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface Hello { + /** The interval (in milliseconds) the client should heartbeat with */ + heartbeatInterval: number; +} + +/** https://discord.com/developers/docs/topics/gateway#hello */ +export type DiscordHello = SnakeCaseProps; diff --git a/src/types/gateway/identify.ts b/src/types/gateway/identify.ts new file mode 100644 index 000000000..3832bb2ae --- /dev/null +++ b/src/types/gateway/identify.ts @@ -0,0 +1,25 @@ +import { SnakeCaseProps } from "../util.ts"; +import { IdentifyConnectionProperties } from "./identify_connection_properties.ts"; +import { UpdateStatus } from "./update_status.ts"; + +export interface Identify { + /** Authentication token */ + token: string; + /** Connection properties */ + properties: IdentifyConnectionProperties; + /** Whether this connection supports compression of packets */ + compress?: boolean; + /** Value between 50 and 250, total number of members where the gateway will stop sending offline members in the guild member list */ + largeThreshold?: number; + /** Used for Guild Sharding */ + shard?: [number, number]; + /** Presence structure for initial presence information */ + presence?: UpdateStatus; + /** Enables dispatching of guild subscription events (presence and typing events) */ + guild_subscriptions?: boolean; + /** The Gateway Intents you wish to receive */ + intents: number; +} + +/** https://discord.com/developers/docs/topics/gateway#identify */ +export type DiscordIdentify = SnakeCaseProps; diff --git a/src/types/gateway/identify_connection_properties.ts b/src/types/gateway/identify_connection_properties.ts new file mode 100644 index 000000000..15704712b --- /dev/null +++ b/src/types/gateway/identify_connection_properties.ts @@ -0,0 +1,11 @@ +/** https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties */ +export interface IdentifyConnectionProperties { + /** Operating system */ + $os: string; + /** Library name */ + $browser: string; + /** Library name */ + $device: string; +} + +export type DiscordIdentifyConnectionProperties = IdentifyConnectionProperties; diff --git a/src/types/gateway/ready.ts b/src/types/gateway/ready.ts new file mode 100644 index 000000000..4c0280e77 --- /dev/null +++ b/src/types/gateway/ready.ts @@ -0,0 +1,24 @@ +import { User } from "../users/user.ts"; +import { SnakeCaseProps } from "../util.ts"; + +export interface Ready { + /** Gateway version */ + v: number; + /** Information about the user including email */ + user: User; + /** Empty array */ + privateChannels: []; + /** The guilds the user is in */ + guilds: UnavailableGuild[]; + /** Used for resuming connections */ + sessionId: string; + /** The shard information associated with this session, if sent when identifying */ + shard?: [number, number]; + /** Contains id and flags */ + application: + & Partial + & Pick; +} + +/** https://discord.com/developers/docs/topics/gateway#ready */ +export type DiscordReady = SnakeCaseProps; diff --git a/src/types/gateway/resume.ts b/src/types/gateway/resume.ts new file mode 100644 index 000000000..cf0a2327b --- /dev/null +++ b/src/types/gateway/resume.ts @@ -0,0 +1,11 @@ +/** https://discord.com/developers/docs/topics/gateway#resume */ +export interface Resume { + /** Session token */ + token: string; + /** Session id */ + session_id: string; + /** Last sequence number received */ + seq: number; +} + +export type DiscordResume = Resume; diff --git a/src/types/gateway/session_start_limit.ts b/src/types/gateway/session_start_limit.ts new file mode 100644 index 000000000..08dbd3469 --- /dev/null +++ b/src/types/gateway/session_start_limit.ts @@ -0,0 +1,15 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface SessionStartLimit { + /** The total number of session starts the current user is allowed */ + total: number; + /** The remaining number of session starts the current user is allowed */ + remaining: number; + /** The number of milliseconds after which the limit resets */ + resetAfter: number; + /** The number of identify requests allowed per 5 seconds */ + maxConcurrency: number; +} + +/** https://discord.com/developers/docs/topics/gateway#session-start-limit-object */ +export type DiscordSessionStartLimit = SnakeCaseProps; diff --git a/src/types/gateway/status_types.ts b/src/types/gateway/status_types.ts new file mode 100644 index 000000000..29ca38ec1 --- /dev/null +++ b/src/types/gateway/status_types.ts @@ -0,0 +1,7 @@ +/** https://discord.com/developers/docs/topics/gateway#update-status-status-types */ +export type DiscordStatusTypes = + | "online" + | "dnd" + | "idle" + | "invisible" + | "offline"; diff --git a/src/types/gateway/update_status.ts b/src/types/gateway/update_status.ts new file mode 100644 index 000000000..17f7e6137 --- /dev/null +++ b/src/types/gateway/update_status.ts @@ -0,0 +1,17 @@ +import { Activity } from "../misc/activity.ts"; +import { SnakeCaseProps } from "../util.ts"; +import { DiscordStatusTypes } from "./status_types.ts"; + +export interface UpdateStatus { + /** Unix time (in milliseconds) of when the client went idle, or null if the client is not idle */ + since: number | null; + /** null, or the user's activities */ + activities: Activity[] | null; + /** The user's new status */ + status: DiscordStatusTypes; + /** Whether or not the client is afk */ + afk: boolean; +} + +/** https://discord.com/developers/docs/topics/gateway#update-status */ +export type DiscordUpdateStatus = SnakeCaseProps; diff --git a/src/types/guilds/guild_ban_add_remove.ts b/src/types/guilds/guild_ban_add_remove.ts new file mode 100644 index 000000000..73b37edd6 --- /dev/null +++ b/src/types/guilds/guild_ban_add_remove.ts @@ -0,0 +1,12 @@ +import { User } from "../users/user.ts"; +import { SnakeCaseProps } from "../util.ts"; + +export interface GuildBanAdd { + /** id of the guild */ + guildId: string; + /** The banned user */ + user: User; +} + +/** https://discord.com/developers/docs/topics/gateway#guild-ban-add */ +export type DiscordGuildBanAdd = SnakeCaseProps; diff --git a/src/types/guilds/guild_ban_remove.ts b/src/types/guilds/guild_ban_remove.ts new file mode 100644 index 000000000..ee75953c3 --- /dev/null +++ b/src/types/guilds/guild_ban_remove.ts @@ -0,0 +1,12 @@ +import { User } from "../users/user.ts"; +import { SnakeCaseProps } from "../util.ts"; + +export interface GuildBanRemove { + /** id of the guild */ + guildId: string; + /** The unbanned user */ + user: User; +} + +/** https://discord.com/developers/docs/topics/gateway#guild-ban-remove */ +export type DiscordGuildBanRemove = SnakeCaseProps; diff --git a/src/types/guilds/guild_integrations_update.ts b/src/types/guilds/guild_integrations_update.ts new file mode 100644 index 000000000..70659cb77 --- /dev/null +++ b/src/types/guilds/guild_integrations_update.ts @@ -0,0 +1,11 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface GuildIntegrationsUpdate { + /** id of the guild whose integrations were updated */ + guildId: string; +} + +/** https://discord.com/developers/docs/topics/gateway#guild-integrations-update */ +export type DiscordGuildIntegrationsUpdate = SnakeCaseProps< + GuildIntegrationsUpdate +>; diff --git a/src/types/guilds/guild_role_create.ts b/src/types/guilds/guild_role_create.ts new file mode 100644 index 000000000..76b3a559f --- /dev/null +++ b/src/types/guilds/guild_role_create.ts @@ -0,0 +1,11 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface GuildRoleCreate { + /** The id of the guild */ + guildId: string; + /** The role created */ + role: Role; +} + +/** https://discord.com/developers/docs/topics/gateway#guild-role-create */ +export type DiscordGuildRoleCreate = SnakeCaseProps; diff --git a/src/types/guilds/guild_role_delete.ts b/src/types/guilds/guild_role_delete.ts new file mode 100644 index 000000000..6d9e98f20 --- /dev/null +++ b/src/types/guilds/guild_role_delete.ts @@ -0,0 +1,11 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface GuildRoleDelete { + /** id of the guild */ + guildId: string; + /** id of the role */ + roleId: string; +} + +/** https://discord.com/developers/docs/topics/gateway#guild-role-delete */ +export type DiscordGuildRoleDelete = SnakeCaseProps; diff --git a/src/types/guilds/guild_role_update.ts b/src/types/guilds/guild_role_update.ts new file mode 100644 index 000000000..69af9b2d9 --- /dev/null +++ b/src/types/guilds/guild_role_update.ts @@ -0,0 +1,11 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface GuildRoleUpdate { + /** The id of the guild */ + guildId: string; + /** The role updated */ + role: Role; +} + +/** https://discord.com/developers/docs/topics/gateway#guild-role-update */ +export type DiscordGuildRoleUpdate = SnakeCaseProps; diff --git a/src/types/guilds/request_guild_members.ts b/src/types/guilds/request_guild_members.ts new file mode 100644 index 000000000..0ecadd076 --- /dev/null +++ b/src/types/guilds/request_guild_members.ts @@ -0,0 +1,19 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface RequestGuildMembers { + /** id of the guild to get members for */ + guild_id: string; + /** String that username starts with, or an empty string to return all members */ + query?: string; + /** Maximum number of members to send matching the query; a limit of 0 can be used with an empty string query to return all members */ + limit: number; + /** Used to specify if we want the presences of the matched members */ + presences?: boolean; + /** Used to specify which users you wish to fetch */ + userIds?: string[]; + /** Nonce to identify the Guild Members Chunk response */ + nonce?: string; +} + +/** https://discord.com/developers/docs/topics/gateway#request-guild-members */ +export type DiscordRequestGuildMembers = SnakeCaseProps; diff --git a/src/types/invites/invite_create.ts b/src/types/invites/invite_create.ts new file mode 100644 index 000000000..4a440baa3 --- /dev/null +++ b/src/types/invites/invite_create.ts @@ -0,0 +1,30 @@ +import { User } from "../users/user.ts"; +import { SnakeCaseProps } from "../util.ts"; + +export interface InviteCreate { + /** The channel the invite is for */ + channelId: string; + /** The unique invite code */ + code: string; + /** The time at which the invite was created */ + createdAt: string; + /** The guild of the invite */ + guildId?: string; + /** The user that created the invite */ + inviter?: User; + /** How long the invite is valid for (in seconds) */ + maxAge: number; + /** The maximum number of times the invite can be used */ + maxUses: number; + /** The target user for this invite */ + targetUser?: Partial; + /** The type of user target for this invite */ + targetUserType?: number; + /** Whether or not the invite is temporary (invited users will be kicked on disconnect unless they're assigned a role) */ + temporary: boolean; + /** How many times the invite has been used (always will be 0) */ + uses: number; +} + +/** https://discord.com/developers/docs/topics/gateway#invite-create */ +export type DiscordInviteCreate = SnakeCaseProps; diff --git a/src/types/invites/invite_delete.ts b/src/types/invites/invite_delete.ts new file mode 100644 index 000000000..fda25e041 --- /dev/null +++ b/src/types/invites/invite_delete.ts @@ -0,0 +1,13 @@ +import { SnakeCaseProps } from "../util.ts"; + +/** https://discord.com/developers/docs/topics/gateway#invite-delete */ +export interface InviteDelete { + /** The channel of the invite */ + channelId: string; + /** The guild of the invite */ + guildId?: string; + /** The unique invite code */ + code: string; +} + +export type DiscordInviteDelete = SnakeCaseProps; diff --git a/src/types/members/guild_member_add.ts b/src/types/members/guild_member_add.ts new file mode 100644 index 000000000..87c56b343 --- /dev/null +++ b/src/types/members/guild_member_add.ts @@ -0,0 +1,9 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface GuildMemberAdd extends GuildMember { + /** id of the guild */ + guildId: string; +} + +/** https://discord.com/developers/docs/topics/gateway#guild-member-add */ +export type DiscordGuildMemberAdd = SnakeCaseProps; diff --git a/src/types/members/guild_member_remove.ts b/src/types/members/guild_member_remove.ts new file mode 100644 index 000000000..6f62ec900 --- /dev/null +++ b/src/types/members/guild_member_remove.ts @@ -0,0 +1,12 @@ +import { User } from "../users/user.ts"; +import { SnakeCaseProps } from "../util.ts"; + +export interface GuildMemberRemove { + /** The id of the guild */ + guildId: string; + /** The user who was removed */ + user: User; +} + +/** https://discord.com/developers/docs/topics/gateway#guild-member-remove */ +export type DiscordGuildMemberRemove = SnakeCaseProps; diff --git a/src/types/members/guild_member_update.ts b/src/types/members/guild_member_update.ts new file mode 100644 index 000000000..4a744450d --- /dev/null +++ b/src/types/members/guild_member_update.ts @@ -0,0 +1,22 @@ +import { User } from "../users/user.ts"; +import { SnakeCaseProps } from "../util.ts"; + +export interface GuildMemberUpdate { + /** The id of the guild */ + guildId: string; + /** User role ids */ + roles: string[]; + /** The user */ + user: User; + /** Nickname of the user in the guild */ + nick?: string | null; + /** When the user joined the guild */ + joinedAt: string; + /** When the user starting boosting the guild */ + premiumSince?: string | null; + /** Whether the user has not yet passed the guild's Membership Screening requirements */ + pending?: boolean; +} + +/** https://discord.com/developers/docs/topics/gateway#guild-member-update */ +export type DiscordGuildMemberUpdate = SnakeCaseProps; diff --git a/src/types/members/guild_members_chunk.ts b/src/types/members/guild_members_chunk.ts new file mode 100644 index 000000000..2ecd52587 --- /dev/null +++ b/src/types/members/guild_members_chunk.ts @@ -0,0 +1,21 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface GuildMembersChunk { + /** The id of the guild */ + guildId: string; + /** Set of guild members */ + members: GuildMember[]; + /** The chunk index in the expected chunks for this response (0 <= chunk_index < chunk_count) */ + chunkIndex: number; + /** The total number of expected chunks for this response */ + chunkCount: number; + /** If passing an invalid id to `REQUEST_GUILD_MEMBERS`, it will be returned here */ + notFound?: string[]; + /** If passing true to `REQUEST_GUILD_MEMBERS`, presences of the returned members will be here */ + presences?: Presence[]; + /** The nonce used in the Guild Members Request */ + nonce?: string; +} + +/** https://discord.com/developers/docs/topics/gateway#guild-members-chunk */ +export type DiscordGuildMembersChunk = SnakeCaseProps; diff --git a/src/types/messages/message_delete.ts b/src/types/messages/message_delete.ts new file mode 100644 index 000000000..31ff5c711 --- /dev/null +++ b/src/types/messages/message_delete.ts @@ -0,0 +1,13 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface MessageDelete { + /** The id of the message */ + id: string; + /** The id of the channel */ + channelId: string; + /** The id of the guild */ + guildId?: string; +} + +/** https://discord.com/developers/docs/topics/gateway#message-delete */ +export type DiscordMessageDelete = SnakeCaseProps; diff --git a/src/types/messages/message_delete_bulk.ts b/src/types/messages/message_delete_bulk.ts new file mode 100644 index 000000000..2d82d8ab1 --- /dev/null +++ b/src/types/messages/message_delete_bulk.ts @@ -0,0 +1,13 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface MessageDeleteBulk { + /** The ids of the messages */ + ids: string[]; + /** The id of the channel */ + channelId: string; + /** The id of the guild */ + guildId?: string; +} + +/** https://discord.com/developers/docs/topics/gateway#message-delete-bulk */ +export type DiscordMessageDeleteBulk = SnakeCaseProps; diff --git a/src/types/messages/message_reaction_add.ts b/src/types/messages/message_reaction_add.ts new file mode 100644 index 000000000..9168f9f0e --- /dev/null +++ b/src/types/messages/message_reaction_add.ts @@ -0,0 +1,20 @@ +import { Emoji } from "../emojis/emoji.ts"; +import { SnakeCaseProps } from "../util.ts"; + +export interface MessageReactionAdd { + /** The id of the user */ + userId: string; + /** The id of the channel */ + channelId: string; + /** The id of the message */ + messageId: string; + /** The id of the guild */ + guildId?: string; + /** The member who reacted if this happened in a guild */ + member?: GuildMember; + /** The emoji used to react */ + emoji: Partial; +} + +/** https://discord.com/developers/docs/topics/gateway#message-reaction-add */ +export type DiscordMessageReactionAdd = SnakeCaseProps; diff --git a/src/types/messages/message_reaction_remove.ts b/src/types/messages/message_reaction_remove.ts new file mode 100644 index 000000000..4f8d34a89 --- /dev/null +++ b/src/types/messages/message_reaction_remove.ts @@ -0,0 +1,12 @@ +import { SnakeCaseProps } from "../util.ts"; +import { MessageReactionAdd } from "./message_reaction_add.ts"; + +export type MessageReactionRemove = Omit< + MessageReactionAdd, + "member" +>; + +/** https://discord.com/developers/docs/topics/gateway#message-reaction-remove */ +export type DiscordMessageReactionRemove = SnakeCaseProps< + MessageReactionRemove +>; diff --git a/src/types/messages/message_reaction_remove_all.ts b/src/types/messages/message_reaction_remove_all.ts new file mode 100644 index 000000000..487c8985a --- /dev/null +++ b/src/types/messages/message_reaction_remove_all.ts @@ -0,0 +1,12 @@ +import { SnakeCaseProps } from "../util.ts"; +import { MessageReactionAdd } from "./message_reaction_add.ts"; + +export type MessageReactionRemoveAll = Pick< + MessageReactionAdd, + "channelId" | "messageId" | "guildId" +>; + +/** https://discord.com/developers/docs/topics/gateway#message-reaction-remove-all */ +export type DiscordMessageReactionRemoveAll = SnakeCaseProps< + MessageReactionRemoveAll +>; diff --git a/src/types/messages/message_reaction_remove_emoji.ts b/src/types/messages/message_reaction_remove_emoji.ts new file mode 100644 index 000000000..fb7018f66 --- /dev/null +++ b/src/types/messages/message_reaction_remove_emoji.ts @@ -0,0 +1,12 @@ +import { SnakeCaseProps } from "../util.ts"; +import { MessageReactionAdd } from "./message_reaction_add.ts"; + +export type MessageReactionRemoveEmoji = Pick< + MessageReactionAdd, + "channelId" | "guildId" | "messageId" | "emoji" +>; + +/** https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji */ +export type DiscordMessageReactionRemoveEmoji = SnakeCaseProps< + MessageReactionRemoveEmoji +>; diff --git a/src/types/misc/activity.ts b/src/types/misc/activity.ts new file mode 100644 index 000000000..c15d4760b --- /dev/null +++ b/src/types/misc/activity.ts @@ -0,0 +1,41 @@ +import { SnakeCaseProps } from "../util.ts"; +import { ActivityAssets } from "./activity_assets.ts"; +import { ActivityEmoji } from "./activity_emoji.ts"; +import { ActivityParty } from "./activity_party.ts"; +import { ActivitySecrets } from "./activity_secrets.ts"; +import { ActivityTimestamps } from "./activity_timestamps.ts"; +import { DiscordActivityTypes } from "./activity_types.ts"; + +export interface Activity { + /** The activity's name */ + name: string; + /** Activity type */ + type: DiscordActivityTypes; + /** Stream url, is validated when type is 1 */ + url?: string | null; + /** Unix timestamp of when the activity was added to the user's session */ + created_at: number; + /** Unix timestamps for start and/or end of the game */ + timestamps?: ActivityTimestamps; + /** Application id for the game */ + application_id?: string; + /** What the player is currently doing */ + details?: string | null; + /** The user's current party status */ + state?: string | null; + /** The emoji used for a custom status */ + emoji?: ActivityEmoji | null; + /** Information for the current party of the player */ + party?: ActivityParty; + /** Images for the presence and their hover texts */ + assets?: ActivityAssets; + /** Secrets for Rich Presence joining and spectating */ + secrets?: ActivitySecrets; + /** Whether or not the activity is an instanced game session */ + instance?: boolean; + /** Activity flags `OR`d together, describes what the payload includes */ + flags?: number; +} + +/** https://discord.com/developers/docs/topics/gateway#activity-object */ +export type DiscordActivity = SnakeCaseProps; diff --git a/src/types/misc/activity_assets.ts b/src/types/misc/activity_assets.ts new file mode 100644 index 000000000..f2f0658fc --- /dev/null +++ b/src/types/misc/activity_assets.ts @@ -0,0 +1,15 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface ActivityAssets { + /** The id for a large asset of the activity, usually a snowflake */ + largeImage?: string; + /** Text displayed when hovering over the large image of the activity */ + largeText?: string; + /** The id for a small asset of the activity, usually a snowflake */ + smallImage?: string; + /** Text displayed when hovering over the small image of the activity */ + smallText?: string; +} + +/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-assets */ +export type DiscordActivityAssets = SnakeCaseProps; diff --git a/src/types/misc/activity_emoji.ts b/src/types/misc/activity_emoji.ts new file mode 100644 index 000000000..8f9e6de77 --- /dev/null +++ b/src/types/misc/activity_emoji.ts @@ -0,0 +1,11 @@ +export interface ActivityEmoji { + /** The name of the emoji */ + name: string; + /** The id of the emoji */ + id?: string; + /** Whether this emoji is animated */ + animated?: boolean; +} + +/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji */ +export type DiscordActivityEmoji = ActivityEmoji; diff --git a/src/types/misc/activity_flags.ts b/src/types/misc/activity_flags.ts new file mode 100644 index 000000000..47fc818ef --- /dev/null +++ b/src/types/misc/activity_flags.ts @@ -0,0 +1,9 @@ +/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags */ +export enum DiscordActivityFlags { + INSTANCE = 1 << 0, + JOIN = 1 << 1, + SPECTATE = 1 << 2, + JOIN_REQUEST = 1 << 3, + SYNC = 1 << 4, + PLAY = 1 << 5, +} diff --git a/src/types/misc/activity_party.ts b/src/types/misc/activity_party.ts new file mode 100644 index 000000000..e3d53dba1 --- /dev/null +++ b/src/types/misc/activity_party.ts @@ -0,0 +1,9 @@ +/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-party */ +export interface ActivityParty { + /** The id of the party */ + id?: string; + /** Used to show the party's current and maximum size */ + size?: [currentSize: number, maxSize: number]; +} + +export type DiscordActivityParty = ActivityParty; diff --git a/src/types/misc/activity_secrets.ts b/src/types/misc/activity_secrets.ts new file mode 100644 index 000000000..b6d188eaa --- /dev/null +++ b/src/types/misc/activity_secrets.ts @@ -0,0 +1,11 @@ +export interface ActivitySecrets { + /** The secret for joining a party */ + join?: string; + /** The secret for spectating a game */ + spectate?: string; + /** The secret for a specific instanced match */ + match?: string; +} + +/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-secrets */ +export type DiscordActivitySecrets = ActivitySecrets; diff --git a/src/types/misc/activity_timestamps.ts b/src/types/misc/activity_timestamps.ts new file mode 100644 index 000000000..ac9bc3173 --- /dev/null +++ b/src/types/misc/activity_timestamps.ts @@ -0,0 +1,9 @@ +export interface ActivityTimestamps { + /** Unix time (in milliseconds) of when the activity started */ + start?: number; + /** Unix time (in milliseconds) of when the activity ends */ + end?: number; +} + +/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-timestamps */ +export type DiscordactivityTimestamps = ActivityTimestamps; diff --git a/src/types/misc/activity_types.ts b/src/types/misc/activity_types.ts new file mode 100644 index 000000000..18301c3c0 --- /dev/null +++ b/src/types/misc/activity_types.ts @@ -0,0 +1,8 @@ +/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-types */ +export enum DiscordActivityTypes { + Game, + Streaming, + Listening, + Custom = 4, + Competing, +} diff --git a/src/types/misc/client_status.ts b/src/types/misc/client_status.ts new file mode 100644 index 000000000..52435ed89 --- /dev/null +++ b/src/types/misc/client_status.ts @@ -0,0 +1,11 @@ +export interface ClientStatus { + /** The user's status set for an active desktop (Windows, Linux, Mac) application session */ + desktop?: string; + /** The user's status set for an active mobile (iOS, Android) application session */ + mobile?: string; + /** The user's status set for an active web (browser, bot account) application session */ + web?: string; +} + +/** https://discord.com/developers/docs/topics/gateway#client-status-object */ +export type DiscordClientStatus = ClientStatus; diff --git a/src/types/misc/presence_update.ts b/src/types/misc/presence_update.ts new file mode 100644 index 000000000..9e21defb2 --- /dev/null +++ b/src/types/misc/presence_update.ts @@ -0,0 +1,20 @@ +import { User } from "../users/user.ts"; +import { SnakeCaseProps } from "../util.ts"; +import { Activity } from "./activity.ts"; +import { ClientStatus } from "./client_status.ts"; + +export interface PresenceUpdate { + /** The user presence is being updated for */ + user: User; + /** id of the guild */ + guild_id: string; + /** Either "idle", "dnd", "online", or "offline" */ + status: "idle" | "dnd" | "online" | "offline"; + /** User's current activities */ + activities: Activity[]; + /** User's platform-dependent status */ + clientStatus: ClientStatus; +} + +/** https://discord.com/developers/docs/topics/gateway#presence-update */ +export type DiscordPresenceUpdate = SnakeCaseProps; diff --git a/src/types/misc/typing_start.ts b/src/types/misc/typing_start.ts new file mode 100644 index 000000000..b174ff6ea --- /dev/null +++ b/src/types/misc/typing_start.ts @@ -0,0 +1,17 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface TypingStart { + /** id of the channel */ + channelId: string; + /** id of the guild */ + guildId?: string; + /** id of the user */ + userId: string; + /** Unix time (in seconds) of when the user started typing */ + timestamp: number; + /** The member who started typing if this happened in a guild */ + member?: GuildMember; +} + +/** https://discord.com/developers/docs/topics/gateway#typing-start */ +export type DiscordTypingStart = SnakeCaseProps; diff --git a/src/types/voice/update_voice_state.ts b/src/types/voice/update_voice_state.ts new file mode 100644 index 000000000..223893f53 --- /dev/null +++ b/src/types/voice/update_voice_state.ts @@ -0,0 +1,15 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface UpdateVoiceState { + /** id of the guild */ + guildId: string; + /** id of the voice channel client wants to join (null if disconnecting) */ + channelId: string | null; + /** Is the client muted */ + selfMute: boolean; + /** Is the client deafened */ + selfDeaf: boolean; +} + +/** https://discord.com/developers/docs/topics/gateway#update-voice-state */ +export type DiscordUpdateVoiceState = SnakeCaseProps; diff --git a/src/types/voice/voice_server_update.ts b/src/types/voice/voice_server_update.ts new file mode 100644 index 000000000..663fa5ec2 --- /dev/null +++ b/src/types/voice/voice_server_update.ts @@ -0,0 +1,13 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface VoiceServerUpdate { + /** Voice connection token */ + token: string; + /** The guild this voice server update is for */ + guildId: string; + /** The voice server host */ + endpoint: string; +} + +/** https://discord.com/developers/docs/topics/gateway#voice-server-update */ +export type DiscordVoiceServerUpdate = SnakeCaseProps; diff --git a/src/types/webhooks/webhooks_update.ts b/src/types/webhooks/webhooks_update.ts new file mode 100644 index 000000000..e96e8bde5 --- /dev/null +++ b/src/types/webhooks/webhooks_update.ts @@ -0,0 +1,11 @@ +import { SnakeCaseProps } from "../util.ts"; + +export interface WebhooksUpdate { + /** id of the guild */ + guildId: string; + /** id of the channel */ + channelId: string; +} + +/** https://discord.com/developers/docs/topics/gateway#webhooks-update */ +export type DiscordWebhooksUpdate = SnakeCaseProps;