diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..d593a504a --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +deno/ diff --git a/README.md b/README.md index e0ab3b349..914e9344f 100644 --- a/README.md +++ b/README.md @@ -24,23 +24,23 @@ pnpm add discord-api-types You can only import this module by specifying the API version you want to target. Append `/v*` to the import path, where the `*` represents the API version. Below are some examples ```js -const { APIUser } = require('discord-api-types/v9'); +const { APIUser } = require('discord-api-types/v10'); ``` ```ts // TypeScript/ES Module support -import { APIUser } from 'discord-api-types/v9'; +import { APIUser } from 'discord-api-types/v10'; ``` You may also import just certain parts of the module that you need. The possible values are: `globals`, `gateway`, `gateway/v*`, `payloads`, `payloads/v*`, `rest`, `rest/v*`, `rpc`, `rpc/v*`, `utils`, `utils/v*`, `voice`, and `voice/v*`. Below are some examples ```js -const { GatewayVersion } = require('discord-api-types/gateway/v9'); +const { GatewayVersion } = require('discord-api-types/gateway/v10'); ``` ```ts // TypeScript/ES Module support -import { GatewayVersion } from 'discord-api-types/gateway/v9'; +import { GatewayVersion } from 'discord-api-types/gateway/v10'; ``` > _**Note:** The `v*` exports (`discord-api-type/v*`) include the appropriate version of `gateway`, `payloads`, `rest`, `rpc`, and `utils` you specified, alongside the `globals` exports_ @@ -53,21 +53,21 @@ We also provide typings compatible with the [deno](https://deno.land/) runtime. ```ts // Importing a specific API version -import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v9.ts'; +import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v10.ts'; ``` 2. From [deno.land/x](https://deno.land/x) ```ts // Importing a specific API version -import { APIUser } from 'https://deno.land/x/discord_api_types/v9.ts'; +import { APIUser } from 'https://deno.land/x/discord_api_types/v10.ts'; ``` 3. From [skypack.dev](https://www.skypack.dev/) ```ts // Importing a specific API version -import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v9?dts'; +import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v10?dts'; ``` ## Project Structure diff --git a/deno/README.md b/deno/README.md index e0ab3b349..914e9344f 100644 --- a/deno/README.md +++ b/deno/README.md @@ -24,23 +24,23 @@ pnpm add discord-api-types You can only import this module by specifying the API version you want to target. Append `/v*` to the import path, where the `*` represents the API version. Below are some examples ```js -const { APIUser } = require('discord-api-types/v9'); +const { APIUser } = require('discord-api-types/v10'); ``` ```ts // TypeScript/ES Module support -import { APIUser } from 'discord-api-types/v9'; +import { APIUser } from 'discord-api-types/v10'; ``` You may also import just certain parts of the module that you need. The possible values are: `globals`, `gateway`, `gateway/v*`, `payloads`, `payloads/v*`, `rest`, `rest/v*`, `rpc`, `rpc/v*`, `utils`, `utils/v*`, `voice`, and `voice/v*`. Below are some examples ```js -const { GatewayVersion } = require('discord-api-types/gateway/v9'); +const { GatewayVersion } = require('discord-api-types/gateway/v10'); ``` ```ts // TypeScript/ES Module support -import { GatewayVersion } from 'discord-api-types/gateway/v9'; +import { GatewayVersion } from 'discord-api-types/gateway/v10'; ``` > _**Note:** The `v*` exports (`discord-api-type/v*`) include the appropriate version of `gateway`, `payloads`, `rest`, `rpc`, and `utils` you specified, alongside the `globals` exports_ @@ -53,21 +53,21 @@ We also provide typings compatible with the [deno](https://deno.land/) runtime. ```ts // Importing a specific API version -import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v9.ts'; +import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v10.ts'; ``` 2. From [deno.land/x](https://deno.land/x) ```ts // Importing a specific API version -import { APIUser } from 'https://deno.land/x/discord_api_types/v9.ts'; +import { APIUser } from 'https://deno.land/x/discord_api_types/v10.ts'; ``` 3. From [skypack.dev](https://www.skypack.dev/) ```ts // Importing a specific API version -import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v9?dts'; +import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v10?dts'; ``` ## Project Structure diff --git a/deno/gateway/mod.ts b/deno/gateway/mod.ts index d6ad52a0e..ba8a3ecbc 100644 --- a/deno/gateway/mod.ts +++ b/deno/gateway/mod.ts @@ -1,4 +1,4 @@ // This file exports all the types available in the recommended gateway version // Thereby, things MAY break in the future. Try sticking to imports from a specific version -export * from './v9.ts'; +export * from './v10.ts'; diff --git a/deno/gateway/v10.ts b/deno/gateway/v10.ts new file mode 100644 index 000000000..a16287571 --- /dev/null +++ b/deno/gateway/v10.ts @@ -0,0 +1,1731 @@ +/** + * Types extracted from https://discord.com/developers/docs/topics/gateway + */ + +import type { Snowflake } from '../globals.ts'; +import type { + APIApplication, + APIChannel, + APIEmoji, + APIGuild, + APIGuildIntegration, + APIGuildMember, + APIGuildScheduledEvent, + APIInteraction, + APIMessage, + APIRole, + APIStageInstance, + APISticker, + APIThreadChannel, + APIThreadMember, + APIUnavailableGuild, + APIUser, + GatewayActivity, + GatewayPresenceUpdate as RawGatewayPresenceUpdate, + GatewayThreadListSync as RawGatewayThreadListSync, + GatewayThreadMembersUpdate as RawGatewayThreadMembersUpdate, + GatewayVoiceState, + InviteTargetType, + PresenceUpdateStatus, +} from '../payloads/v10/mod.ts'; +import type { Nullable } from '../utils/internals.ts'; + +export * from './common.ts'; + +export const GatewayVersion = '10'; + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes + */ +export enum GatewayOpcodes { + /** + * An event was dispatched + */ + Dispatch, + /** + * A bidirectional opcode to maintain an active gateway connection. + * Fired periodically by the client, or fired by the gateway to request an immediate heartbeat from the client. + */ + Heartbeat, + /** + * Starts a new session during the initial handshake + */ + Identify, + /** + * Update the client's presence + */ + PresenceUpdate, + /** + * Used to join/leave or move between voice channels + */ + VoiceStateUpdate, + /** + * Resume a previous session that was disconnected + */ + Resume = 6, + /** + * You should attempt to reconnect and resume immediately + */ + Reconnect, + /** + * Request information about offline guild members in a large guild + */ + RequestGuildMembers, + /** + * The session has been invalidated. You should reconnect and identify/resume accordingly + */ + InvalidSession, + /** + * Sent immediately after connecting, contains the `heartbeat_interval` to use + */ + Hello, + /** + * Sent in response to receiving a heartbeat to acknowledge that it has been received + */ + HeartbeatAck, +} + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes + */ +export enum GatewayCloseCodes { + /** + * We're not sure what went wrong. Try reconnecting? + */ + UnknownError = 4000, + /** + * You sent an invalid Gateway opcode or an invalid payload for an opcode. Don't do that! + * + * See https://discord.com/developers/docs/topics/gateway#payloads-and-opcodes + */ + UnknownOpcode, + /** + * You sent an invalid payload to us. Don't do that! + * + * See https://discord.com/developers/docs/topics/gateway#sending-payloads + */ + DecodeError, + /** + * You sent us a payload prior to identifying + * + * See https://discord.com/developers/docs/topics/gateway#identify + */ + NotAuthenticated, + /** + * The account token sent with your identify payload is incorrect + * + * See https://discord.com/developers/docs/topics/gateway#identify + */ + AuthenticationFailed, + /** + * You sent more than one identify payload. Don't do that! + */ + AlreadyAuthenticated, + /** + * The sequence sent when resuming the session was invalid. Reconnect and start a new session + * + * See https://discord.com/developers/docs/topics/gateway#resume + */ + InvalidSeq = 4007, + /** + * Woah nelly! You're sending payloads to us too quickly. Slow it down! You will be disconnected on receiving this + */ + RateLimited, + /** + * Your session timed out. Reconnect and start a new one + */ + SessionTimedOut, + /** + * You sent us an invalid shard when identifying + * + * See https://discord.com/developers/docs/topics/gateway#sharding + */ + InvalidShard, + /** + * The session would have handled too many guilds - you are required to shard your connection in order to connect + * + * See https://discord.com/developers/docs/topics/gateway#sharding + */ + ShardingRequired, + /** + * You sent an invalid version for the gateway + */ + InvalidAPIVersion, + /** + * You sent an invalid intent for a Gateway Intent. You may have incorrectly calculated the bitwise value + * + * See https://discord.com/developers/docs/topics/gateway#gateway-intents + */ + InvalidIntents, + /** + * You sent a disallowed intent for a Gateway Intent. You may have tried to specify an intent that you have not + * enabled or are not whitelisted for + * + * See https://discord.com/developers/docs/topics/gateway#gateway-intents + * + * See https://discord.com/developers/docs/topics/gateway#privileged-intents + */ + DisallowedIntents, +} + +/** + * https://discord.com/developers/docs/topics/gateway#list-of-intents + */ +export enum GatewayIntentBits { + Guilds = 1 << 0, + GuildMembers = 1 << 1, + GuildBans = 1 << 2, + GuildEmojisAndStickers = 1 << 3, + GuildIntegrations = 1 << 4, + GuildWebhooks = 1 << 5, + GuildInvites = 1 << 6, + GuildVoiceStates = 1 << 7, + GuildPresences = 1 << 8, + GuildMessages = 1 << 9, + GuildMessageReactions = 1 << 10, + GuildMessageTyping = 1 << 11, + DirectMessages = 1 << 12, + DirectMessageReactions = 1 << 13, + DirectMessageTyping = 1 << 14, + MessageContent = 1 << 15, + GuildScheduledEvents = 1 << 16, +} + +/** + * https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events + */ +export enum GatewayDispatchEvents { + ChannelCreate = 'CHANNEL_CREATE', + ChannelDelete = 'CHANNEL_DELETE', + ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE', + ChannelUpdate = 'CHANNEL_UPDATE', + GuildBanAdd = 'GUILD_BAN_ADD', + GuildBanRemove = 'GUILD_BAN_REMOVE', + GuildCreate = 'GUILD_CREATE', + GuildDelete = 'GUILD_DELETE', + GuildEmojisUpdate = 'GUILD_EMOJIS_UPDATE', + GuildIntegrationsUpdate = 'GUILD_INTEGRATIONS_UPDATE', + GuildMemberAdd = 'GUILD_MEMBER_ADD', + GuildMemberRemove = 'GUILD_MEMBER_REMOVE', + GuildMembersChunk = 'GUILD_MEMBERS_CHUNK', + GuildMemberUpdate = 'GUILD_MEMBER_UPDATE', + GuildRoleCreate = 'GUILD_ROLE_CREATE', + GuildRoleDelete = 'GUILD_ROLE_DELETE', + GuildRoleUpdate = 'GUILD_ROLE_UPDATE', + GuildStickersUpdate = 'GUILD_STICKERS_UPDATE', + GuildUpdate = 'GUILD_UPDATE', + IntegrationCreate = 'INTEGRATION_CREATE', + IntegrationDelete = 'INTEGRATION_DELETE', + IntegrationUpdate = 'INTEGRATION_UPDATE', + InteractionCreate = 'INTERACTION_CREATE', + InviteCreate = 'INVITE_CREATE', + InviteDelete = 'INVITE_DELETE', + MessageCreate = 'MESSAGE_CREATE', + MessageDelete = 'MESSAGE_DELETE', + MessageDeleteBulk = 'MESSAGE_DELETE_BULK', + MessageReactionAdd = 'MESSAGE_REACTION_ADD', + MessageReactionRemove = 'MESSAGE_REACTION_REMOVE', + MessageReactionRemoveAll = 'MESSAGE_REACTION_REMOVE_ALL', + MessageReactionRemoveEmoji = 'MESSAGE_REACTION_REMOVE_EMOJI', + MessageUpdate = 'MESSAGE_UPDATE', + PresenceUpdate = 'PRESENCE_UPDATE', + StageInstanceCreate = 'STAGE_INSTANCE_CREATE', + StageInstanceDelete = 'STAGE_INSTANCE_DELETE', + StageInstanceUpdate = 'STAGE_INSTANCE_UPDATE', + Ready = 'READY', + Resumed = 'RESUMED', + ThreadCreate = 'THREAD_CREATE', + ThreadDelete = 'THREAD_DELETE', + ThreadListSync = 'THREAD_LIST_SYNC', + ThreadMembersUpdate = 'THREAD_MEMBERS_UPDATE', + ThreadMemberUpdate = 'THREAD_MEMBER_UPDATE', + ThreadUpdate = 'THREAD_UPDATE', + TypingStart = 'TYPING_START', + UserUpdate = 'USER_UPDATE', + VoiceServerUpdate = 'VOICE_SERVER_UPDATE', + VoiceStateUpdate = 'VOICE_STATE_UPDATE', + WebhooksUpdate = 'WEBHOOKS_UPDATE', + GuildScheduledEventCreate = 'GUILD_SCHEDULED_EVENT_CREATE', + GuildScheduledEventUpdate = 'GUILD_SCHEDULED_EVENT_UPDATE', + GuildScheduledEventDelete = 'GUILD_SCHEDULED_EVENT_DELETE', + GuildScheduledEventUserAdd = 'GUILD_SCHEDULED_EVENT_USER_ADD', + GuildScheduledEventUserRemove = 'GUILD_SCHEDULED_EVENT_USER_REMOVE', +} + +export type GatewaySendPayload = + | GatewayHeartbeat + | GatewayIdentify + | GatewayUpdatePresence + | GatewayVoiceStateUpdate + | GatewayResume + | GatewayRequestGuildMembers; + +export type GatewayReceivePayload = + | GatewayHello + | GatewayHeartbeatRequest + | GatewayHeartbeatAck + | GatewayInvalidSession + | GatewayReconnect + | GatewayDispatchPayload; + +export type GatewayDispatchPayload = + | GatewayChannelModifyDispatch + | GatewayChannelPinsUpdateDispatch + | GatewayGuildBanModifyDispatch + | GatewayGuildDeleteDispatch + | GatewayGuildEmojisUpdateDispatch + | GatewayGuildIntegrationsUpdateDispatch + | GatewayGuildMemberAddDispatch + | GatewayGuildMemberRemoveDispatch + | GatewayGuildMembersChunkDispatch + | GatewayGuildMemberUpdateDispatch + | GatewayGuildModifyDispatch + | GatewayGuildRoleDeleteDispatch + | GatewayGuildRoleModifyDispatch + | GatewayGuildScheduledEventCreateDispatch + | GatewayGuildScheduledEventUpdateDispatch + | GatewayGuildScheduledEventDeleteDispatch + | GatewayGuildScheduledEventUserAddDispatch + | GatewayGuildScheduledEventUserRemoveDispatch + | GatewayGuildStickersUpdateDispatch + | GatewayIntegrationCreateDispatch + | GatewayIntegrationDeleteDispatch + | GatewayIntegrationUpdateDispatch + | GatewayInteractionCreateDispatch + | GatewayInviteCreateDispatch + | GatewayInviteDeleteDispatch + | GatewayMessageCreateDispatch + | GatewayMessageDeleteBulkDispatch + | GatewayMessageDeleteDispatch + | GatewayMessageReactionAddDispatch + | GatewayMessageReactionRemoveAllDispatch + | GatewayMessageReactionRemoveDispatch + | GatewayMessageReactionRemoveEmojiDispatch + | GatewayMessageUpdateDispatch + | GatewayPresenceUpdateDispatch + | GatewayStageInstanceCreateDispatch + | GatewayStageInstanceDeleteDispatch + | GatewayStageInstanceUpdateDispatch + | GatewayReadyDispatch + | GatewayResumedDispatch + | GatewayThreadListSyncDispatch + | GatewayThreadMembersUpdateDispatch + | GatewayThreadMemberUpdateDispatch + | GatewayThreadModifyDispatch + | GatewayTypingStartDispatch + | GatewayUserUpdateDispatch + | GatewayVoiceServerUpdateDispatch + | GatewayVoiceStateUpdateDispatch + | GatewayWebhooksUpdateDispatch; + +// #region Dispatch Payloads + +/** + * https://discord.com/developers/docs/topics/gateway#hello + */ +export interface GatewayHello extends NonDispatchPayload { + op: GatewayOpcodes.Hello; + d: GatewayHelloData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#hello + */ +export interface GatewayHelloData { + /** + * The interval (in milliseconds) the client should heartbeat with + */ + heartbeat_interval: number; +} + +/** + * https://discord.com/developers/docs/topics/gateway#heartbeating + */ +export interface GatewayHeartbeatRequest extends NonDispatchPayload { + op: GatewayOpcodes.Heartbeat; + d: never; +} + +/** + * https://discord.com/developers/docs/topics/gateway#heartbeating-example-gateway-heartbeat-ack + */ +export interface GatewayHeartbeatAck extends NonDispatchPayload { + op: GatewayOpcodes.HeartbeatAck; + d: never; +} + +/** + * https://discord.com/developers/docs/topics/gateway#invalid-session + */ +export interface GatewayInvalidSession extends NonDispatchPayload { + op: GatewayOpcodes.InvalidSession; + d: GatewayInvalidSessionData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#invalid-session + */ +export type GatewayInvalidSessionData = boolean; + +/** + * https://discord.com/developers/docs/topics/gateway#reconnect + */ +export interface GatewayReconnect extends NonDispatchPayload { + op: GatewayOpcodes.Reconnect; + d: never; +} + +/** + * https://discord.com/developers/docs/topics/gateway#ready + */ +export type GatewayReadyDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#ready + */ +export interface GatewayReadyDispatchData { + /** + * Gateway version + * + * See https://discord.com/developers/docs/topics/gateway#gateways-gateway-versions + */ + v: number; + /** + * Information about the user including email + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + user: APIUser; + /** + * The guilds the user is in + * + * See https://discord.com/developers/docs/resources/guild#unavailable-guild-object + */ + guilds: APIUnavailableGuild[]; + /** + * Used for resuming connections + */ + session_id: string; + /** + * The shard information associated with this session, if sent when identifying + * + * See https://discord.com/developers/docs/topics/gateway#sharding + */ + shard?: [shard_id: number, shard_count: number]; + /** + * Contains `id` and `flags` + * + * See https://discord.com/developers/docs/resources/application#application-object + */ + application: Pick; +} + +/** + * https://discord.com/developers/docs/topics/gateway#resumed + */ +export type GatewayResumedDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-create + * https://discord.com/developers/docs/topics/gateway#channel-update + * https://discord.com/developers/docs/topics/gateway#channel-delete + */ +export type GatewayChannelModifyDispatch = DataPayload< + GatewayDispatchEvents.ChannelCreate | GatewayDispatchEvents.ChannelDelete | GatewayDispatchEvents.ChannelUpdate, + GatewayChannelModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-create + * https://discord.com/developers/docs/topics/gateway#channel-update + * https://discord.com/developers/docs/topics/gateway#channel-delete + */ +export type GatewayChannelModifyDispatchData = APIChannel; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-create + */ +export type GatewayChannelCreateDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-create + */ +export type GatewayChannelCreateDispatchData = GatewayChannelModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-update + */ +export type GatewayChannelUpdateDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-update + */ +export type GatewayChannelUpdateDispatchData = GatewayChannelModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-delete + */ +export type GatewayChannelDeleteDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-delete + */ +export type GatewayChannelDeleteDispatchData = GatewayChannelModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-pins-update + */ +export type GatewayChannelPinsUpdateDispatch = DataPayload< + GatewayDispatchEvents.ChannelPinsUpdate, + GatewayChannelPinsUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-pins-update + */ +export interface GatewayChannelPinsUpdateDispatchData { + /** + * The id of the guild + */ + guild_id?: Snowflake; + /** + * The id of the channel + */ + channel_id: Snowflake; + /** + * The time at which the most recent pinned message was pinned + */ + last_pin_timestamp?: string | null; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-create + * https://discord.com/developers/docs/topics/gateway#guild-update + */ +export type GatewayGuildModifyDispatch = DataPayload< + GatewayDispatchEvents.GuildCreate | GatewayDispatchEvents.GuildUpdate, + GatewayGuildModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-create + * https://discord.com/developers/docs/topics/gateway#guild-update + */ +export type GatewayGuildModifyDispatchData = APIGuild; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-create + */ +export type GatewayGuildCreateDispatch = GatewayGuildModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-create + */ +export type GatewayGuildCreateDispatchData = GatewayGuildModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-update + */ +export type GatewayGuildUpdateDispatch = GatewayGuildModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-update + */ +export type GatewayGuildUpdateDispatchData = GatewayGuildModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-delete + */ +export type GatewayGuildDeleteDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-delete + */ +export type GatewayGuildDeleteDispatchData = APIUnavailableGuild; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-add + * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + */ +export type GatewayGuildBanModifyDispatch = DataPayload< + GatewayDispatchEvents.GuildBanAdd | GatewayDispatchEvents.GuildBanRemove, + GatewayGuildBanModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-add + * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + */ +export interface GatewayGuildBanModifyDispatchData { + /** + * ID of the guild + */ + guild_id: Snowflake; + /** + * The banned user + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + user: APIUser; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-add + */ +export type GatewayGuildBanAddDispatch = GatewayGuildBanModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-add + */ +export type GatewayGuildBanAddDispatchData = GatewayGuildBanModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + */ +export type GatewayGuildBanRemoveDispatch = GatewayGuildBanModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + */ +export type GatewayGuildBanRemoveDispatchData = GatewayGuildBanModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-emojis-update + */ +export type GatewayGuildEmojisUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildEmojisUpdate, + GatewayGuildEmojisUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-emojis-update + */ +export interface GatewayGuildEmojisUpdateDispatchData { + /** + * ID of the guild + */ + guild_id: Snowflake; + /** + * Array of emojis + * + * See https://discord.com/developers/docs/resources/emoji#emoji-object + */ + emojis: APIEmoji[]; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-stickers-update + */ +export type GatewayGuildStickersUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildStickersUpdate, + GatewayGuildStickersUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-stickers-update + */ +export interface GatewayGuildStickersUpdateDispatchData { + /** + * ID of the guild + */ + guild_id: Snowflake; + /** + * Array of stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + */ + stickers: APISticker[]; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-integrations-update + */ +export type GatewayGuildIntegrationsUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildIntegrationsUpdate, + GatewayGuildIntegrationsUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-integrations-update + */ +export interface GatewayGuildIntegrationsUpdateDispatchData { + /** + * ID of the guild whose integrations were updated + */ + guild_id: Snowflake; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-add + */ +export type GatewayGuildMemberAddDispatch = DataPayload< + GatewayDispatchEvents.GuildMemberAdd, + GatewayGuildMemberAddDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-add + */ +export interface GatewayGuildMemberAddDispatchData extends APIGuildMember { + /** + * The id of the guild + */ + guild_id: Snowflake; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-remove + */ +export type GatewayGuildMemberRemoveDispatch = DataPayload< + GatewayDispatchEvents.GuildMemberRemove, + GatewayGuildMemberRemoveDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-remove + */ +export interface GatewayGuildMemberRemoveDispatchData { + /** + * The id of the guild + */ + guild_id: Snowflake; + /** + * The user who was removed + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + user: APIUser; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-update + */ +export type GatewayGuildMemberUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildMemberUpdate, + GatewayGuildMemberUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-update + */ +export type GatewayGuildMemberUpdateDispatchData = Omit & + Partial> & + Required> & + Nullable> & { + /** + * The id of the guild + */ + guild_id: Snowflake; + }; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-members-chunk + */ +export type GatewayGuildMembersChunkDispatch = DataPayload< + GatewayDispatchEvents.GuildMembersChunk, + GatewayGuildMembersChunkDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-members-chunk + */ +export interface GatewayGuildMembersChunkDispatchData { + /** + * The id of the guild + */ + guild_id: Snowflake; + /** + * Set of guild members + * + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ + members: APIGuildMember[]; + /** + * 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?: unknown[]; + /** + * If passing true to `REQUEST_GUILD_MEMBERS`, presences of the returned members will be here + * + * See https://discord.com/developers/docs/topics/gateway#presence + */ + presences?: RawGatewayPresenceUpdate[]; + /** + * The nonce used in the Guild Members Request + * + * See https://discord.com/developers/docs/topics/gateway#request-guild-members + */ + nonce?: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-create + * https://discord.com/developers/docs/topics/gateway#guild-role-update + */ +export type GatewayGuildRoleModifyDispatch = DataPayload< + GatewayDispatchEvents.GuildRoleCreate | GatewayDispatchEvents.GuildRoleUpdate, + GatewayGuildRoleModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-create + * https://discord.com/developers/docs/topics/gateway#guild-role-update + */ +export interface GatewayGuildRoleModifyDispatchData { + /** + * The id of the guild + */ + guild_id: Snowflake; + /** + * The role created or updated + * + * See https://discord.com/developers/docs/topics/permissions#role-object + */ + role: APIRole; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-create + */ +export type GatewayGuildRoleCreateDispatch = GatewayGuildRoleModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-create + */ +export type GatewayGuildRoleCreateDispatchData = GatewayGuildRoleModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-update + */ +export type GatewayGuildRoleUpdateDispatch = GatewayGuildRoleModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-update + */ +export type GatewayGuildRoleUpdateDispatchData = GatewayGuildRoleModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-delete + */ +export type GatewayGuildRoleDeleteDispatch = DataPayload< + GatewayDispatchEvents.GuildRoleDelete, + GatewayGuildRoleDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-delete + */ +export interface GatewayGuildRoleDeleteDispatchData { + /** + * The id of the guild + */ + guild_id: Snowflake; + /** + * The id of the role + */ + role_id: Snowflake; +} + +export type GatewayGuildScheduledEventCreateDispatch = DataPayload< + GatewayDispatchEvents.GuildScheduledEventCreate, + GatewayGuildScheduledEventCreateDispatchData +>; + +export type GatewayGuildScheduledEventCreateDispatchData = APIGuildScheduledEvent; + +export type GatewayGuildScheduledEventUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildScheduledEventUpdate, + GatewayGuildScheduledEventUpdateDispatchData +>; + +export type GatewayGuildScheduledEventUpdateDispatchData = APIGuildScheduledEvent; + +export type GatewayGuildScheduledEventDeleteDispatch = DataPayload< + GatewayDispatchEvents.GuildScheduledEventDelete, + GatewayGuildScheduledEventDeleteDispatchData +>; + +export type GatewayGuildScheduledEventDeleteDispatchData = APIGuildScheduledEvent; + +export type GatewayGuildScheduledEventUserAddDispatch = DataPayload< + GatewayDispatchEvents.GuildScheduledEventUserAdd, + GatewayGuildScheduledEventUserAddDispatchData +>; + +export interface GatewayGuildScheduledEventUserAddDispatchData { + guild_scheduled_event_id: Snowflake; + user_id: Snowflake; + guild_id: Snowflake; +} + +export type GatewayGuildScheduledEventUserRemoveDispatch = DataPayload< + GatewayDispatchEvents.GuildScheduledEventUserRemove, + GatewayGuildScheduledEventUserAddDispatchData +>; + +export interface GatewayGuildScheduledEventUserRemoveDispatchData { + guild_scheduled_event_id: Snowflake; + user_id: Snowflake; + guild_id: Snowflake; +} + +/** + * https://discord.com/developers/docs/topics/gateway#integration-create + */ +export type GatewayIntegrationCreateDispatch = DataPayload< + GatewayDispatchEvents.IntegrationCreate, + GatewayIntegrationCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#integration-create + */ +export type GatewayIntegrationCreateDispatchData = APIGuildIntegration & { guild_id: Snowflake }; + +/** + * https://discord.com/developers/docs/topics/gateway#integration-update + */ +export type GatewayIntegrationUpdateDispatch = DataPayload< + GatewayDispatchEvents.IntegrationUpdate, + GatewayIntegrationUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#integration-update + */ +export type GatewayIntegrationUpdateDispatchData = APIGuildIntegration & { guild_id: Snowflake }; + +/** + * https://discord.com/developers/docs/topics/gateway#integration-update + */ +export type GatewayIntegrationDeleteDispatch = DataPayload< + GatewayDispatchEvents.IntegrationDelete, + GatewayIntegrationDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#integration-delete + */ +export interface GatewayIntegrationDeleteDispatchData { + /** + * Integration id + */ + id: Snowflake; + /** + * ID of the guild + */ + guild_id: Snowflake; + /** + * ID of the bot/OAuth2 application for this Discord integration + */ + application_id?: Snowflake; +} + +/** + * https://discord.com/developers/docs/topics/gateway#interaction-create + */ +export type GatewayInteractionCreateDispatch = DataPayload< + GatewayDispatchEvents.InteractionCreate, + GatewayInteractionCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#interaction-create + */ +export type GatewayInteractionCreateDispatchData = APIInteraction; + +/** + * https://discord.com/developers/docs/topics/gateway#invite-create + */ +export type GatewayInviteCreateDispatch = DataPayload< + GatewayDispatchEvents.InviteCreate, + GatewayInviteCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#invite-create + */ +export interface GatewayInviteCreateDispatchData { + /** + * The channel the invite is for + */ + channel_id: Snowflake; + /** + * The unique invite code + * + * See https://discord.com/developers/docs/resources/invite#invite-object + */ + code: string; + /** + * The time at which the invite was created + */ + created_at: number; + /** + * The guild of the invite + */ + guild_id?: Snowflake; + /** + * The user that created the invite + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + inviter?: APIUser; + /** + * 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 type of target for this voice channel invite + * + * See https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types + */ + target_type?: InviteTargetType; + /** + * The user whose stream to display for this voice channel stream invite + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + target_user?: APIUser; + /** + * The embedded application to open for this voice channel embedded application invite + */ + target_application?: Partial; + /** + * 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: 0; +} + +/** + * https://discord.com/developers/docs/topics/gateway#invite-delete + */ +export type GatewayInviteDeleteDispatch = DataPayload< + GatewayDispatchEvents.InviteDelete, + GatewayInviteDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#invite-delete + */ +export interface GatewayInviteDeleteDispatchData { + /** + * The channel of the invite + */ + channel_id: Snowflake; + /** + * The guild of the invite + */ + guild_id?: Snowflake; + /** + * The unique invite code + * + * See https://discord.com/developers/docs/resources/invite#invite-object + */ + code: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#message-create + */ +export type GatewayMessageCreateDispatch = DataPayload< + GatewayDispatchEvents.MessageCreate, + GatewayMessageCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-create + */ +export type GatewayMessageCreateDispatchData = APIMessage; + +/** + * https://discord.com/developers/docs/topics/gateway#message-update + */ +export type GatewayMessageUpdateDispatch = DataPayload< + GatewayDispatchEvents.MessageUpdate, + GatewayMessageUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-update + */ +export type GatewayMessageUpdateDispatchData = { + id: Snowflake; + channel_id: Snowflake; +} & Partial; + +/** + * https://discord.com/developers/docs/topics/gateway#message-delete + */ +export type GatewayMessageDeleteDispatch = DataPayload< + GatewayDispatchEvents.MessageDelete, + GatewayMessageDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-delete + */ +export interface GatewayMessageDeleteDispatchData { + /** + * The id of the message + */ + id: Snowflake; + /** + * The id of the channel + */ + channel_id: Snowflake; + /** + * The id of the guild + */ + guild_id?: Snowflake; +} + +/** + * https://discord.com/developers/docs/topics/gateway#message-delete-bulk + */ +export type GatewayMessageDeleteBulkDispatch = DataPayload< + GatewayDispatchEvents.MessageDeleteBulk, + GatewayMessageDeleteBulkDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-delete-bulk + */ +export interface GatewayMessageDeleteBulkDispatchData { + /** + * The ids of the messages + */ + ids: Snowflake[]; + /** + * The id of the channel + */ + channel_id: Snowflake; + /** + * The id of the guild + */ + guild_id?: Snowflake; +} + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-add + */ +export type GatewayMessageReactionAddDispatch = ReactionData; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-add + */ +export type GatewayMessageReactionAddDispatchData = GatewayMessageReactionAddDispatch['d']; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove + */ +export type GatewayMessageReactionRemoveDispatch = ReactionData; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove + */ +export type GatewayMessageReactionRemoveDispatchData = GatewayMessageReactionRemoveDispatch['d']; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-all + */ +export type GatewayMessageReactionRemoveAllDispatch = DataPayload< + GatewayDispatchEvents.MessageReactionRemoveAll, + GatewayMessageReactionRemoveAllDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-all + */ +export type GatewayMessageReactionRemoveAllDispatchData = MessageReactionRemoveData; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji + */ +export type GatewayMessageReactionRemoveEmojiDispatch = DataPayload< + GatewayDispatchEvents.MessageReactionRemoveEmoji, + GatewayMessageReactionRemoveEmojiDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji + */ +export interface GatewayMessageReactionRemoveEmojiDispatchData extends MessageReactionRemoveData { + /** + * The emoji that was removed + */ + emoji: APIEmoji; +} + +/** + * https://discord.com/developers/docs/topics/gateway#presence-update + */ +export type GatewayPresenceUpdateDispatch = DataPayload< + GatewayDispatchEvents.PresenceUpdate, + GatewayPresenceUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#presence-update + */ +export type GatewayPresenceUpdateDispatchData = RawGatewayPresenceUpdate; + +/** + * https://discord.com/developers/docs/topics/gateway#stage-instance-create + */ +export type GatewayStageInstanceCreateDispatch = DataPayload< + GatewayDispatchEvents.StageInstanceCreate, + GatewayStageInstanceCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#stage-instance-create + */ +export type GatewayStageInstanceCreateDispatchData = APIStageInstance; + +/** + * https://discord.com/developers/docs/topics/gateway#stage-instance-delete + */ +export type GatewayStageInstanceDeleteDispatch = DataPayload< + GatewayDispatchEvents.StageInstanceDelete, + GatewayStageInstanceDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#stage-instance-delete + */ +export type GatewayStageInstanceDeleteDispatchData = APIStageInstance; + +/** + * https://discord.com/developers/docs/topics/gateway#stage-instance-update + */ +export type GatewayStageInstanceUpdateDispatch = DataPayload< + GatewayDispatchEvents.StageInstanceUpdate, + GatewayStageInstanceUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#stage-instance-update + */ +export type GatewayStageInstanceUpdateDispatchData = APIStageInstance; + +/** + * https://discord.com/developers/docs/topics/gateway#thread-list-sync + */ +export type GatewayThreadListSyncDispatch = DataPayload< + GatewayDispatchEvents.ThreadListSync, + GatewayThreadListSyncDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#thread-list-sync + */ +export type GatewayThreadListSyncDispatchData = RawGatewayThreadListSync; + +/** + * https://discord.com/developers/docs/topics/gateway#thread-members-update + */ +export type GatewayThreadMembersUpdateDispatch = DataPayload< + GatewayDispatchEvents.ThreadMembersUpdate, + GatewayThreadMembersUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#thread-members-update + */ +export type GatewayThreadMembersUpdateDispatchData = RawGatewayThreadMembersUpdate; + +/** + * https://discord.com/developers/docs/topics/gateway#thread-member-update + */ +export type GatewayThreadMemberUpdateDispatch = DataPayload< + GatewayDispatchEvents.ThreadMemberUpdate, + GatewayThreadMemberUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#thread-member-update + */ +export type GatewayThreadMemberUpdateDispatchData = APIThreadMember & { guild_id: Snowflake }; + +/** + * https://discord.com/developers/docs/topics/gateway#thread-create + * https://discord.com/developers/docs/topics/gateway#thread-update + * https://discord.com/developers/docs/topics/gateway#thread-delete + */ +export type GatewayThreadModifyDispatch = DataPayload< + GatewayDispatchEvents.ThreadCreate | GatewayDispatchEvents.ThreadDelete | GatewayDispatchEvents.ThreadUpdate, + GatewayChannelModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#thread-create + */ +export type GatewayThreadCreateDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#thread-create + */ +export interface GatewayThreadCreateDispatchData extends APIThreadChannel { + /** + * Whether the thread is newly created or not. + */ + newly_created?: true; +} + +/** + * https://discord.com/developers/docs/topics/gateway#thread-update + */ +export type GatewayThreadUpdateDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#thread-update + */ +export type GatewayThreadUpdateDispatchData = GatewayChannelModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#thread-delete + */ +export type GatewayThreadDeleteDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#thread-delete + */ +export type GatewayThreadDeleteDispatchData = GatewayChannelModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#typing-start + */ +export type GatewayTypingStartDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#typing-start + */ +export interface GatewayTypingStartDispatchData { + /** + * The id of the channel + */ + channel_id: Snowflake; + /** + * The id of the guild + */ + guild_id?: Snowflake; + /** + * The id of the user + */ + user_id: Snowflake; + /** + * Unix time (in seconds) of when the user started typing + */ + timestamp: number; + /** + * The member who started typing if this happened in a guild + * + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ + member?: APIGuildMember; +} + +/** + * https://discord.com/developers/docs/topics/gateway#user-update + */ +export type GatewayUserUpdateDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#user-update + */ +export type GatewayUserUpdateDispatchData = APIUser; + +/** + * https://discord.com/developers/docs/topics/gateway#voice-state-update + */ +export type GatewayVoiceStateUpdateDispatch = DataPayload< + GatewayDispatchEvents.VoiceStateUpdate, + GatewayVoiceStateUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#voice-state-update + */ +export type GatewayVoiceStateUpdateDispatchData = GatewayVoiceState; + +/** + * https://discord.com/developers/docs/topics/gateway#voice-server-update + */ +export type GatewayVoiceServerUpdateDispatch = DataPayload< + GatewayDispatchEvents.VoiceServerUpdate, + GatewayVoiceServerUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#voice-server-update + */ +export interface GatewayVoiceServerUpdateDispatchData { + /** + * Voice connection token + */ + token: string; + /** + * The guild this voice server update is for + */ + guild_id: Snowflake; + /** + * The voice server host + * + * A `null` endpoint means that the voice server allocated has gone away and is trying to be reallocated. + * You should attempt to disconnect from the currently connected voice server, and not attempt to reconnect + * until a new voice server is allocated + */ + endpoint: string | null; +} + +/** + * https://discord.com/developers/docs/topics/gateway#webhooks-update + */ +export type GatewayWebhooksUpdateDispatch = DataPayload< + GatewayDispatchEvents.WebhooksUpdate, + GatewayWebhooksUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#webhooks-update + */ +export interface GatewayWebhooksUpdateDispatchData { + /** + * The id of the guild + */ + guild_id: Snowflake; + /** + * The id of the channel + */ + channel_id: Snowflake; +} + +// #endregion Dispatch Payloads + +// #region Sendable Payloads + +/** + * https://discord.com/developers/docs/topics/gateway#heartbeating + */ +export interface GatewayHeartbeat { + op: GatewayOpcodes.Heartbeat; + d: GatewayHeartbeatData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#heartbeating + */ +export type GatewayHeartbeatData = number | null; + +/** + * https://discord.com/developers/docs/topics/gateway#identify + */ +export interface GatewayIdentify { + op: GatewayOpcodes.Identify; + d: GatewayIdentifyData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#identify + */ +export interface GatewayIdentifyData { + /** + * Authentication token + */ + token: string; + /** + * Connection properties + * + * See https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties + */ + properties: GatewayIdentifyProperties; + /** + * Whether this connection supports compression of packets + * + * @default false + */ + compress?: boolean; + /** + * Value between 50 and 250, total number of members where the gateway will stop sending + * offline members in the guild member list + * + * @default 50 + */ + large_threshold?: number; + /** + * Used for Guild Sharding + * + * See https://discord.com/developers/docs/topics/gateway#sharding + */ + shard?: [shard_id: number, shard_count: number]; + /** + * Presence structure for initial presence information + * + * See https://discord.com/developers/docs/topics/gateway#update-presence + */ + presence?: GatewayPresenceUpdateData; + /** + * The Gateway Intents you wish to receive + * + * See https://discord.com/developers/docs/topics/gateway#gateway-intents + */ + intents: number; +} + +/** + * https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties + */ +export interface GatewayIdentifyProperties { + /** + * Your operating system + */ + $os: string; + /** + * Your library name + */ + $browser: string; + /** + * Your library name + */ + $device: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#resume + */ +export interface GatewayResume { + op: GatewayOpcodes.Resume; + d: GatewayResumeData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#resume + */ +export interface GatewayResumeData { + /** + * 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 GatewayRequestGuildMembers { + op: GatewayOpcodes.RequestGuildMembers; + d: GatewayRequestGuildMembersData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#request-guild-members + */ +export interface GatewayRequestGuildMembersData { + /** + * ID of the guild to get members for + */ + guild_id: Snowflake; + /** + * 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?: Snowflake | Snowflake[]; + /** + * Nonce to identify the Guild Members Chunk response + * + * Nonce can only be up to 32 bytes. If you send an invalid nonce it will be ignored and the reply member_chunk(s) will not have a `nonce` set. + * + * See https://discord.com/developers/docs/topics/gateway#guild-members-chunk + */ + nonce?: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#update-voice-state + */ +export interface GatewayVoiceStateUpdate { + op: GatewayOpcodes.VoiceStateUpdate; + d: GatewayVoiceStateUpdateData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#update-voice-state + */ +export interface GatewayVoiceStateUpdateData { + /** + * ID of the guild + */ + guild_id: Snowflake; + /** + * ID of the voice channel client wants to join (`null` if disconnecting) + */ + channel_id: Snowflake | 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 GatewayUpdatePresence { + op: GatewayOpcodes.PresenceUpdate; + d: GatewayPresenceUpdateData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#update-presence-gateway-presence-update-structure + */ +export interface GatewayPresenceUpdateData { + /** + * Unix time (in milliseconds) of when the client went idle, or `null` if the client is not idle + */ + since: number | null; + /** + * The user's activities + * + * See https://discord.com/developers/docs/topics/gateway#activity-object + */ + activities: GatewayActivityUpdateData[]; + /** + * The user's new status + * + * See https://discord.com/developers/docs/topics/gateway#update-presence-status-types + */ + status: PresenceUpdateStatus; + /** + * Whether or not the client is afk + */ + afk: boolean; +} + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-structure + */ +export type GatewayActivityUpdateData = Pick; + +// #endregion Sendable Payloads + +// #region Shared +interface BasePayload { + /** + * Opcode for the payload + */ + op: GatewayOpcodes; + /** + * Event data + */ + d?: unknown; + /** + * Sequence number, used for resuming sessions and heartbeats + */ + s: number; + /** + * The event name for this payload + */ + t?: string; +} + +type NonDispatchPayload = Omit & { + t: null; + s: null; +}; + +interface DataPayload extends BasePayload { + op: GatewayOpcodes.Dispatch; + t: Event; + d: D; +} + +type ReactionData = DataPayload< + E, + Omit< + { + /** + * The id of the user + */ + user_id: Snowflake; + /** + * The id of the channel + */ + channel_id: Snowflake; + /** + * The id of the message + */ + message_id: Snowflake; + /** + * The id of the guild + */ + guild_id?: Snowflake; + /** + * The member who reacted if this happened in a guild + * + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ + member?: APIGuildMember; + /** + * The emoji used to react + * + * See https://discord.com/developers/docs/resources/emoji#emoji-object + */ + emoji: APIEmoji; + }, + O + > +>; + +interface MessageReactionRemoveData { + /** + * The id of the channel + */ + channel_id: Snowflake; + /** + * The id of the message + */ + message_id: Snowflake; + /** + * The id of the guild + */ + guild_id?: Snowflake; +} +// #endregion Shared diff --git a/deno/gateway/v8.ts b/deno/gateway/v8.ts index 00a2bb160..4cd2dbe26 100644 --- a/deno/gateway/v8.ts +++ b/deno/gateway/v8.ts @@ -5,15 +5,14 @@ import type { Snowflake } from '../globals.ts'; import type { APIApplication, - APIApplicationCommandInteraction, APIChannel, APIEmoji, APIGuild, - APIGuildScheduledEvent, APIGuildIntegration, APIGuildMember, + APIGuildScheduledEvent, + APIInteraction, APIMessage, - APIMessageComponentInteraction, APIRole, APIStageInstance, APISticker, @@ -29,10 +28,14 @@ import type { Nullable } from '../utils/internals.ts'; export * from './common.ts'; +/** + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. + */ export const GatewayVersion = '8'; /** * https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export enum GatewayOpcodes { /** @@ -84,6 +87,7 @@ export enum GatewayOpcodes { /** * https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export enum GatewayCloseCodes { /** @@ -167,6 +171,7 @@ export enum GatewayCloseCodes { /** * https://discord.com/developers/docs/topics/gateway#list-of-intents + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export enum GatewayIntentBits { Guilds = 1 << 0, @@ -189,6 +194,7 @@ export enum GatewayIntentBits { /** * https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export enum GatewayDispatchEvents { ChannelCreate = 'CHANNEL_CREATE', @@ -242,6 +248,9 @@ export enum GatewayDispatchEvents { GuildScheduledEventUserRemove = 'GUILD_SCHEDULED_EVENT_USER_REMOVE', } +/** + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. + */ export type GatewaySendPayload = | GatewayHeartbeat | GatewayIdentify @@ -250,6 +259,9 @@ export type GatewaySendPayload = | GatewayResume | GatewayRequestGuildMembers; +/** + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. + */ export type GatewayReceivePayload = | GatewayHello | GatewayHeartbeatRequest @@ -258,6 +270,9 @@ export type GatewayReceivePayload = | GatewayReconnect | GatewayDispatchPayload; +/** + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. + */ export type GatewayDispatchPayload = | GatewayChannelModifyDispatch | GatewayChannelPinsUpdateDispatch @@ -308,6 +323,7 @@ export type GatewayDispatchPayload = /** * https://discord.com/developers/docs/topics/gateway#hello + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayHello extends NonDispatchPayload { op: GatewayOpcodes.Hello; @@ -316,6 +332,7 @@ export interface GatewayHello extends NonDispatchPayload { /** * https://discord.com/developers/docs/topics/gateway#hello + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayHelloData { /** @@ -326,6 +343,7 @@ export interface GatewayHelloData { /** * https://discord.com/developers/docs/topics/gateway#heartbeating + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayHeartbeatRequest extends NonDispatchPayload { op: GatewayOpcodes.Heartbeat; @@ -334,6 +352,7 @@ export interface GatewayHeartbeatRequest extends NonDispatchPayload { /** * https://discord.com/developers/docs/topics/gateway#heartbeating-example-gateway-heartbeat-ack + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayHeartbeatAck extends NonDispatchPayload { op: GatewayOpcodes.HeartbeatAck; @@ -342,6 +361,7 @@ export interface GatewayHeartbeatAck extends NonDispatchPayload { /** * https://discord.com/developers/docs/topics/gateway#invalid-session + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayInvalidSession extends NonDispatchPayload { op: GatewayOpcodes.InvalidSession; @@ -350,11 +370,13 @@ export interface GatewayInvalidSession extends NonDispatchPayload { /** * https://discord.com/developers/docs/topics/gateway#invalid-session + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayInvalidSessionData = boolean; /** * https://discord.com/developers/docs/topics/gateway#reconnect + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayReconnect extends NonDispatchPayload { op: GatewayOpcodes.Reconnect; @@ -363,11 +385,13 @@ export interface GatewayReconnect extends NonDispatchPayload { /** * https://discord.com/developers/docs/topics/gateway#ready + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayReadyDispatch = DataPayload; /** * https://discord.com/developers/docs/topics/gateway#ready + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayReadyDispatchData { /** @@ -408,6 +432,7 @@ export interface GatewayReadyDispatchData { /** * https://discord.com/developers/docs/topics/gateway#resumed + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayResumedDispatch = DataPayload; @@ -415,6 +440,7 @@ export type GatewayResumedDispatch = DataPayload; /** * https://discord.com/developers/docs/topics/gateway#guild-delete + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayGuildDeleteDispatchData = APIUnavailableGuild; /** * https://discord.com/developers/docs/topics/gateway#guild-ban-add * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayGuildBanModifyDispatch = DataPayload< GatewayDispatchEvents.GuildBanAdd | GatewayDispatchEvents.GuildBanRemove, @@ -541,6 +585,7 @@ export type GatewayGuildBanModifyDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#guild-ban-add * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayGuildBanModifyDispatchData { /** @@ -557,26 +602,31 @@ export interface GatewayGuildBanModifyDispatchData { /** * https://discord.com/developers/docs/topics/gateway#guild-ban-add + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayGuildBanAddDispatch = GatewayGuildBanModifyDispatch; /** * https://discord.com/developers/docs/topics/gateway#guild-ban-add + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayGuildBanAddDispatchData = GatewayGuildBanModifyDispatchData; /** * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayGuildBanRemoveDispatch = GatewayGuildBanModifyDispatch; /** * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayGuildBanRemoveDispatchData = GatewayGuildBanModifyDispatchData; /** * https://discord.com/developers/docs/topics/gateway#guild-emojis-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayGuildEmojisUpdateDispatch = DataPayload< GatewayDispatchEvents.GuildEmojisUpdate, @@ -585,6 +635,7 @@ export type GatewayGuildEmojisUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#guild-emojis-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayGuildEmojisUpdateDispatchData { /** @@ -601,6 +652,7 @@ export interface GatewayGuildEmojisUpdateDispatchData { /** * https://discord.com/developers/docs/topics/gateway#guild-stickers-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayGuildStickersUpdateDispatch = DataPayload< GatewayDispatchEvents.GuildStickersUpdate, @@ -609,6 +661,7 @@ export type GatewayGuildStickersUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#guild-stickers-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayGuildStickersUpdateDispatchData { /** @@ -625,6 +678,7 @@ export interface GatewayGuildStickersUpdateDispatchData { /** * https://discord.com/developers/docs/topics/gateway#guild-integrations-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayGuildIntegrationsUpdateDispatch = DataPayload< GatewayDispatchEvents.GuildIntegrationsUpdate, @@ -633,6 +687,7 @@ export type GatewayGuildIntegrationsUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#guild-integrations-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayGuildIntegrationsUpdateDispatchData { /** @@ -643,6 +698,7 @@ export interface GatewayGuildIntegrationsUpdateDispatchData { /** * https://discord.com/developers/docs/topics/gateway#guild-member-add + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayGuildMemberAddDispatch = DataPayload< GatewayDispatchEvents.GuildMemberAdd, @@ -651,6 +707,7 @@ export type GatewayGuildMemberAddDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#guild-member-add + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayGuildMemberAddDispatchData extends APIGuildMember { /** @@ -661,6 +718,7 @@ export interface GatewayGuildMemberAddDispatchData extends APIGuildMember { /** * https://discord.com/developers/docs/topics/gateway#guild-member-remove + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayGuildMemberRemoveDispatch = DataPayload< GatewayDispatchEvents.GuildMemberRemove, @@ -669,6 +727,7 @@ export type GatewayGuildMemberRemoveDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#guild-member-remove + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayGuildMemberRemoveDispatchData { /** @@ -685,6 +744,7 @@ export interface GatewayGuildMemberRemoveDispatchData { /** * https://discord.com/developers/docs/topics/gateway#guild-member-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayGuildMemberUpdateDispatch = DataPayload< GatewayDispatchEvents.GuildMemberUpdate, @@ -693,6 +753,7 @@ export type GatewayGuildMemberUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#guild-member-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayGuildMemberUpdateDispatchData = Omit & Partial> & @@ -706,6 +767,7 @@ export type GatewayGuildMemberUpdateDispatchData = Omit; +/** + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. + */ export type GatewayGuildScheduledEventCreateDispatchData = APIGuildScheduledEvent; +/** + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. + */ export type GatewayGuildScheduledEventUpdateDispatch = DataPayload< GatewayDispatchEvents.GuildScheduledEventUpdate, GatewayGuildScheduledEventUpdateDispatchData >; +/** + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. + */ export type GatewayGuildScheduledEventUpdateDispatchData = APIGuildScheduledEvent; +/** + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. + */ export type GatewayGuildScheduledEventDeleteDispatch = DataPayload< GatewayDispatchEvents.GuildScheduledEventDelete, GatewayGuildScheduledEventDeleteDispatchData >; +/** + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. + */ export type GatewayGuildScheduledEventDeleteDispatchData = APIGuildScheduledEvent; +/** + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. + */ export type GatewayGuildScheduledEventUserAddDispatch = DataPayload< GatewayDispatchEvents.GuildScheduledEventUserAdd, GatewayGuildScheduledEventUserAddDispatchData >; +/** + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. + */ export interface GatewayGuildScheduledEventUserAddDispatchData { guild_scheduled_event_id: Snowflake; user_id: Snowflake; guild_id: Snowflake; } +/** + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. + */ export type GatewayGuildScheduledEventUserRemoveDispatch = DataPayload< GatewayDispatchEvents.GuildScheduledEventUserRemove, GatewayGuildScheduledEventUserAddDispatchData >; +/** + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. + */ export interface GatewayGuildScheduledEventUserRemoveDispatchData { guild_scheduled_event_id: Snowflake; user_id: Snowflake; @@ -865,6 +966,7 @@ export interface GatewayGuildScheduledEventUserRemoveDispatchData { /** * https://discord.com/developers/docs/topics/gateway#integration-create + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayIntegrationCreateDispatch = DataPayload< GatewayDispatchEvents.IntegrationCreate, @@ -873,11 +975,13 @@ export type GatewayIntegrationCreateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#integration-create + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayIntegrationCreateDispatchData = APIGuildIntegration & { guild_id: Snowflake }; /** * https://discord.com/developers/docs/topics/gateway#integration-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayIntegrationUpdateDispatch = DataPayload< GatewayDispatchEvents.IntegrationUpdate, @@ -886,11 +990,13 @@ export type GatewayIntegrationUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#integration-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayIntegrationUpdateDispatchData = APIGuildIntegration & { guild_id: Snowflake }; /** * https://discord.com/developers/docs/topics/gateway#integration-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayIntegrationDeleteDispatch = DataPayload< GatewayDispatchEvents.IntegrationDelete, @@ -899,6 +1005,7 @@ export type GatewayIntegrationDeleteDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#integration-delete + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayIntegrationDeleteDispatchData { /** @@ -917,6 +1024,7 @@ export interface GatewayIntegrationDeleteDispatchData { /** * https://discord.com/developers/docs/topics/gateway#interaction-create + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayInteractionCreateDispatch = DataPayload< GatewayDispatchEvents.InteractionCreate, @@ -925,11 +1033,13 @@ export type GatewayInteractionCreateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#interaction-create + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ -export type GatewayInteractionCreateDispatchData = APIApplicationCommandInteraction | APIMessageComponentInteraction; +export type GatewayInteractionCreateDispatchData = APIInteraction; /** * https://discord.com/developers/docs/topics/gateway#invite-create + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayInviteCreateDispatch = DataPayload< GatewayDispatchEvents.InviteCreate, @@ -938,6 +1048,7 @@ export type GatewayInviteCreateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#invite-create + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayInviteCreateDispatchData { /** @@ -1000,6 +1111,7 @@ export interface GatewayInviteCreateDispatchData { /** * https://discord.com/developers/docs/topics/gateway#invite-delete + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayInviteDeleteDispatch = DataPayload< GatewayDispatchEvents.InviteDelete, @@ -1008,6 +1120,7 @@ export type GatewayInviteDeleteDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#invite-delete + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayInviteDeleteDispatchData { /** @@ -1028,6 +1141,7 @@ export interface GatewayInviteDeleteDispatchData { /** * https://discord.com/developers/docs/topics/gateway#message-create + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayMessageCreateDispatch = DataPayload< GatewayDispatchEvents.MessageCreate, @@ -1036,11 +1150,13 @@ export type GatewayMessageCreateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#message-create + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayMessageCreateDispatchData = APIMessage; /** * https://discord.com/developers/docs/topics/gateway#message-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayMessageUpdateDispatch = DataPayload< GatewayDispatchEvents.MessageUpdate, @@ -1049,6 +1165,7 @@ export type GatewayMessageUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#message-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayMessageUpdateDispatchData = { id: Snowflake; @@ -1057,6 +1174,7 @@ export type GatewayMessageUpdateDispatchData = { /** * https://discord.com/developers/docs/topics/gateway#message-delete + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayMessageDeleteDispatch = DataPayload< GatewayDispatchEvents.MessageDelete, @@ -1065,6 +1183,7 @@ export type GatewayMessageDeleteDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#message-delete + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayMessageDeleteDispatchData { /** @@ -1083,6 +1202,7 @@ export interface GatewayMessageDeleteDispatchData { /** * https://discord.com/developers/docs/topics/gateway#message-delete-bulk + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayMessageDeleteBulkDispatch = DataPayload< GatewayDispatchEvents.MessageDeleteBulk, @@ -1091,6 +1211,7 @@ export type GatewayMessageDeleteBulkDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#message-delete-bulk + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayMessageDeleteBulkDispatchData { /** @@ -1109,26 +1230,31 @@ export interface GatewayMessageDeleteBulkDispatchData { /** * https://discord.com/developers/docs/topics/gateway#message-reaction-add + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayMessageReactionAddDispatch = ReactionData; /** * https://discord.com/developers/docs/topics/gateway#message-reaction-add + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayMessageReactionAddDispatchData = GatewayMessageReactionAddDispatch['d']; /** * https://discord.com/developers/docs/topics/gateway#message-reaction-remove + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayMessageReactionRemoveDispatch = ReactionData; /** * https://discord.com/developers/docs/topics/gateway#message-reaction-remove + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayMessageReactionRemoveDispatchData = GatewayMessageReactionRemoveDispatch['d']; /** * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-all + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayMessageReactionRemoveAllDispatch = DataPayload< GatewayDispatchEvents.MessageReactionRemoveAll, @@ -1137,11 +1263,13 @@ export type GatewayMessageReactionRemoveAllDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-all + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayMessageReactionRemoveAllDispatchData = MessageReactionRemoveData; /** * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayMessageReactionRemoveEmojiDispatch = DataPayload< GatewayDispatchEvents.MessageReactionRemoveEmoji, @@ -1150,6 +1278,7 @@ export type GatewayMessageReactionRemoveEmojiDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayMessageReactionRemoveEmojiDispatchData extends MessageReactionRemoveData { /** @@ -1160,6 +1289,7 @@ export interface GatewayMessageReactionRemoveEmojiDispatchData extends MessageRe /** * https://discord.com/developers/docs/topics/gateway#presence-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayPresenceUpdateDispatch = DataPayload< GatewayDispatchEvents.PresenceUpdate, @@ -1168,11 +1298,13 @@ export type GatewayPresenceUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#presence-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayPresenceUpdateDispatchData = RawGatewayPresenceUpdate; /** * https://discord.com/developers/docs/topics/gateway#stage-instance-create + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayStageInstanceCreateDispatch = DataPayload< GatewayDispatchEvents.StageInstanceCreate, @@ -1181,11 +1313,13 @@ export type GatewayStageInstanceCreateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#stage-instance-create + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayStageInstanceCreateDispatchData = APIStageInstance; /** * https://discord.com/developers/docs/topics/gateway#stage-instance-delete + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayStageInstanceDeleteDispatch = DataPayload< GatewayDispatchEvents.StageInstanceDelete, @@ -1194,11 +1328,13 @@ export type GatewayStageInstanceDeleteDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#stage-instance-delete + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayStageInstanceDeleteDispatchData = APIStageInstance; /** * https://discord.com/developers/docs/topics/gateway#stage-instance-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayStageInstanceUpdateDispatch = DataPayload< GatewayDispatchEvents.StageInstanceUpdate, @@ -1207,16 +1343,19 @@ export type GatewayStageInstanceUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#stage-instance-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayStageInstanceUpdateDispatchData = APIStageInstance; /** * https://discord.com/developers/docs/topics/gateway#typing-start + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayTypingStartDispatch = DataPayload; /** * https://discord.com/developers/docs/topics/gateway#typing-start + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayTypingStartDispatchData { /** @@ -1245,16 +1384,19 @@ export interface GatewayTypingStartDispatchData { /** * https://discord.com/developers/docs/topics/gateway#user-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayUserUpdateDispatch = DataPayload; /** * https://discord.com/developers/docs/topics/gateway#user-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayUserUpdateDispatchData = APIUser; /** * https://discord.com/developers/docs/topics/gateway#voice-state-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayVoiceStateUpdateDispatch = DataPayload< GatewayDispatchEvents.VoiceStateUpdate, @@ -1263,11 +1405,13 @@ export type GatewayVoiceStateUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#voice-state-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayVoiceStateUpdateDispatchData = GatewayVoiceState; /** * https://discord.com/developers/docs/topics/gateway#voice-server-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayVoiceServerUpdateDispatch = DataPayload< GatewayDispatchEvents.VoiceServerUpdate, @@ -1276,6 +1420,7 @@ export type GatewayVoiceServerUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#voice-server-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayVoiceServerUpdateDispatchData { /** @@ -1298,6 +1443,7 @@ export interface GatewayVoiceServerUpdateDispatchData { /** * https://discord.com/developers/docs/topics/gateway#webhooks-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayWebhooksUpdateDispatch = DataPayload< GatewayDispatchEvents.WebhooksUpdate, @@ -1306,6 +1452,7 @@ export type GatewayWebhooksUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#webhooks-update + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayWebhooksUpdateDispatchData { /** @@ -1324,6 +1471,7 @@ export interface GatewayWebhooksUpdateDispatchData { /** * https://discord.com/developers/docs/topics/gateway#heartbeating + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayHeartbeat { op: GatewayOpcodes.Heartbeat; @@ -1332,11 +1480,13 @@ export interface GatewayHeartbeat { /** * https://discord.com/developers/docs/topics/gateway#heartbeating + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayHeartbeatData = number | null; /** * https://discord.com/developers/docs/topics/gateway#identify + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayIdentify { op: GatewayOpcodes.Identify; @@ -1345,6 +1495,7 @@ export interface GatewayIdentify { /** * https://discord.com/developers/docs/topics/gateway#identify + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayIdentifyData { /** @@ -1392,6 +1543,7 @@ export interface GatewayIdentifyData { /** * https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayIdentifyProperties { /** @@ -1410,6 +1562,7 @@ export interface GatewayIdentifyProperties { /** * https://discord.com/developers/docs/topics/gateway#resume + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayResume { op: GatewayOpcodes.Resume; @@ -1418,6 +1571,7 @@ export interface GatewayResume { /** * https://discord.com/developers/docs/topics/gateway#resume + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayResumeData { /** @@ -1436,6 +1590,7 @@ export interface GatewayResumeData { /** * https://discord.com/developers/docs/topics/gateway#request-guild-members + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayRequestGuildMembers { op: GatewayOpcodes.RequestGuildMembers; @@ -1444,6 +1599,7 @@ export interface GatewayRequestGuildMembers { /** * https://discord.com/developers/docs/topics/gateway#request-guild-members + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayRequestGuildMembersData { /** @@ -1479,6 +1635,7 @@ export interface GatewayRequestGuildMembersData { /** * https://discord.com/developers/docs/topics/gateway#update-voice-state + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayVoiceStateUpdate { op: GatewayOpcodes.VoiceStateUpdate; @@ -1487,6 +1644,7 @@ export interface GatewayVoiceStateUpdate { /** * https://discord.com/developers/docs/topics/gateway#update-voice-state + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayVoiceStateUpdateData { /** @@ -1509,6 +1667,7 @@ export interface GatewayVoiceStateUpdateData { /** * https://discord.com/developers/docs/topics/gateway#update-presence + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayUpdatePresence { op: GatewayOpcodes.PresenceUpdate; @@ -1517,6 +1676,7 @@ export interface GatewayUpdatePresence { /** * https://discord.com/developers/docs/topics/gateway#update-presence-gateway-presence-update-structure + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export interface GatewayPresenceUpdateData { /** @@ -1543,6 +1703,7 @@ export interface GatewayPresenceUpdateData { /** * https://discord.com/developers/docs/topics/gateway#activity-object-activity-structure + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. */ export type GatewayActivityUpdateData = Pick; @@ -1616,6 +1777,9 @@ type ReactionData = D > >; +/** + * @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10. + */ interface MessageReactionRemoveData { /** * The id of the channel diff --git a/deno/gateway/v9.ts b/deno/gateway/v9.ts index d3e9758f9..91d21910c 100644 --- a/deno/gateway/v9.ts +++ b/deno/gateway/v9.ts @@ -5,18 +5,18 @@ import type { Snowflake } from '../globals.ts'; import type { APIApplication, - APIApplicationCommandInteraction, APIChannel, APIEmoji, APIGuild, - APIGuildScheduledEvent, APIGuildIntegration, APIGuildMember, + APIGuildScheduledEvent, + APIInteraction, APIMessage, - APIMessageComponentInteraction, APIRole, APIStageInstance, APISticker, + APIThreadChannel, APIThreadMember, APIUnavailableGuild, APIUser, @@ -27,7 +27,6 @@ import type { GatewayVoiceState, InviteTargetType, PresenceUpdateStatus, - APIThreadChannel, } from '../payloads/v9/mod.ts'; import type { Nullable } from '../utils/internals.ts'; @@ -940,7 +939,7 @@ export type GatewayInteractionCreateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#interaction-create */ -export type GatewayInteractionCreateDispatchData = APIApplicationCommandInteraction | APIMessageComponentInteraction; +export type GatewayInteractionCreateDispatchData = APIInteraction; /** * https://discord.com/developers/docs/topics/gateway#invite-create diff --git a/deno/payloads/common.ts b/deno/payloads/common.ts new file mode 100644 index 000000000..d92024b78 --- /dev/null +++ b/deno/payloads/common.ts @@ -0,0 +1,56 @@ +/** + * https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags + * + * These flags are exported as `BigInt`s and NOT numbers. Wrapping them in `Number()` + * may cause issues, try to use BigInts as much as possible or modules that can + * replicate them in some way + */ +export const PermissionFlagsBits = { + CreateInstantInvite: 1n << 0n, + KickMembers: 1n << 1n, + BanMembers: 1n << 2n, + Administrator: 1n << 3n, + ManageChannels: 1n << 4n, + ManageGuild: 1n << 5n, + AddReactions: 1n << 6n, + ViewAuditLog: 1n << 7n, + PrioritySpeaker: 1n << 8n, + Stream: 1n << 9n, + ViewChannel: 1n << 10n, + SendMessages: 1n << 11n, + SendTTSMessages: 1n << 12n, + ManageMessages: 1n << 13n, + EmbedLinks: 1n << 14n, + AttachFiles: 1n << 15n, + ReadMessageHistory: 1n << 16n, + MentionEveryone: 1n << 17n, + UseExternalEmojis: 1n << 18n, + ViewGuildInsights: 1n << 19n, + Connect: 1n << 20n, + Speak: 1n << 21n, + MuteMembers: 1n << 22n, + DeafenMembers: 1n << 23n, + MoveMembers: 1n << 24n, + UseVAD: 1n << 25n, + ChangeNickname: 1n << 26n, + ManageNicknames: 1n << 27n, + ManageRoles: 1n << 28n, + ManageWebhooks: 1n << 29n, + ManageEmojisAndStickers: 1n << 30n, + UseApplicationCommands: 1n << 31n, + RequestToSpeak: 1n << 32n, + ManageEvents: 1n << 33n, + ManageThreads: 1n << 34n, + CreatePublicThreads: 1n << 35n, + CreatePrivateThreads: 1n << 36n, + UseExternalStickers: 1n << 37n, + SendMessagesInThreads: 1n << 38n, + StartEmbeddedActivities: 1n << 39n, + ModerateMembers: 1n << 40n, +} as const; + +/** + * Freeze the object of bits, preventing any modifications to it + * @internal + */ +Object.freeze(PermissionFlagsBits); diff --git a/deno/payloads/mod.ts b/deno/payloads/mod.ts index dee3a16eb..14a80b488 100644 --- a/deno/payloads/mod.ts +++ b/deno/payloads/mod.ts @@ -1,4 +1,4 @@ // This file exports all the payloads available in the recommended API version // Thereby, things MAY break in the future. Try sticking to imports from a specific version -export * from './v9/mod.ts'; +export * from './v10/mod.ts'; diff --git a/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/attachment.ts b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/attachment.ts new file mode 100644 index 000000000..f1e4b935f --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/attachment.ts @@ -0,0 +1,11 @@ +import type { Snowflake } from '../../../../../globals.ts'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandAttachmentOption = + APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataAttachmentOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Attachment, + Snowflake +>; diff --git a/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/base.ts b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/base.ts new file mode 100644 index 000000000..489e61c34 --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/base.ts @@ -0,0 +1,26 @@ +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; + +export interface APIApplicationCommandOptionBase { + type: Type; + name: string; + description: string; + required?: boolean; +} + +export interface APIInteractionDataOptionBase { + name: string; + type: T; + value: D; +} + +export type APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + Base extends APIApplicationCommandOptionBase, + ChoiceType extends APIApplicationCommandOptionChoice, +> = + | (Base & { + autocomplete: true; + }) + | (Base & { + autocomplete?: false; + choices?: ChoiceType[]; + }); diff --git a/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/boolean.ts b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/boolean.ts new file mode 100644 index 000000000..5d069f5a5 --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/boolean.ts @@ -0,0 +1,9 @@ +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandBooleanOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataBooleanOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Boolean, + boolean +>; diff --git a/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/channel.ts b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/channel.ts new file mode 100644 index 000000000..c21327007 --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/channel.ts @@ -0,0 +1,14 @@ +import type { Snowflake } from '../../../../../globals.ts'; +import type { ChannelType } from '../../../channel.ts'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export interface APIApplicationCommandChannelOption + extends APIApplicationCommandOptionBase { + channel_types?: Exclude[]; +} + +export type APIApplicationCommandInteractionDataChannelOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Channel, + Snowflake +>; diff --git a/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/integer.ts b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/integer.ts new file mode 100644 index 000000000..21b739b1d --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/integer.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base.ts'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; + +interface APIApplicationCommandIntegerOptionBase + extends APIApplicationCommandOptionBase { + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + min_value?: number; + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + max_value?: number; +} + +export type APIApplicationCommandIntegerOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandIntegerOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataIntegerOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/mentionable.ts b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/mentionable.ts new file mode 100644 index 000000000..20679c3ce --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/mentionable.ts @@ -0,0 +1,11 @@ +import type { Snowflake } from '../../../../../globals.ts'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandMentionableOption = + APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataMentionableOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Mentionable, + Snowflake +>; diff --git a/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/number.ts b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/number.ts new file mode 100644 index 000000000..54faeafcf --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/number.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base.ts'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; + +interface APIApplicationCommandNumberOptionBase + extends APIApplicationCommandOptionBase { + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + min_value?: number; + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + max_value?: number; +} + +export type APIApplicationCommandNumberOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandNumberOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataNumberOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/role.ts b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/role.ts new file mode 100644 index 000000000..b59f55a4b --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/role.ts @@ -0,0 +1,10 @@ +import type { Snowflake } from '../../../../../globals.ts'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandRoleOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataRoleOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Role, + Snowflake +>; diff --git a/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/shared.ts b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/shared.ts new file mode 100644 index 000000000..6a27c88b0 --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/shared.ts @@ -0,0 +1,24 @@ +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type + */ +export enum ApplicationCommandOptionType { + Subcommand = 1, + SubcommandGroup, + String, + Integer, + Boolean, + User, + Channel, + Role, + Mentionable, + Number, + Attachment, +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure + */ +export interface APIApplicationCommandOptionChoice { + name: string; + value: ValueType; +} diff --git a/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/string.ts b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/string.ts new file mode 100644 index 000000000..5c6853ace --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/string.ts @@ -0,0 +1,16 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base.ts'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandStringOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataStringOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/subcommand.ts b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/subcommand.ts new file mode 100644 index 000000000..5c7e132a7 --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/subcommand.ts @@ -0,0 +1,14 @@ +import type { APIApplicationCommandBasicOption, APIApplicationCommandInteractionDataBasicOption } from '../chatInput.ts'; +import type { APIApplicationCommandOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export interface APIApplicationCommandSubcommandOption + extends APIApplicationCommandOptionBase { + options?: APIApplicationCommandBasicOption[]; +} + +export interface APIApplicationCommandInteractionDataSubcommandOption { + name: string; + type: ApplicationCommandOptionType.Subcommand; + options?: APIApplicationCommandInteractionDataBasicOption[]; +} diff --git a/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts new file mode 100644 index 000000000..78698d1d5 --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts @@ -0,0 +1,17 @@ +import type { APIApplicationCommandOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; +import type { + APIApplicationCommandInteractionDataSubcommandOption, + APIApplicationCommandSubcommandOption, +} from './subcommand.ts'; + +export interface APIApplicationCommandSubcommandGroupOption + extends APIApplicationCommandOptionBase { + options?: APIApplicationCommandSubcommandOption[]; +} + +export interface APIApplicationCommandInteractionDataSubcommandGroupOption { + name: string; + type: ApplicationCommandOptionType.SubcommandGroup; + options: APIApplicationCommandInteractionDataSubcommandOption[]; +} diff --git a/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/user.ts b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/user.ts new file mode 100644 index 000000000..71f5b357e --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/_chatInput/user.ts @@ -0,0 +1,10 @@ +import type { Snowflake } from '../../../../../globals.ts'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandUserOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataUserOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.User, + Snowflake +>; diff --git a/deno/payloads/v10/_interactions/_applicationCommands/chatInput.ts b/deno/payloads/v10/_interactions/_applicationCommands/chatInput.ts new file mode 100644 index 000000000..efec9dc0d --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/chatInput.ts @@ -0,0 +1,146 @@ +import type { Snowflake } from '../../../../globals.ts'; +import type { APIAttachment, APIRole, APIUser } from '../../mod.ts'; +import type { + APIApplicationCommandInteractionWrapper, + APIInteractionDataResolvedChannel, + APIInteractionDataResolvedGuildMember, + ApplicationCommandType, +} from '../applicationCommands.ts'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base.ts'; +import type { APIBaseApplicationCommandInteractionData } from './internals.ts'; +import type { + APIApplicationCommandAttachmentOption, + APIApplicationCommandInteractionDataAttachmentOption, +} from './_chatInput/attachment.ts'; +import type { + APIApplicationCommandBooleanOption, + APIApplicationCommandInteractionDataBooleanOption, +} from './_chatInput/boolean.ts'; +import type { + APIApplicationCommandChannelOption, + APIApplicationCommandInteractionDataChannelOption, +} from './_chatInput/channel.ts'; +import type { + APIApplicationCommandIntegerOption, + APIApplicationCommandInteractionDataIntegerOption, +} from './_chatInput/integer.ts'; +import type { + APIApplicationCommandInteractionDataMentionableOption, + APIApplicationCommandMentionableOption, +} from './_chatInput/mentionable.ts'; +import type { + APIApplicationCommandInteractionDataNumberOption, + APIApplicationCommandNumberOption, +} from './_chatInput/number.ts'; +import type { + APIApplicationCommandInteractionDataRoleOption, + APIApplicationCommandRoleOption, +} from './_chatInput/role.ts'; +import type { + APIApplicationCommandInteractionDataStringOption, + APIApplicationCommandStringOption, +} from './_chatInput/string.ts'; +import type { + APIApplicationCommandInteractionDataSubcommandOption, + APIApplicationCommandSubcommandOption, +} from './_chatInput/subcommand.ts'; +import type { + APIApplicationCommandInteractionDataSubcommandGroupOption, + APIApplicationCommandSubcommandGroupOption, +} from './_chatInput/subcommandGroup.ts'; +import type { + APIApplicationCommandInteractionDataUserOption, + APIApplicationCommandUserOption, +} from './_chatInput/user.ts'; + +export * from './_chatInput/attachment.ts'; +export * from './_chatInput/boolean.ts'; +export * from './_chatInput/channel.ts'; +export * from './_chatInput/integer.ts'; +export * from './_chatInput/mentionable.ts'; +export * from './_chatInput/number.ts'; +export * from './_chatInput/role.ts'; +export * from './_chatInput/shared.ts'; +export * from './_chatInput/string.ts'; +export * from './_chatInput/subcommand.ts'; +export * from './_chatInput/subcommandGroup.ts'; +export * from './_chatInput/user.ts'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure + */ +export type APIApplicationCommandBasicOption = + | APIApplicationCommandStringOption + | APIApplicationCommandIntegerOption + | APIApplicationCommandBooleanOption + | APIApplicationCommandUserOption + | APIApplicationCommandChannelOption + | APIApplicationCommandRoleOption + | APIApplicationCommandMentionableOption + | APIApplicationCommandNumberOption + | APIApplicationCommandAttachmentOption; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure + */ +export type APIApplicationCommandOption = + | APIApplicationCommandSubcommandOption + | APIApplicationCommandSubcommandGroupOption + | APIApplicationCommandBasicOption; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-interaction-data-option-structure + */ +export type APIApplicationCommandInteractionDataOption = + | APIApplicationCommandInteractionDataSubcommandOption + | APIApplicationCommandInteractionDataSubcommandGroupOption + | APIApplicationCommandInteractionDataBasicOption; + +export type APIApplicationCommandInteractionDataBasicOption = + | APIApplicationCommandInteractionDataStringOption + | APIApplicationCommandInteractionDataIntegerOption + | APIApplicationCommandInteractionDataBooleanOption + | APIApplicationCommandInteractionDataUserOption + | APIApplicationCommandInteractionDataChannelOption + | APIApplicationCommandInteractionDataRoleOption + | APIApplicationCommandInteractionDataMentionableOption + | APIApplicationCommandInteractionDataNumberOption + | APIApplicationCommandInteractionDataAttachmentOption; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export interface APIChatInputApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + options?: APIApplicationCommandInteractionDataOption[]; + resolved?: APIChatInputApplicationCommandInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure + */ +export interface APIChatInputApplicationCommandInteractionDataResolved { + users?: Record; + roles?: Record; + members?: Record; + channels?: Record; + attachments?: Record; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIChatInputApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIChatInputApplicationCommandDMInteraction = + APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIChatInputApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; diff --git a/deno/payloads/v10/_interactions/_applicationCommands/contextMenu.ts b/deno/payloads/v10/_interactions/_applicationCommands/contextMenu.ts new file mode 100644 index 000000000..d60ce0f0c --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/contextMenu.ts @@ -0,0 +1,104 @@ +import type { Snowflake } from '../../../../globals.ts'; +import type { APIMessage } from '../../channel.ts'; +import type { APIUser } from '../../user.ts'; +import type { + APIApplicationCommandInteractionWrapper, + APIInteractionDataResolvedGuildMember, + ApplicationCommandType, +} from '../applicationCommands.ts'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base.ts'; +import type { APIBaseApplicationCommandInteractionData } from './internals.ts'; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export interface APIUserApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + target_id: Snowflake; + resolved: APIUserApplicationCommandInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure + */ +export interface APIUserApplicationCommandInteractionDataResolved { + users: Record; + members?: Record; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export interface APIMessageApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + target_id: Snowflake; + resolved: APIMessageApplicationCommandInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure + */ +export interface APIMessageApplicationCommandInteractionDataResolved { + messages: Record; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export type APIContextMenuInteractionData = + | APIUserApplicationCommandInteractionData + | APIMessageApplicationCommandInteractionData; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandDMInteraction = APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandDMInteraction = + APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuInteraction = APIUserApplicationCommandInteraction | APIMessageApplicationCommandInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuDMInteraction = + | APIUserApplicationCommandDMInteraction + | APIMessageApplicationCommandDMInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuGuildInteraction = + | APIUserApplicationCommandGuildInteraction + | APIMessageApplicationCommandGuildInteraction; diff --git a/deno/payloads/v10/_interactions/_applicationCommands/internals.ts b/deno/payloads/v10/_interactions/_applicationCommands/internals.ts new file mode 100644 index 000000000..6e2d4b8b1 --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/internals.ts @@ -0,0 +1,8 @@ +import type { Snowflake } from '../../../../globals.ts'; +import type { ApplicationCommandType } from '../applicationCommands.ts'; + +export interface APIBaseApplicationCommandInteractionData { + id: Snowflake; + type: Type; + name: string; +} diff --git a/deno/payloads/v10/_interactions/_applicationCommands/permissions.ts b/deno/payloads/v10/_interactions/_applicationCommands/permissions.ts new file mode 100644 index 000000000..38186f893 --- /dev/null +++ b/deno/payloads/v10/_interactions/_applicationCommands/permissions.ts @@ -0,0 +1,49 @@ +import type { Snowflake } from '../../../../globals.ts'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure + */ +export interface APIGuildApplicationCommandPermissions { + /** + * The id of the command + */ + id: Snowflake; + /** + * The id of the application the command belongs to + */ + application_id: Snowflake; + /** + * The id of the guild + */ + guild_id: Snowflake; + /** + * The permissions for the command in the guild + */ + permissions: APIApplicationCommandPermission[]; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-structure + */ +export interface APIApplicationCommandPermission { + /** + * The id of the role or user + */ + id: Snowflake; + /** + * Role or user + */ + type: ApplicationCommandPermissionType; + /** + * `true` to allow, `false`, to disallow + */ + permission: boolean; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type + */ +export enum ApplicationCommandPermissionType { + Role = 1, + User, +} diff --git a/deno/payloads/v10/_interactions/applicationCommands.ts b/deno/payloads/v10/_interactions/applicationCommands.ts new file mode 100644 index 000000000..cda6b3628 --- /dev/null +++ b/deno/payloads/v10/_interactions/applicationCommands.ts @@ -0,0 +1,124 @@ +import type { Permissions, Snowflake } from '../../../globals.ts'; +import type { APIPartialChannel, APIThreadMetadata } from '../channel.ts'; +import type { APIGuildMember } from '../guild.ts'; +import type { APIBaseInteraction } from './base.ts'; +import type { InteractionType } from './responses.ts'; +import type { + APIApplicationCommandOption, + APIChatInputApplicationCommandDMInteraction, + APIChatInputApplicationCommandGuildInteraction, + APIChatInputApplicationCommandInteraction, + APIChatInputApplicationCommandInteractionData, +} from './_applicationCommands/chatInput.ts'; +import type { + APIContextMenuDMInteraction, + APIContextMenuGuildInteraction, + APIContextMenuInteraction, + APIContextMenuInteractionData, +} from './_applicationCommands/contextMenu.ts'; + +export * from './_applicationCommands/chatInput.ts'; +export * from './_applicationCommands/contextMenu.ts'; +export * from './_applicationCommands/permissions.ts'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object + */ +export interface APIApplicationCommand { + /** + * Unique id of the command + */ + id: Snowflake; + /** + * Type of the command + */ + type: ApplicationCommandType; + /** + * Unique id of the parent application + */ + application_id: Snowflake; + /** + * Guild id of the command, if not global + */ + guild_id?: Snowflake; + /** + * 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[\w-]{1,32}$` + */ + name: string; + /** + * 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands + */ + description: string; + /** + * The parameters for the `CHAT_INPUT` command, max 25 + */ + options?: APIApplicationCommandOption[]; + /** + * Whether the command is enabled by default when the app is added to a guild + * + * If missing, this property should be assumed as `true` + */ + default_permission?: boolean; + /** + * Autoincrementing version identifier updated during substantial record changes + */ + version: Snowflake; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types + */ +export enum ApplicationCommandType { + ChatInput = 1, + User, + Message, +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export type APIApplicationCommandInteractionData = + | APIChatInputApplicationCommandInteractionData + | APIContextMenuInteractionData; + +/** + * https://discord.com/developers/docs/resources/channel#channel-object + */ +export interface APIInteractionDataResolvedChannel extends Required { + thread_metadata?: APIThreadMetadata | null; + permissions: Permissions; + parent_id?: string | null; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-member-object + */ +export interface APIInteractionDataResolvedGuildMember extends Omit { + permissions: Permissions; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandInteractionWrapper = + APIBaseInteraction & + Required, 'channel_id' | 'data'>>; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandInteraction = APIChatInputApplicationCommandInteraction | APIContextMenuInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandDMInteraction = + | APIChatInputApplicationCommandDMInteraction + | APIContextMenuDMInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandGuildInteraction = + | APIChatInputApplicationCommandGuildInteraction + | APIContextMenuGuildInteraction; diff --git a/deno/payloads/v10/_interactions/autocomplete.ts b/deno/payloads/v10/_interactions/autocomplete.ts new file mode 100644 index 000000000..4de90f038 --- /dev/null +++ b/deno/payloads/v10/_interactions/autocomplete.ts @@ -0,0 +1,30 @@ +import type { + APIBaseInteraction, + APIChatInputApplicationCommandInteractionData, + APIDMInteractionWrapper, + APIGuildInteractionWrapper, + InteractionType, +} from '../mod.ts'; + +export type APIApplicationCommandAutocompleteInteraction = APIBaseInteraction< + InteractionType.ApplicationCommandAutocomplete, + APIChatInputApplicationCommandInteractionData +> & + Required< + Pick< + APIBaseInteraction, + 'data' + > + >; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandAutocompleteDMInteraction = + APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandAutocompleteGuildInteraction = + APIGuildInteractionWrapper; diff --git a/deno/payloads/v10/_interactions/base.ts b/deno/payloads/v10/_interactions/base.ts new file mode 100644 index 000000000..45d991022 --- /dev/null +++ b/deno/payloads/v10/_interactions/base.ts @@ -0,0 +1,127 @@ +import type { Permissions, Snowflake } from '../../../globals.ts'; +import type { LocaleString } from '../../../v10.ts'; +import type { APIMessage } from '../channel.ts'; +import type { APIGuildMember } from '../guild.ts'; +import type { APIUser } from '../user.ts'; +import type { InteractionType } from './responses.ts'; + +export type PartialAPIMessageInteractionGuildMember = Pick< + APIGuildMember, + | 'roles' + | 'premium_since' + | 'pending' + | 'nick' + | 'mute' + | 'joined_at' + | 'deaf' + | 'communication_disabled_until' + | 'avatar' +>; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object + */ +export interface APIMessageInteraction { + /** + * ID of the interaction + */ + id: Snowflake; + /** + * The type of interaction + */ + type: InteractionType; + /** + * The name of the ApplicationCommand + */ + name: string; + /** + * The user who invoked the interaction + */ + user: APIUser; + /** + * The guild member who invoked the interaction, only sent in MESSAGE_CREATE events + */ + member?: PartialAPIMessageInteractionGuildMember; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-member-object + */ +export interface APIInteractionGuildMember extends APIGuildMember { + permissions: Permissions; + user: APIUser; +} + +// INTERACTIONS RECEIVED + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export interface APIBaseInteraction { + /** + * ID of the interaction + */ + id: Snowflake; + /** + * ID of the application this interaction is for + */ + application_id: Snowflake; + /** + * The type of interaction + */ + type: Type; + /** + * The command data payload + */ + data?: Data; + /** + * The guild it was sent from + */ + guild_id?: Snowflake; + /** + * The channel it was sent from + */ + channel_id?: Snowflake; + /** + * Guild member data for the invoking user, including permissions + * + * **This is only sent when an interaction is invoked in a guild** + */ + member?: APIInteractionGuildMember; + /** + * User object for the invoking user, if invoked in a DM + */ + user?: APIUser; + /** + * A continuation token for responding to the interaction + */ + token: string; + /** + * Read-only property, always `1` + */ + version: 1; + /** + * For components, the message they were attached to + */ + message?: APIMessage; + /** + * The selected language of the invoking user + */ + locale: LocaleString; + /** + * The guild's preferred locale, if invoked in a guild + */ + guild_locale?: LocaleString; +} + +export type APIDMInteractionWrapper> = Omit< + Original, + 'member' | 'guild_id' +> & + Required>; + +export type APIGuildInteractionWrapper> = Omit< + Original, + 'user' +> & + Required>; diff --git a/deno/payloads/v10/_interactions/messageComponents.ts b/deno/payloads/v10/_interactions/messageComponents.ts new file mode 100644 index 000000000..d6f623050 --- /dev/null +++ b/deno/payloads/v10/_interactions/messageComponents.ts @@ -0,0 +1,38 @@ +import type { ComponentType } from '../channel.ts'; +import type { APIBaseInteraction, InteractionType } from '../interactions.ts'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts'; + +export type APIMessageComponentInteraction = APIBaseInteraction< + InteractionType.MessageComponent, + APIMessageComponentInteractionData +> & + Required< + Pick< + APIBaseInteraction, + 'channel_id' | 'data' | 'message' + > + >; + +export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData; + +export interface APIMessageComponentBaseInteractionData { + /** + * The `custom_id` of the component + */ + custom_id: string; + /** + * The type of the component + */ + component_type: CType; +} + +export type APIMessageButtonInteractionData = APIMessageComponentBaseInteractionData; + +export interface APIMessageSelectMenuInteractionData + extends APIMessageComponentBaseInteractionData { + values: string[]; +} + +export type APIMessageComponentDMInteraction = APIDMInteractionWrapper; + +export type APIMessageComponentGuildInteraction = APIGuildInteractionWrapper; diff --git a/deno/payloads/v10/_interactions/modalSubmit.ts b/deno/payloads/v10/_interactions/modalSubmit.ts new file mode 100644 index 000000000..2fbceee9a --- /dev/null +++ b/deno/payloads/v10/_interactions/modalSubmit.ts @@ -0,0 +1,46 @@ +import type { APIActionRowComponent, APIModalActionRowComponent } from '../channel.ts'; +import type { + APIBaseInteraction, + APIDMInteractionWrapper, + APIGuildInteractionWrapper, + ComponentType, + InteractionType, +} from '../mod.ts'; + +export interface ModalSubmitComponent { + type: ComponentType; + custom_id: string; + value: string; +} + +export interface ModalSubmitActionRowComponent + extends Omit, 'components'> { + components: ModalSubmitComponent[]; +} + +export interface APIModalSubmission { + /** + * A developer-defined identifier for the component, max 100 characters + */ + custom_id: string; + /** + * A list of child components + */ + components?: ModalSubmitActionRowComponent[]; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIModalSubmitInteraction = APIBaseInteraction & + Required, 'data'>>; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIModalSubmitDMInteraction = APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIModalSubmitGuildInteraction = APIGuildInteractionWrapper; diff --git a/deno/payloads/v10/_interactions/ping.ts b/deno/payloads/v10/_interactions/ping.ts new file mode 100644 index 000000000..3e03a6207 --- /dev/null +++ b/deno/payloads/v10/_interactions/ping.ts @@ -0,0 +1,4 @@ +import type { APIBaseInteraction } from './base.ts'; +import type { InteractionType } from './responses.ts'; + +export type APIPingInteraction = Omit, 'locale'>; diff --git a/deno/payloads/v10/_interactions/responses.ts b/deno/payloads/v10/_interactions/responses.ts new file mode 100644 index 000000000..7601f96cf --- /dev/null +++ b/deno/payloads/v10/_interactions/responses.ts @@ -0,0 +1,124 @@ +import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v10.ts'; +import type { APIActionRowComponent, APIModalActionRowComponent } from '../channel.ts'; +import type { MessageFlags } from '../mod.ts'; +import type { APIApplicationCommandOptionChoice } from './applicationCommands.ts'; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type + */ +export enum InteractionType { + Ping = 1, + ApplicationCommand, + MessageComponent, + ApplicationCommandAutocomplete, + ModalSubmit, +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object + */ +export type APIInteractionResponse = + | APIInteractionResponsePong + | APIInteractionResponseChannelMessageWithSource + | APIInteractionResponseDeferredChannelMessageWithSource + | APIInteractionResponseDeferredMessageUpdate + | APIInteractionResponseUpdateMessage + | APIApplicationCommandAutocompleteResponse + | APIModalInteractionResponse; + +export interface APIInteractionResponsePong { + type: InteractionResponseType.Pong; +} + +export interface APIApplicationCommandAutocompleteResponse { + type: InteractionResponseType.ApplicationCommandAutocompleteResult; + data: APICommandAutocompleteInteractionResponseCallbackData; +} + +export interface APIModalInteractionResponse { + type: InteractionResponseType.Modal; + data: APIModalInteractionResponseCallbackData; +} + +export interface APIInteractionResponseChannelMessageWithSource { + type: InteractionResponseType.ChannelMessageWithSource; + data: APIInteractionResponseCallbackData; +} + +export interface APIInteractionResponseDeferredChannelMessageWithSource { + type: InteractionResponseType.DeferredChannelMessageWithSource; + data?: Pick; +} + +export interface APIInteractionResponseDeferredMessageUpdate { + type: InteractionResponseType.DeferredMessageUpdate; +} + +export interface APIInteractionResponseUpdateMessage { + type: InteractionResponseType.UpdateMessage; + data?: APIInteractionResponseCallbackData; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type + */ +export enum InteractionResponseType { + /** + * ACK a `Ping` + */ + Pong = 1, + /** + * Respond to an interaction with a message + */ + ChannelMessageWithSource = 4, + /** + * ACK an interaction and edit to a response later, the user sees a loading state + */ + DeferredChannelMessageWithSource, + /** + * ACK a button interaction and update it to a loading state + */ + DeferredMessageUpdate, + /** + * ACK a button interaction and edit the message to which the button was attached + */ + UpdateMessage, + /** + * For autocomplete interactions + */ + ApplicationCommandAutocompleteResult, + /** + * Respond to an interaction with an modal for a user to fill-out + */ + Modal, +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-data-structure + */ +export type APIInteractionResponseCallbackData = Omit< + RESTPostAPIWebhookWithTokenJSONBody, + 'username' | 'avatar_url' +> & { flags?: MessageFlags }; + +export interface APICommandAutocompleteInteractionResponseCallbackData { + choices?: APIApplicationCommandOptionChoice[]; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-modal + */ +export interface APIModalInteractionResponseCallbackData { + /** + * A developer-defined identifier for the component, max 100 characters + */ + custom_id: string; + /** + * The title of the popup modal + */ + title: string; + /** + * Between 1 and 5 (inclusive) components that make up the modal + */ + components: APIActionRowComponent[]; +} diff --git a/deno/payloads/v10/application.ts b/deno/payloads/v10/application.ts new file mode 100644 index 000000000..306c919c3 --- /dev/null +++ b/deno/payloads/v10/application.ts @@ -0,0 +1,115 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/application + */ + +import type { Snowflake } from '../../globals.ts'; +import type { APITeam } from './teams.ts'; +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/resources/application#application-object + */ +export interface APIApplication { + /** + * The id of the app + */ + id: Snowflake; + /** + * The name of the app + */ + name: string; + /** + * The icon hash of the app + */ + icon: string | null; + /** + * The description of the app + */ + description: string; + /** + * An array of rpc origin urls, if rpc is enabled + */ + rpc_origins?: string[]; + /** + * When `false` only app owner can join the app's bot to guilds + */ + bot_public: boolean; + /** + * When `true` the app's bot will only join upon completion of the full oauth2 code grant flow + */ + bot_require_code_grant: boolean; + /** + * The url of the application's terms of service + */ + terms_of_service_url?: string; + /** + * The url of the application's privacy policy + */ + privacy_policy_url?: string; + /** + * Partial user object containing info on the owner of the application + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + owner?: APIUser; + /** + * If this application is a game sold on Discord, this field will be the summary field for the store page + * of its primary sku + * + * @deprecated Always an empty string, will be removed in v11 + */ + summary: ''; + /** + * The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function + * + * See https://discord.com/developers/docs/game-sdk/applications#get-ticket + */ + verify_key: string; + /** + * The team this application belongs to + * + * See https://discord.com/developers/docs/topics/teams#data-models-team-object + */ + team: APITeam | null; + /** + * If this application is a game sold on Discord, this field will be the guild to which it has been linked + */ + guild_id?: Snowflake; + /** + * If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists + */ + primary_sku_id?: Snowflake; + /** + * If this application is a game sold on Discord, this field will be the URL slug that links to the store page + */ + slug?: string; + /** + * If this application is a game sold on Discord, this field will be the hash of the image on store embeds + */ + cover_image?: string; + /** + * The application's public flags + * + * See https://discord.com/developers/docs/resources/application#application-object-application-flags + */ + flags: ApplicationFlags; +} + +/** + * https://discord.com/developers/docs/resources/application#application-object-application-flags + */ +export enum ApplicationFlags { + EmbeddedReleased = 1 << 1, + ManagedEmoji = 1 << 2, + GroupDMCreate = 1 << 4, + RPCHasConnected = 1 << 11, + GatewayPresence = 1 << 12, + GatewayPresenceLimited = 1 << 13, + GatewayGuildMembers = 1 << 14, + GatewayGuildMembersLimited = 1 << 15, + VerificationPendingGuildLimit = 1 << 16, + Embedded = 1 << 17, + GatewayMessageContent = 1 << 18, + GatewayMessageContentLimited = 1 << 19, + EmbeddedFirstParty = 1 << 20, +} diff --git a/deno/payloads/v10/auditLog.ts b/deno/payloads/v10/auditLog.ts new file mode 100644 index 000000000..ab5c7a6aa --- /dev/null +++ b/deno/payloads/v10/auditLog.ts @@ -0,0 +1,702 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/audit-log + */ + +import type { Snowflake } from '../../globals.ts'; +import type { APIChannel, APIOverwrite } from './channel.ts'; +import type { + APIGuildIntegration, + GuildDefaultMessageNotifications, + GuildExplicitContentFilter, + GuildMFALevel, + GuildVerificationLevel, + IntegrationExpireBehavior, +} from './guild.ts'; +import type { + APIGuildScheduledEvent, + GuildScheduledEventEntityType, + GuildScheduledEventStatus, +} from './guildScheduledEvent.ts'; +import type { APIRole } from './permissions.ts'; +import type { StageInstancePrivacyLevel } from './stageInstance.ts'; +import type { StickerFormatType } from './sticker.ts'; +import type { APIUser } from './user.ts'; +import type { APIWebhook } from './webhook.ts'; + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure + */ +export interface APIAuditLog { + /** + * Webhooks found in the audit log + * + * See https://discord.com/developers/docs/resources/webhook#webhook-object + */ + webhooks: APIWebhook[]; + /** + * Users found in the audit log + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + users: APIUser[]; + /** + * Audit log entries + * + * See https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object + */ + audit_log_entries: APIAuditLogEntry[]; + /** + * Partial integration objects + * + * See https://discord.com/developers/docs/resources/guild#integration-object + */ + integrations: APIGuildIntegration[]; + /** + * Threads found in the audit log + * + * Threads referenced in THREAD_CREATE and THREAD_UPDATE events are included in the threads map, since archived threads might not be kept in memory by clients. + * + * See https://discord.com/developers/docs/resources/channel#channel-object + */ + threads: APIChannel[]; + /** + * The guild scheduled events in the audit log + * + * See https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object + */ + guild_scheduled_events: APIGuildScheduledEvent[]; +} + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure + */ +export interface APIAuditLogEntry { + /** + * ID of the affected entity (webhook, user, role, etc.) + */ + target_id: string | null; + /** + * Changes made to the `target_id` + * + * See https://discord.com/developers/docs/resources/audit-log#audit-log-change-object + */ + changes?: APIAuditLogChange[]; + /** + * The user who made the changes + * + * This can be `null` in some cases (webhooks deleting themselves by using their own token, for example) + */ + user_id: Snowflake | null; + /** + * ID of the entry + */ + id: Snowflake; + /** + * Type of action that occurred + * + * See https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events + */ + action_type: AuditLogEvent; + /** + * Additional info for certain action types + * + * See https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info + */ + options?: APIAuditLogOptions; + /** + * The reason for the change (0-512 characters) + */ + reason?: string; +} + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events + */ +export enum AuditLogEvent { + GuildUpdate = 1, + + ChannelCreate = 10, + ChannelUpdate, + ChannelDelete, + ChannelOverwriteCreate, + ChannelOverwriteUpdate, + ChannelOverwriteDelete, + + MemberKick = 20, + MemberPrune, + MemberBanAdd, + MemberBanRemove, + MemberUpdate, + MemberRoleUpdate, + MemberMove, + MemberDisconnect, + BotAdd, + + RoleCreate = 30, + RoleUpdate, + RoleDelete, + + InviteCreate = 40, + InviteUpdate, + InviteDelete, + + WebhookCreate = 50, + WebhookUpdate, + WebhookDelete, + + EmojiCreate = 60, + EmojiUpdate, + EmojiDelete, + + MessageDelete = 72, + MessageBulkDelete, + MessagePin, + MessageUnpin, + + IntegrationCreate = 80, + IntegrationUpdate, + IntegrationDelete, + StageInstanceCreate, + StageInstanceUpdate, + StageInstanceDelete, + + StickerCreate = 90, + StickerUpdate, + StickerDelete, + + GuildScheduledEventCreate = 100, + GuildScheduledEventUpdate, + GuildScheduledEventDelete, + + ThreadCreate = 110, + ThreadUpdate, + ThreadDelete, +} + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info + */ +export interface APIAuditLogOptions { + /** + * Number of days after which inactive members were kicked + * + * Present from: + * - MEMBER_PRUNE + */ + delete_member_days?: string; + /** + * Number of members removed by the prune + * + * Present from: + * - MEMBER_PRUNE + */ + members_removed?: string; + + /** + * Channel in which the entities were targeted + * + * Present from: + * - MEMBER_MOVE + * - MESSAGE_PIN + * - MESSAGE_UNPIN + * - MESSAGE_DELETE + * - STAGE_INSTANCE_CREATE + * - STAGE_INSTANCE_UPDATE + * - STAGE_INSTANCE_DELETE + */ + channel_id?: Snowflake; + + /** + * ID of the message that was targeted + * + * Present from: + * - MESSAGE_PIN + * - MESSAGE_UNPIN + */ + message_id?: Snowflake; + + /** + * Number of entities that were targeted + * + * Present from: + * - MESSAGE_DELETE + * - MESSAGE_BULK_DELETE + * - MEMBER_DISCONNECT + * - MEMBER_MOVE + */ + count?: string; + + /** + * ID of the overwritten entity + * + * Present from: + * - CHANNEL_OVERWRITE_CREATE + * - CHANNEL_OVERWRITE_UPDATE + * - CHANNEL_OVERWRITE_DELETE + */ + id?: Snowflake; + + /** + * Type of overwritten entity - "0" for "role" or "1" for "member" + * + * Present from: + * - CHANNEL_OVERWRITE_CREATE + * - CHANNEL_OVERWRITE_UPDATE + * - CHANNEL_OVERWRITE_DELETE + * + * {@link AuditLogOptionsType} + */ + type?: AuditLogOptionsType; + + /** + * Name of the role + * + * Present from: + * - CHANNEL_OVERWRITE_CREATE + * - CHANNEL_OVERWRITE_UPDATE + * - CHANNEL_OVERWRITE_DELETE + * + * **Present only if the {@link APIAuditLogOptions#type entry type} is "0"** + */ + role_name?: string; +} + +export enum AuditLogOptionsType { + Role = '0', + Member = '1', +} + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure + */ +export type APIAuditLogChange = + | APIAuditLogChangeKeyName + | APIAuditLogChangeKeyDescription + | APIAuditLogChangeKeyIconHash + | APIAuditLogChangeKeySplashHash + | APIAuditLogChangeKeyDiscoverySplashHash + | APIAuditLogChangeKeyBannerHash + | APIAuditLogChangeKeyOwnerId + | APIAuditLogChangeKeyRegion + | APIAuditLogChangeKeyPreferredLocale + | APIAuditLogChangeKeyAFKChannelId + | APIAuditLogChangeKeyAFKTimeout + | APIAuditLogChangeKeyRulesChannelId + | APIAuditLogChangeKeyPublicUpdatesChannelId + | APIAuditLogChangeKeyMFALevel + | APIAuditLogChangeKeyVerificationLevel + | APIAuditLogChangeKeyExplicitContentFilter + | APIAuditLogChangeKeyDefaultMessageNotifications + | APIAuditLogChangeKeyVanityURLCode + | APIAuditLogChangeKey$Add + | APIAuditLogChangeKey$Remove + | APIAuditLogChangeKeyPruneDeleteDays + | APIAuditLogChangeKeyWidgetEnabled + | APIAuditLogChangeKeyWidgetChannelId + | APIAuditLogChangeKeySystemChannelId + | APIAuditLogChangeKeyPosition + | APIAuditLogChangeKeyTopic + | APIAuditLogChangeKeyBitrate + | APIAuditLogChangeKeyPermissionOverwrites + | APIAuditLogChangeKeyNSFW + | APIAuditLogChangeKeyApplicationId + | APIAuditLogChangeKeyRateLimitPerUser + | APIAuditLogChangeKeyPermissions + | APIAuditLogChangeKeyColor + | APIAuditLogChangeKeyHoist + | APIAuditLogChangeKeyMentionable + | APIAuditLogChangeKeyAllow + | APIAuditLogChangeKeyDeny + | APIAuditLogChangeKeyCode + | APIAuditLogChangeKeyChannelId + | APIAuditLogChangeKeyInviterId + | APIAuditLogChangeKeyMaxUses + | APIAuditLogChangeKeyUses + | APIAuditLogChangeKeyMaxAge + | APIAuditLogChangeKeyTemporary + | APIAuditLogChangeKeyDeaf + | APIAuditLogChangeKeyMute + | APIAuditLogChangeKeyNick + | APIAuditLogChangeKeyAvatarHash + | APIAuditLogChangeKeyId + | APIAuditLogChangeKeyType + | APIAuditLogChangeKeyEnableEmoticons + | APIAuditLogChangeKeyExpireBehavior + | APIAuditLogChangeKeyExpireGracePeriod + | APIAuditLogChangeKeyUserLimit + | APIAuditLogChangeKeyPrivacyLevel + | APIAuditLogChangeKeyTags + | APIAuditLogChangeKeyFormatType + | APIAuditLogChangeKeyAsset + | APIAuditLogChangeKeyAvailable + | APIAuditLogChangeKeyGuildId + | APIAuditLogChangeKeyArchived + | APIAuditLogChangeKeyLocked + | APIAuditLogChangeKeyAutoArchiveDuration + | APIAuditLogChangeKeyDefaultAutoArchiveDuration + | APIAuditLogChangeKeyEntityType + | APIAuditLogChangeKeyStatus + | APIAuditLogChangeKeyLocation + | APIAuditLogChangeKeyCommunicationDisabledUntil; + +/** + * Returned when an entity's name is changed + */ +export type APIAuditLogChangeKeyName = AuditLogChangeData<'name', string>; + +/** + * Returned when a guild's or sticker's or guild scheduled event's description is changed + */ +export type APIAuditLogChangeKeyDescription = AuditLogChangeData<'description', string>; + +/** + * Returned when a guild's icon is changed + */ +export type APIAuditLogChangeKeyIconHash = AuditLogChangeData<'icon_hash', string>; + +/** + * Returned when a guild's splash is changed + */ +export type APIAuditLogChangeKeySplashHash = AuditLogChangeData<'splash_hash', string>; + +/** + * Returned when a guild's discovery splash is changed + */ +export type APIAuditLogChangeKeyDiscoverySplashHash = AuditLogChangeData<'discovery_splash_hash', string>; + +/** + * Returned when a guild's banner hash is changed + */ +export type APIAuditLogChangeKeyBannerHash = AuditLogChangeData<'banner_hash', string>; + +/** + * Returned when a guild's owner_id is changed + */ +export type APIAuditLogChangeKeyOwnerId = AuditLogChangeData<'owner_id', Snowflake>; + +/** + * Returned when a guild's region is changed + */ +export type APIAuditLogChangeKeyRegion = AuditLogChangeData<'region', string>; + +/** + * Returned when a guild's preferred_locale is changed + */ +export type APIAuditLogChangeKeyPreferredLocale = AuditLogChangeData<'preferred_locale', string>; + +/** + * Returned when a guild's afk_channel_id is changed + */ +export type APIAuditLogChangeKeyAFKChannelId = AuditLogChangeData<'afk_channel_id', Snowflake>; + +/** + * Returned when a guild's afk_timeout is changed + */ +export type APIAuditLogChangeKeyAFKTimeout = AuditLogChangeData<'afk_timeout', number>; + +/** + * Returned when a guild's rules_channel_id is changed + */ +export type APIAuditLogChangeKeyRulesChannelId = AuditLogChangeData<'rules_channel_id', string>; + +/** + * Returned when a guild's public_updates_channel_id is changed + */ +export type APIAuditLogChangeKeyPublicUpdatesChannelId = AuditLogChangeData<'public_updates_channel_id', string>; + +/** + * Returned when a guild's mfa_level is changed + */ +export type APIAuditLogChangeKeyMFALevel = AuditLogChangeData<'mfa_level', GuildMFALevel>; + +/** + * Returned when a guild's verification_level is changed + */ +export type APIAuditLogChangeKeyVerificationLevel = AuditLogChangeData<'verification_level', GuildVerificationLevel>; + +/** + * Returned when a guild's explicit_content_filter is changed + */ +export type APIAuditLogChangeKeyExplicitContentFilter = AuditLogChangeData< + 'explicit_content_filter', + GuildExplicitContentFilter +>; + +/** + * Returned when a guild's default_message_notifications is changed + */ +export type APIAuditLogChangeKeyDefaultMessageNotifications = AuditLogChangeData< + 'default_message_notifications', + GuildDefaultMessageNotifications +>; + +/** + * Returned when a guild's vanity_url_code is changed + */ +export type APIAuditLogChangeKeyVanityURLCode = AuditLogChangeData<'vanity_url_code', string>; + +/** + * Returned when new role(s) are added + */ +export type APIAuditLogChangeKey$Add = AuditLogChangeData<'$add', APIRole[]>; + +/** + * Returned when role(s) are removed + */ +export type APIAuditLogChangeKey$Remove = AuditLogChangeData<'$remove', APIRole[]>; + +/** + * Returned when there is a change in number of days after which inactive and role-unassigned members are kicked + */ +export type APIAuditLogChangeKeyPruneDeleteDays = AuditLogChangeData<'prune_delete_days', number>; + +/** + * Returned when a guild's widget is enabled + */ +export type APIAuditLogChangeKeyWidgetEnabled = AuditLogChangeData<'widget_enabled', boolean>; + +/** + * Returned when a guild's widget_channel_id is changed + */ +export type APIAuditLogChangeKeyWidgetChannelId = AuditLogChangeData<'widget_channel_id', Snowflake>; + +/** + * Returned when a guild's system_channel_id is changed + */ +export type APIAuditLogChangeKeySystemChannelId = AuditLogChangeData<'system_channel_id', Snowflake>; + +/** + * Returned when a channel's position is changed + */ +export type APIAuditLogChangeKeyPosition = AuditLogChangeData<'position', number>; + +/** + * Returned when a channel's topic is changed + */ +export type APIAuditLogChangeKeyTopic = AuditLogChangeData<'topic', string>; + +/** + * Returned when a voice channel's bitrate is changed + */ +export type APIAuditLogChangeKeyBitrate = AuditLogChangeData<'bitrate', number>; + +/** + * Returned when a channel's permission overwrites is changed + */ +export type APIAuditLogChangeKeyPermissionOverwrites = AuditLogChangeData<'permission_overwrites', APIOverwrite[]>; + +/** + * Returned when a channel's NSFW restriction is changed + */ +export type APIAuditLogChangeKeyNSFW = AuditLogChangeData<'nsfw', boolean>; + +/** + * The application ID of the added or removed Webhook or Bot + */ +export type APIAuditLogChangeKeyApplicationId = AuditLogChangeData<'application_id', Snowflake>; + +/** + * Returned when a channel's amount of seconds a user has to wait before sending another message + * is changed + */ +export type APIAuditLogChangeKeyRateLimitPerUser = AuditLogChangeData<'rate_limit_per_user', number>; + +/** + * Returned when a permission bitfield is changed + */ +export type APIAuditLogChangeKeyPermissions = AuditLogChangeData<'permissions', string>; + +/** + * Returned when a role's color is changed + */ +export type APIAuditLogChangeKeyColor = AuditLogChangeData<'color', number>; + +/** + * Returned when a role's hoist status is changed + */ +export type APIAuditLogChangeKeyHoist = AuditLogChangeData<'hoist', boolean>; + +/** + * Returned when a role's mentionable status is changed + */ +export type APIAuditLogChangeKeyMentionable = AuditLogChangeData<'mentionable', boolean>; + +/** + * Returned when an overwrite's allowed permissions bitfield is changed + */ +export type APIAuditLogChangeKeyAllow = AuditLogChangeData<'allow', string>; + +/** + * Returned when an overwrite's denied permissions bitfield is changed + */ +export type APIAuditLogChangeKeyDeny = AuditLogChangeData<'deny', string>; + +/** + * Returned when an invite's code is changed + */ +export type APIAuditLogChangeKeyCode = AuditLogChangeData<'code', string>; + +/** + * Returned when an invite's or guild scheduled event's channel_id is changed + */ +export type APIAuditLogChangeKeyChannelId = AuditLogChangeData<'channel_id', Snowflake>; + +/** + * Returned when an invite's inviter_id is changed + */ +export type APIAuditLogChangeKeyInviterId = AuditLogChangeData<'inviter_id', Snowflake>; + +/** + * Returned when an invite's max_uses is changed + */ +export type APIAuditLogChangeKeyMaxUses = AuditLogChangeData<'max_uses', number>; + +/** + * Returned when an invite's uses is changed + */ +export type APIAuditLogChangeKeyUses = AuditLogChangeData<'uses', number>; + +/** + * Returned when an invite's max_age is changed + */ +export type APIAuditLogChangeKeyMaxAge = AuditLogChangeData<'max_age', number>; + +/** + * Returned when an invite's temporary status is changed + */ +export type APIAuditLogChangeKeyTemporary = AuditLogChangeData<'temporary', boolean>; + +/** + * Returned when a user's deaf status is changed + */ +export type APIAuditLogChangeKeyDeaf = AuditLogChangeData<'deaf', boolean>; + +/** + * Returned when a user's mute status is changed + */ +export type APIAuditLogChangeKeyMute = AuditLogChangeData<'mute', boolean>; + +/** + * Returned when a user's nick is changed + */ +export type APIAuditLogChangeKeyNick = AuditLogChangeData<'nick', string>; + +/** + * Returned when a user's avatar_hash is changed + */ +export type APIAuditLogChangeKeyAvatarHash = AuditLogChangeData<'avatar_hash', string>; + +/** + * The ID of the changed entity - sometimes used in conjunction with other keys + */ +export type APIAuditLogChangeKeyId = AuditLogChangeData<'id', Snowflake>; + +/** + * The type of entity created + */ +export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', number | string>; + +/** + * Returned when an integration's enable_emoticons is changed + */ +export type APIAuditLogChangeKeyEnableEmoticons = AuditLogChangeData<'enable_emoticons', boolean>; + +/** + * Returned when an integration's expire_behavior is changed + */ +export type APIAuditLogChangeKeyExpireBehavior = AuditLogChangeData<'expire_behavior', IntegrationExpireBehavior>; + +/** + * Returned when an integration's expire_grace_period is changed + */ +export type APIAuditLogChangeKeyExpireGracePeriod = AuditLogChangeData<'expire_grace_period', number>; + +/** + * Returned when a voice channel's user_limit is changed + */ +export type APIAuditLogChangeKeyUserLimit = AuditLogChangeData<'user_limit', number>; + +/** + * Returned when privacy level of a stage instance or guild scheduled event is changed + */ +export type APIAuditLogChangeKeyPrivacyLevel = AuditLogChangeData<'privacy_level', StageInstancePrivacyLevel>; + +/** + * Returned when a sticker's related emoji is changed + */ +export type APIAuditLogChangeKeyTags = AuditLogChangeData<'tags', string>; + +/** + * Returned when a sticker's format_type is changed + */ +export type APIAuditLogChangeKeyFormatType = AuditLogChangeData<'format_type', StickerFormatType>; + +/** + * Empty string + */ +export type APIAuditLogChangeKeyAsset = AuditLogChangeData<'asset', ''>; + +/** + * Returned when a sticker's availability is changed + */ +export type APIAuditLogChangeKeyAvailable = AuditLogChangeData<'available', boolean>; + +/** + * Returned when a sticker's guild_id is changed + */ +export type APIAuditLogChangeKeyGuildId = AuditLogChangeData<'guild_id', Snowflake>; + +/* + * Returned when a thread's archive status is changed + */ +export type APIAuditLogChangeKeyArchived = AuditLogChangeData<'archived', boolean>; + +/* + * Returned when a thread's lock status is changed + */ +export type APIAuditLogChangeKeyLocked = AuditLogChangeData<'locked', boolean>; + +/* + * Returned when a thread's auto archive duration is changed + */ +export type APIAuditLogChangeKeyAutoArchiveDuration = AuditLogChangeData<'auto_archive_duration', number>; + +/* + * Returned when a channel's default auto archive duration for newly created threads is changed + */ +export type APIAuditLogChangeKeyDefaultAutoArchiveDuration = AuditLogChangeData< + 'default_auto_archive_duration', + number +>; + +/** + * Returned when entity type of a guild scheduled event is changed + */ +export type APIAuditLogChangeKeyEntityType = AuditLogChangeData<'entity_type', GuildScheduledEventEntityType>; + +/** + * Returned when status of a guild scheduled event is changed + */ +export type APIAuditLogChangeKeyStatus = AuditLogChangeData<'status', GuildScheduledEventStatus>; + +/** + * Returned when location of a guild scheduled event is changed + */ +export type APIAuditLogChangeKeyLocation = AuditLogChangeData<'location', string>; + +/** + * Returned when a user's timeout is changed + */ +export type APIAuditLogChangeKeyCommunicationDisabledUntil = AuditLogChangeData<'communication_disabled_until', string>; + +interface AuditLogChangeData { + key: K; + /** + * The new value + * + * If `new_value` is not present in the change object, while `old_value` is, + * that means the property that was changed has been reset, or set to `null` + */ + new_value?: D; + old_value?: D; +} diff --git a/deno/payloads/v10/channel.ts b/deno/payloads/v10/channel.ts new file mode 100644 index 000000000..8667433c6 --- /dev/null +++ b/deno/payloads/v10/channel.ts @@ -0,0 +1,1377 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/channel + */ + +import type { Permissions, Snowflake } from '../../globals.ts'; +import type { APIApplication } from './application.ts'; +import type { APIPartialEmoji } from './emoji.ts'; +import type { APIGuildMember } from './guild.ts'; +import type { APIMessageInteraction } from './interactions.ts'; +import type { APIRole } from './permissions.ts'; +import type { APISticker, APIStickerItem } from './sticker.ts'; +import type { APIUser } from './user.ts'; + +/** + * Not documented, but partial only includes id, name, and type + */ +export interface APIPartialChannel { + /** + * The id of the channel + */ + id: Snowflake; + /** + * The type of the channel + * + * See https://discord.com/developers/docs/resources/channel#channel-object-channel-types + */ + type: ChannelType; + /** + * The name of the channel (2-100 characters) + */ + name?: string; +} + +/** + * This interface is used to allow easy extension for other channel types. While + * also allowing `APIPartialChannel` to be used without breaking. + */ +export interface APIChannelBase extends APIPartialChannel { + type: T; +} + +// TODO: update when text in voice is released +export type TextChannelType = + | ChannelType.DM + | ChannelType.GroupDM + | ChannelType.GuildNews + | ChannelType.GuildPublicThread + | ChannelType.GuildPrivateThread + | ChannelType.GuildNewsThread + | ChannelType.GuildText; + +export type GuildChannelType = Exclude< + | TextChannelType + | ChannelType.GuildVoice + | ChannelType.GuildStageVoice + | ChannelType.GuildNews + | ChannelType.GuildStore, + ChannelType.DM | ChannelType.GroupDM +>; + +export interface APITextBasedChannel extends APIChannelBase { + /** + * The id of the last message sent in this channel (may not point to an existing or valid message) + */ + last_message_id?: Snowflake | null; +} + +export interface APIGuildChannel extends APIChannelBase { + /** + * The id of the guild (may be missing for some channel objects received over gateway guild dispatches) + */ + guild_id?: Snowflake; + /** + * Explicit permission overwrites for members and roles + * + * See https://discord.com/developers/docs/resources/channel#overwrite-object + */ + permission_overwrites?: APIOverwrite[]; + /** + * Sorting position of the channel + */ + position?: number; + /** + * ID of the parent category for a channel (each parent category can contain up to 50 channels) + * + * OR + * + * ID of the parent channel for a thread + */ + parent_id?: Snowflake | null; + /** + * Whether the channel is nsfw + */ + nsfw?: boolean; +} + +export type GuildTextChannelType = Exclude; + +export interface APIGuildTextChannel + extends APITextBasedChannel, + APIGuildChannel { + /** + * Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity + */ + default_auto_archive_duration?: ThreadAutoArchiveDuration; + /** + * The channel topic (0-1024 characters) + */ + topic?: string | null; + /** + * When the last pinned message was pinned. + * This may be `null` in events such as `GUILD_CREATE` when a message is not pinned + */ + last_pin_timestamp?: string | null; +} + +export interface APITextChannel extends APIGuildTextChannel { + /** + * Amount of seconds a user has to wait before sending another message (0-21600); + * bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected + * + * `rate_limit_per_user` also applies to thread creation. Users can send one message and create one thread during each `rate_limit_per_user` interval. + * + * For thread channels, `rate_limit_per_user` is only returned if the field is set to a non-zero and non-null value. + * The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value. + */ + rate_limit_per_user?: number; +} + +export type APINewsChannel = APIGuildTextChannel; +export type APIGuildCategoryChannel = APIGuildChannel; +export type APIGuildStoreChannel = APIGuildChannel; + +export interface APIVoiceChannel extends APIGuildChannel { + /** + * The bitrate (in bits) of the voice channel + */ + bitrate?: number; + /** + * The user limit of the voice channel + */ + user_limit?: number; + /** + * Voice region id for the voice or stage channel, automatic when set to `null` + * + * See https://discord.com/developers/docs/resources/voice#voice-region-object + */ + rtc_region?: string | null; + /** + * The camera video quality mode of the voice channel, `1` when not present + * + * See https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes + */ + video_quality_mode?: VideoQualityMode; +} + +interface APIDMChannelBase extends APITextBasedChannel { + /** + * The recipients of the DM + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + recipients?: APIUser[]; +} + +export type APIDMChannel = APIDMChannelBase; + +export interface APIGroupDMChannel extends APIDMChannelBase { + /** + * Application id of the group DM creator if it is bot-created + */ + application_id?: Snowflake; + /** + * Icon hash + */ + icon?: string | null; + /** + * ID of the DM creator + */ + owner_id?: Snowflake; + /** + * The id of the last message sent in this channel (may not point to an existing or valid message) + */ + last_message_id?: Snowflake | null; +} + +export interface APIThreadChannel + extends APIGuildChannel< + ChannelType.GuildPublicThread | ChannelType.GuildPrivateThread | ChannelType.GuildNewsThread + > { + /** + * The client users member for the thread, only included in select endpoints + */ + member?: APIThreadMember; + /** + * The metadata for a thread channel not shared by other channels + */ + thread_metadata?: APIThreadMetadata; + /** + * The approximate message count of the thread, does not count above 50 even if there are more messages + */ + message_count?: number; + /** + * The approximate member count of the thread, does not count above 50 even if there are more members + */ + member_count?: number; + /** + * Amount of seconds a user has to wait before sending another message (0-21600); + * bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected + * + * `rate_limit_per_user` also applies to thread creation. Users can send one message and create one thread during each `rate_limit_per_user` interval. + * + * For thread channels, `rate_limit_per_user` is only returned if the field is set to a non-zero and non-null value. + * The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value. + */ + rate_limit_per_user?: number; + /** + * ID of the thread creator + */ + owner_id?: Snowflake; + /** + * The id of the last message sent in this thread (may not point to an existing or valid message) + */ + last_message_id?: Snowflake | null; +} + +/** + * https://discord.com/developers/docs/resources/channel#channel-object-channel-structure + */ +export type APIChannel = + | APIGroupDMChannel + | APIDMChannel + | APITextChannel + | APINewsChannel + | APIGuildStoreChannel + | APIVoiceChannel + | APIGuildCategoryChannel + | APIThreadChannel + | APINewsChannel; + +/** + * https://discord.com/developers/docs/resources/channel#channel-object-channel-types + */ +export enum ChannelType { + /** + * A text channel within a guild + */ + GuildText, + /** + * A direct message between users + */ + DM, + /** + * A voice channel within a guild + */ + GuildVoice, + /** + * A direct message between multiple users + */ + GroupDM, + /** + * An organizational category that contains up to 50 channels + * + * See https://support.discord.com/hc/en-us/articles/115001580171-Channel-Categories-101 + */ + GuildCategory, + /** + * A channel that users can follow and crosspost into their own guild + * + * See https://support.discord.com/hc/en-us/articles/360032008192 + */ + GuildNews, + /** + * A channel in which game developers can sell their game on Discord + * + * See https://discord.com/developers/docs/game-and-server-management/special-channels + */ + GuildStore, + /** + * A thread channel (public) within a Guild News channel + */ + GuildNewsThread = 10, + /** + * A public thread channel within a Guild Text channel + */ + GuildPublicThread, + /** + * A private thread channel within a Guild Text channel + */ + GuildPrivateThread, + /** + * A voice channel for hosting events with an audience + * + * See https://support.discord.com/hc/en-us/articles/1500005513722 + */ + GuildStageVoice, +} + +export enum VideoQualityMode { + /** + * Discord chooses the quality for optimal performance + */ + Auto = 1, + /** + * 720p + */ + Full, +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-structure + */ +export interface APIMessage { + /** + * ID of the message + */ + id: Snowflake; + /** + * ID of the channel the message was sent in + */ + channel_id: Snowflake; + /** + * ID of the guild the message was sent in + */ + guild_id?: Snowflake; + /** + * The author of this message (only a valid user in the case where the message is generated by a user or bot user) + * + * If the message is generated by a webhook, the author object corresponds to the webhook's id, + * username, and avatar. You can tell if a message is generated by a webhook by checking for the `webhook_id` property + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + author: APIUser; + /** + * Member properties for this message's author + * + * The member object exists in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events + * from text-based guild channels + * + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ + member?: APIGuildMember; + /** + * Contents of the message + */ + content: string; + /** + * When this message was sent + */ + timestamp: string; + /** + * When this message was edited (or null if never) + */ + edited_timestamp: string | null; + /** + * Whether this was a TTS message + */ + tts: boolean; + /** + * Whether this message mentions everyone + */ + mention_everyone: boolean; + /** + * Users specifically mentioned in the message + * + * The `member` field is only present in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events + * from text-based guild channels + * + * See https://discord.com/developers/docs/resources/user#user-object + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ + mentions: (APIUser & { member?: Omit })[]; + /** + * Roles specifically mentioned in this message + * + * See https://discord.com/developers/docs/topics/permissions#role-object + */ + mention_roles: APIRole['id'][]; + /** + * Channels specifically mentioned in this message + * + * Not all channel mentions in a message will appear in `mention_channels`. + * - Only textual channels that are visible to everyone in a lurkable guild will ever be included + * - Only crossposted messages (via Channel Following) currently include `mention_channels` at all + * + * If no mentions in the message meet these requirements, this field will not be sent + * + * See https://discord.com/developers/docs/resources/channel#channel-mention-object + */ + mention_channels?: APIChannelMention[]; + /** + * Any attached files + * + * See https://discord.com/developers/docs/resources/channel#attachment-object + */ + attachments: APIAttachment[]; + /** + * Any embedded content + * + * See https://discord.com/developers/docs/resources/channel#embed-object + */ + embeds: APIEmbed[]; + /** + * Reactions to the message + * + * See https://discord.com/developers/docs/resources/channel#reaction-object + */ + reactions?: APIReaction[]; + /** + * A nonce that can be used for optimistic message sending (up to 25 characters) + * + * **You will not receive this from further fetches. This is received only once from a `MESSAGE_CREATE` + * event to ensure it got sent** + */ + nonce?: string | number; + /** + * Whether this message is pinned + */ + pinned: boolean; + /** + * If the message is generated by a webhook, this is the webhook's id + */ + webhook_id?: Snowflake; + /** + * Type of message + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-types + */ + type: MessageType; + /** + * Sent with Rich Presence-related chat embeds + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure + */ + activity?: APIMessageActivity; + /** + * Sent with Rich Presence-related chat embeds + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-application-structure + */ + application?: Partial; + /** + * If the message is a response to an Interaction, this is the id of the interaction's application + */ + application_id?: Snowflake; + /** + * Reference data sent with crossposted messages, replies, pins, and thread starter messages + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure + */ + message_reference?: APIMessageReference; + /** + * Message flags combined as a bitfield + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-flags + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + flags?: MessageFlags; + /** + * The message associated with the `message_reference` + * + * This field is only returned for messages with a `type` of `19` (REPLY). + * + * If the message is a reply but the `referenced_message` field is not present, + * the backend did not attempt to fetch the message that was being replied to, + * so its state is unknown. + * + * If the field exists but is `null`, the referenced message was deleted + * + * See https://discord.com/developers/docs/resources/channel#message-object + */ + referenced_message?: APIMessage | null; + /** + * Sent if the message is a response to an Interaction + */ + interaction?: APIMessageInteraction; + /** + * Sent if a thread was started from this message + */ + thread?: APIChannel; + /** + * Sent if the message contains components like buttons, action rows, or other interactive components + */ + components?: APIActionRowComponent[]; + /** + * Sent if the message contains stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-item-object + */ + sticker_items?: APIStickerItem[]; + /** + * The stickers sent with the message + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + * @deprecated Use `sticker_items` instead + */ + stickers?: APISticker[]; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-types + */ +export enum MessageType { + Default, + RecipientAdd, + RecipientRemove, + Call, + ChannelNameChange, + ChannelIconChange, + ChannelPinnedMessage, + GuildMemberJoin, + UserPremiumGuildSubscription, + UserPremiumGuildSubscriptionTier1, + UserPremiumGuildSubscriptionTier2, + UserPremiumGuildSubscriptionTier3, + ChannelFollowAdd, + GuildDiscoveryDisqualified = 14, + GuildDiscoveryRequalified, + GuildDiscoveryGracePeriodInitialWarning, + GuildDiscoveryGracePeriodFinalWarning, + ThreadCreated, + Reply, + ChatInputCommand, + ThreadStarterMessage, + GuildInviteReminder, + ContextMenuCommand, +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure + */ +export interface APIMessageActivity { + /** + * Type of message activity + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-activity-types + */ + type: MessageActivityType; + /** + * `party_id` from a Rich Presence event + * + * See https://discord.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields + */ + party_id?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure + */ +export interface APIMessageReference { + /** + * ID of the originating message + */ + message_id?: Snowflake; + /** + * ID of the originating message's channel + */ + channel_id: Snowflake; + /** + * ID of the originating message's guild + */ + guild_id?: Snowflake; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-activity-types + */ +export enum MessageActivityType { + Join = 1, + Spectate, + Listen, + JoinRequest = 5, +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-flags + */ +export enum MessageFlags { + /** + * This message has been published to subscribed channels (via Channel Following) + */ + Crossposted = 1 << 0, + /** + * This message originated from a message in another channel (via Channel Following) + */ + IsCrosspost = 1 << 1, + /** + * Do not include any embeds when serializing this message + */ + SuppressEmbeds = 1 << 2, + /** + * The source message for this crosspost has been deleted (via Channel Following) + */ + SourceMessageDeleted = 1 << 3, + /** + * This message came from the urgent message system + */ + Urgent = 1 << 4, + /** + * This message has an associated thread, which shares its id + */ + HasThread = 1 << 5, + /** + * This message is only visible to the user who invoked the Interaction + */ + Ephemeral = 1 << 6, + /** + * This message is an Interaction Response and the bot is "thinking" + */ + Loading = 1 << 7, + /** + * This message failed to mention some roles and add their members to the thread + */ + FailedToMentionSomeRolesInThread = 1 << 8, +} + +/** + * https://discord.com/developers/docs/resources/channel#followed-channel-object + */ +export interface APIFollowedChannel { + /** + * Source channel id + */ + channel_id: Snowflake; + /** + * Created target webhook id + */ + webhook_id: Snowflake; +} + +/** + * https://discord.com/developers/docs/resources/channel#reaction-object-reaction-structure + */ +export interface APIReaction { + /** + * Times this emoji has been used to react + */ + count: number; + /** + * Whether the current user reacted using this emoji + */ + me: boolean; + /** + * Emoji information + * + * See https://discord.com/developers/docs/resources/emoji#emoji-object + */ + emoji: APIPartialEmoji; +} + +/** + * https://discord.com/developers/docs/resources/channel#overwrite-object-overwrite-structure + */ +export interface APIOverwrite { + /** + * Role or user id + */ + id: Snowflake; + /** + * Either 0 (role) or 1 (member) + * + * {@link OverwriteType} + */ + type: OverwriteType; + /** + * Permission bit set + * + * See https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + allow: Permissions; + /** + * Permission bit set + * + * See https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + deny: Permissions; +} + +export enum OverwriteType { + Role, + Member, +} + +/** + * https://discord.com/developers/docs/resources/channel#thread-metadata-object-thread-metadata-structure + */ +export interface APIThreadMetadata { + /** + * Whether the thread is archived + */ + archived: boolean; + /** + * Duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 + */ + auto_archive_duration: ThreadAutoArchiveDuration; + /** + * An ISO8601 timestamp when the thread's archive status was last changed, used for calculating recent activity + */ + archive_timestamp: string; + /** + * Whether the thread is locked; when a thread is locked, only users with `MANAGE_THREADS` can unarchive it + */ + locked?: boolean; + /** + * Whether non-moderators can add other non-moderators to the thread; only available on private threads + */ + invitable?: boolean; + /** + * Timestamp when the thread was created; only populated for threads created after 2022-01-09 + */ + create_timestamp?: string; +} + +export enum ThreadAutoArchiveDuration { + OneHour = 60, + OneDay = 1440, + ThreeDays = 4320, + OneWeek = 10080, +} + +/** + * https://discord.com/developers/docs/resources/channel#thread-member-object-thread-member-structure + */ +export interface APIThreadMember { + /** + * The id of the thread + * + * **This field is omitted on the member sent within each thread in the `GUILD_CREATE` event** + */ + id?: Snowflake; + /** + * The id of the member + * + * **This field is omitted on the member sent within each thread in the `GUILD_CREATE` event** + */ + user_id?: Snowflake; + /** + * An ISO8601 timestamp for when the member last joined + */ + join_timestamp: string; + /** + * Member flags combined as a bitfield + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + flags: ThreadMemberFlags; +} + +export enum ThreadMemberFlags {} + +export interface APIThreadList { + /** + * The threads that were fetched + */ + threads: APIChannel[]; + /** + * The members for the client user in each of the fetched threads + */ + members: APIThreadMember[]; + /** + * Whether there are potentially additional threads + */ + has_more?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-structure + * + * Length limit: 6000 characters + */ +export interface APIEmbed { + /** + * Title of embed + * + * Length limit: 256 characters + */ + title?: string; + /** + * Type of embed (always "rich" for webhook embeds) + * + * @deprecated *Embed types should be considered deprecated and might be removed in a future API version* + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-types + */ + type?: EmbedType; + /** + * Description of embed + * + * Length limit: 4096 characters + */ + description?: string; + /** + * URL of embed + */ + url?: string; + /** + * Timestamp of embed content + */ + timestamp?: string; + /** + * Color code of the embed + */ + color?: number; + /** + * Footer information + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure + */ + footer?: APIEmbedFooter; + /** + * Image information + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure + */ + image?: APIEmbedImage; + /** + * Thumbnail information + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure + */ + thumbnail?: APIEmbedThumbnail; + /** + * Video information + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure + */ + video?: APIEmbedVideo; + /** + * Provider information + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure + */ + provider?: APIEmbedProvider; + /** + * Author information + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure + */ + author?: APIEmbedAuthor; + /** + * Fields information + * + * Length limit: 25 field objects + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure + */ + fields?: APIEmbedField[]; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-types + * @deprecated *Embed types should be considered deprecated and might be removed in a future API version* + */ +export enum EmbedType { + /** + * Generic embed rendered from embed attributes + */ + Rich = 'rich', + /** + * Image embed + */ + Image = 'image', + /** + * Video embed + */ + Video = 'video', + /** + * Animated gif image embed rendered as a video embed + */ + GIFV = 'gifv', + /** + * Article embed + */ + Article = 'article', + /** + * Link embed + */ + Link = 'link', +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure + */ +export interface APIEmbedThumbnail { + /** + * Source url of thumbnail (only supports http(s) and attachments) + */ + url: string; + /** + * A proxied url of the thumbnail + */ + proxy_url?: string; + /** + * Height of thumbnail + */ + height?: number; + /** + * Width of thumbnail + */ + width?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure + */ +export interface APIEmbedVideo { + /** + * Source url of video + */ + url?: string; + /** + * Height of video + */ + height?: number; + /** + * Width of video + */ + width?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure + */ +export interface APIEmbedImage { + /** + * Source url of image (only supports http(s) and attachments) + */ + url: string; + /** + * A proxied url of the image + */ + proxy_url?: string; + /** + * Height of image + */ + height?: number; + /** + * Width of image + */ + width?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure + */ +export interface APIEmbedProvider { + /** + * Name of provider + */ + name?: string; + /** + * URL of provider + */ + url?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure + */ +export interface APIEmbedAuthor { + /** + * Name of author + * + * Length limit: 256 characters + */ + name: string; + /** + * URL of author + */ + url?: string; + /** + * URL of author icon (only supports http(s) and attachments) + */ + icon_url?: string; + /** + * A proxied url of author icon + */ + proxy_icon_url?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure + */ +export interface APIEmbedFooter { + /** + * Footer text + * + * Length limit: 2048 characters + */ + text: string; + /** + * URL of footer icon (only supports http(s) and attachments) + */ + icon_url?: string; + /** + * A proxied url of footer icon + */ + proxy_icon_url?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure + */ +export interface APIEmbedField { + /** + * Name of the field + * + * Length limit: 256 characters + */ + name: string; + /** + * Value of the field + * + * Length limit: 1024 characters + */ + value: string; + /** + * Whether or not this field should display inline + */ + inline?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/channel#attachment-object-attachment-structure + */ +export interface APIAttachment { + /** + * Attachment id + */ + id: Snowflake; + /** + * Name of file attached + */ + filename: string; + /** + * Description for the file + */ + description?: string; + /** + * The attachment's media type + * + * See https://en.wikipedia.org/wiki/Media_type + */ + content_type?: string; + /** + * Size of file in bytes + */ + size: number; + /** + * Source url of file + */ + url: string; + /** + * A proxied url of file + */ + proxy_url: string; + /** + * Height of file (if image) + */ + height?: number | null; + /** + * Width of file (if image) + */ + width?: number | null; + /** + * Whether this attachment is ephemeral + */ + ephemeral?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/channel#channel-mention-object-channel-mention-structure + */ +export interface APIChannelMention { + /** + * ID of the channel + */ + id: Snowflake; + /** + * ID of the guild containing the channel + */ + guild_id: Snowflake; + /** + * The type of channel + * + * See https://discord.com/developers/docs/resources/channel#channel-object-channel-types + */ + type: ChannelType; + /** + * The name of the channel + */ + name: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types + */ +export enum AllowedMentionsTypes { + /** + * Controls @everyone and @here mentions + */ + Everyone = 'everyone', + /** + * Controls role mentions + */ + Role = 'roles', + /** + * Controls user mentions + */ + User = 'users', +} + +/** + * https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mentions-structure + */ +export interface APIAllowedMentions { + /** + * An array of allowed mention types to parse from the content + * + * See https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types + */ + parse?: AllowedMentionsTypes[]; + /** + * Array of role_ids to mention (Max size of 100) + */ + roles?: Snowflake[]; + /** + * Array of user_ids to mention (Max size of 100) + */ + users?: Snowflake[]; + /** + * For replies, whether to mention the author of the message being replied to (default false) + * + * @default false + */ + replied_user?: boolean; +} + +/** + * https://discord.com/developers/docs/interactions/message-components#component-object + */ +export interface APIBaseComponent { + /** + * The type of the component + */ + type: T; +} + +/** + * https://discord.com/developers/docs/interactions/message-components#component-types + */ +export enum ComponentType { + /** + * Action Row component + */ + ActionRow = 1, + /** + * Button component + */ + Button, + /** + * Select Menu component + */ + SelectMenu, + /** + * Text Input component + */ + TextInput, +} + +/** + * https://discord.com/developers/docs/interactions/message-components#action-rows + */ +export interface APIActionRowComponent + extends APIBaseComponent { + /** + * The components in the ActionRow + */ + components: T[]; +} + +/** + * https://discord.com/developers/docs/interactions/message-components#buttons + */ +interface APIButtonComponentBase