diff --git a/.gitignore b/.gitignore index 16e30cd..92f947f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ node_modules lib/ dist/ -__test__ \ No newline at end of file +__test__ +package-lock.json + diff --git a/biome.json b/biome.json index d4296f3..3b539fb 100644 --- a/biome.json +++ b/biome.json @@ -28,7 +28,8 @@ "noDefaultExport": "off", "noNamespaceImport": "off", "useSingleCaseStatement": "off", - "useBlockStatements": "off" + "useBlockStatements": "off", + "useEnumInitializers": "off" }, "correctness": { "noUnusedVariables": "off", diff --git a/package.json b/package.json index 720f0d6..7d14f40 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "module": "./lib/index.js", "types": "./lib/index.d.ts", "files": [ - "lib/**" + "lib/**", + "deps/**" ], "scripts": { "build": "tsc --outDir ./lib", @@ -20,7 +21,6 @@ "author": "MARCROCK22", "license": "Apache-2.0", "dependencies": { - "discord-api-types": "github:tiramisulabs/discord-api-types", "magic-bytes.js": "^1.10.0", "ts-mixer": "^6.0.4", "ws": "^8.18.0" @@ -31,7 +31,7 @@ ] }, "devDependencies": { - "@biomejs/biome": "1.8.1", + "@biomejs/biome": "1.8.3", "@commitlint/cli": "^19.3.0", "@commitlint/config-conventional": "^19.2.2", "@types/node": "^20.14.11", @@ -64,10 +64,20 @@ "publishConfig": { "access": "public" }, - "contributors": [ + "maintainers": [ { "name": "socram03", "url": "https://github.com/socram03" } + ], + "contributors": [ + { + "name": "Free 公園", + "url": "https://github.com/FreeAoi" + }, + { + "name": "David", + "url": "https://github.com/Drylozu" + } ] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fc3c898..9e0e29a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,6 @@ importers: .: dependencies: - discord-api-types: - specifier: github:tiramisulabs/discord-api-types - version: https://codeload.github.com/tiramisulabs/discord-api-types/tar.gz/fb7d551a671718f4e1b7b4010574c0f3a4d0a858 magic-bytes.js: specifier: ^1.10.0 version: 1.10.0 @@ -35,8 +32,8 @@ importers: version: https://codeload.github.com/uNetworking/uWebSockets.js/tar.gz/f40213ec0a97d0d8721d9d32d92d6eb6ddcd22e7 devDependencies: '@biomejs/biome': - specifier: 1.8.1 - version: 1.8.1 + specifier: 1.8.3 + version: 1.8.3 '@commitlint/cli': specifier: ^19.3.0 version: 19.3.0(@types/node@20.14.11)(typescript@5.5.3) @@ -73,55 +70,55 @@ packages: resolution: {integrity: sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==} engines: {node: '>=6.9.0'} - '@biomejs/biome@1.8.1': - resolution: {integrity: sha512-fQXGfvq6DIXem12dGQCM2tNF+vsNHH1qs3C7WeOu75Pd0trduoTmoO7G4ntLJ2qDs5wuw981H+cxQhi1uHnAtA==} + '@biomejs/biome@1.8.3': + resolution: {integrity: sha512-/uUV3MV+vyAczO+vKrPdOW0Iaet7UnJMU4bNMinggGJTAnBPjCoLEYcyYtYHNnUNYlv4xZMH6hVIQCAozq8d5w==} engines: {node: '>=14.21.3'} hasBin: true - '@biomejs/cli-darwin-arm64@1.8.1': - resolution: {integrity: sha512-XLiB7Uu6GALIOBWzQ2aMD0ru4Ly5/qSeQF7kk3AabzJ/kwsEWSe33iVySBP/SS2qv25cgqNiLksjGcw2bHT3mw==} + '@biomejs/cli-darwin-arm64@1.8.3': + resolution: {integrity: sha512-9DYOjclFpKrH/m1Oz75SSExR8VKvNSSsLnVIqdnKexj6NwmiMlKk94Wa1kZEdv6MCOHGHgyyoV57Cw8WzL5n3A==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [darwin] - '@biomejs/cli-darwin-x64@1.8.1': - resolution: {integrity: sha512-uMTSxVLMfqkBVqyc25hSn83jBbp+wtWjzM/pHFlKXt3htJuw7FErVGW0nmQ9Sxa9vJ7GcqoltLMl28VQRIMYzg==} + '@biomejs/cli-darwin-x64@1.8.3': + resolution: {integrity: sha512-UeW44L/AtbmOF7KXLCoM+9PSgPo0IDcyEUfIoOXYeANaNXXf9mLUwV1GeF2OWjyic5zj6CnAJ9uzk2LT3v/wAw==} engines: {node: '>=14.21.3'} cpu: [x64] os: [darwin] - '@biomejs/cli-linux-arm64-musl@1.8.1': - resolution: {integrity: sha512-UQ8Wc01J0wQL+5AYOc7qkJn20B4PZmQL1KrmDZh7ot0DvD6aX4+8mmfd/dG5b6Zjo/44QvCKcvkFGCMRYuhWZA==} + '@biomejs/cli-linux-arm64-musl@1.8.3': + resolution: {integrity: sha512-9yjUfOFN7wrYsXt/T/gEWfvVxKlnh3yBpnScw98IF+oOeCYb5/b/+K7YNqKROV2i1DlMjg9g/EcN9wvj+NkMuQ==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] - '@biomejs/cli-linux-arm64@1.8.1': - resolution: {integrity: sha512-3SzZRuC/9Oi2P2IBNPsEj0KXxSXUEYRR2kfRF/Ve8QAfGgrt4qnwuWd6QQKKN5R+oYH691qjm+cXBKEcrP1v/Q==} + '@biomejs/cli-linux-arm64@1.8.3': + resolution: {integrity: sha512-fed2ji8s+I/m8upWpTJGanqiJ0rnlHOK3DdxsyVLZQ8ClY6qLuPc9uehCREBifRJLl/iJyQpHIRufLDeotsPtw==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] - '@biomejs/cli-linux-x64-musl@1.8.1': - resolution: {integrity: sha512-fYbP/kNu/rtZ4kKzWVocIdqZOtBSUEg9qUhZaao3dy3CRzafR6u6KDtBeSCnt47O+iLnks1eOR1TUxzr5+QuqA==} + '@biomejs/cli-linux-x64-musl@1.8.3': + resolution: {integrity: sha512-UHrGJX7PrKMKzPGoEsooKC9jXJMa28TUSMjcIlbDnIO4EAavCoVmNQaIuUSH0Ls2mpGMwUIf+aZJv657zfWWjA==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] - '@biomejs/cli-linux-x64@1.8.1': - resolution: {integrity: sha512-AeBycVdNrTzsyYKEOtR2R0Ph0hCD0sCshcp2aOnfGP0hCZbtFg09D0SdKLbyzKntisY41HxKVrydYiaApp+2uw==} + '@biomejs/cli-linux-x64@1.8.3': + resolution: {integrity: sha512-I8G2QmuE1teISyT8ie1HXsjFRz9L1m5n83U1O6m30Kw+kPMPSKjag6QGUn+sXT8V+XWIZxFFBoTDEDZW2KPDDw==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] - '@biomejs/cli-win32-arm64@1.8.1': - resolution: {integrity: sha512-6tEd1H/iFKpgpE3OIB7oNgW5XkjiVMzMRPL8zYoZ036YfuJ5nMYm9eB9H/y81+8Z76vL48fiYzMPotJwukGPqQ==} + '@biomejs/cli-win32-arm64@1.8.3': + resolution: {integrity: sha512-J+Hu9WvrBevfy06eU1Na0lpc7uR9tibm9maHynLIoAjLZpQU3IW+OKHUtyL8p6/3pT2Ju5t5emReeIS2SAxhkQ==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [win32] - '@biomejs/cli-win32-x64@1.8.1': - resolution: {integrity: sha512-g2H31jJzYmS4jkvl6TiyEjEX+Nv79a5km/xn+5DARTp5MBFzC9gwceusSSB2AkJKqZzY131AiACAWjKrVt5Ijw==} + '@biomejs/cli-win32-x64@1.8.3': + resolution: {integrity: sha512-/PJ59vA1pnQeKahemaQf4Nyj7IKUvGQSc3Ze1uIGi+Wvr1xF7rGobSrAAG01T/gUDG21vkDsZYM03NAmPiVkqg==} engines: {node: '>=14.21.3'} cpu: [x64] os: [win32] @@ -362,10 +359,6 @@ packages: resolution: {integrity: sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==} engines: {node: '>=0.10'} - discord-api-types@https://codeload.github.com/tiramisulabs/discord-api-types/tar.gz/fb7d551a671718f4e1b7b4010574c0f3a4d0a858: - resolution: {tarball: https://codeload.github.com/tiramisulabs/discord-api-types/tar.gz/fb7d551a671718f4e1b7b4010574c0f3a4d0a858} - version: 0.37.92 - dot-prop@5.3.0: resolution: {integrity: sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==} engines: {node: '>=8'} @@ -871,39 +864,39 @@ snapshots: js-tokens: 4.0.0 picocolors: 1.0.1 - '@biomejs/biome@1.8.1': + '@biomejs/biome@1.8.3': optionalDependencies: - '@biomejs/cli-darwin-arm64': 1.8.1 - '@biomejs/cli-darwin-x64': 1.8.1 - '@biomejs/cli-linux-arm64': 1.8.1 - '@biomejs/cli-linux-arm64-musl': 1.8.1 - '@biomejs/cli-linux-x64': 1.8.1 - '@biomejs/cli-linux-x64-musl': 1.8.1 - '@biomejs/cli-win32-arm64': 1.8.1 - '@biomejs/cli-win32-x64': 1.8.1 + '@biomejs/cli-darwin-arm64': 1.8.3 + '@biomejs/cli-darwin-x64': 1.8.3 + '@biomejs/cli-linux-arm64': 1.8.3 + '@biomejs/cli-linux-arm64-musl': 1.8.3 + '@biomejs/cli-linux-x64': 1.8.3 + '@biomejs/cli-linux-x64-musl': 1.8.3 + '@biomejs/cli-win32-arm64': 1.8.3 + '@biomejs/cli-win32-x64': 1.8.3 - '@biomejs/cli-darwin-arm64@1.8.1': + '@biomejs/cli-darwin-arm64@1.8.3': optional: true - '@biomejs/cli-darwin-x64@1.8.1': + '@biomejs/cli-darwin-x64@1.8.3': optional: true - '@biomejs/cli-linux-arm64-musl@1.8.1': + '@biomejs/cli-linux-arm64-musl@1.8.3': optional: true - '@biomejs/cli-linux-arm64@1.8.1': + '@biomejs/cli-linux-arm64@1.8.3': optional: true - '@biomejs/cli-linux-x64-musl@1.8.1': + '@biomejs/cli-linux-x64-musl@1.8.3': optional: true - '@biomejs/cli-linux-x64@1.8.1': + '@biomejs/cli-linux-x64@1.8.3': optional: true - '@biomejs/cli-win32-arm64@1.8.1': + '@biomejs/cli-win32-arm64@1.8.3': optional: true - '@biomejs/cli-win32-x64@1.8.1': + '@biomejs/cli-win32-x64@1.8.3': optional: true '@commitlint/cli@19.3.0(@types/node@20.14.11)(typescript@5.5.3)': @@ -1185,8 +1178,6 @@ snapshots: denque@2.1.0: optional: true - discord-api-types@https://codeload.github.com/tiramisulabs/discord-api-types/tar.gz/fb7d551a671718f4e1b7b4010574c0f3a4d0a858: {} - dot-prop@5.3.0: dependencies: is-obj: 2.0.0 diff --git a/src/api/Routes/applications.ts b/src/api/Routes/applications.ts index cb68a52..ae982fa 100644 --- a/src/api/Routes/applications.ts +++ b/src/api/Routes/applications.ts @@ -30,7 +30,8 @@ import type { RESTPostAPIApplicationEmojiResult, RESTPatchAPIApplicationEmojiResult, RESTDeleteAPIApplicationEmojiResult, -} from 'discord-api-types/v10'; +} from '../../types'; + import type { ProxyRequestMethod } from '../Router'; import type { RestArguments } from '../api'; diff --git a/src/api/Routes/channels.ts b/src/api/Routes/channels.ts index da8d6a7..ef91b0b 100644 --- a/src/api/Routes/channels.ts +++ b/src/api/Routes/channels.ts @@ -55,7 +55,7 @@ import type { RESTPutAPIChannelRecipientJSONBody, RESTPutAPIChannelRecipientResult, RESTPutAPIChannelThreadMembersResult, -} from 'discord-api-types/v10'; +} from '../../types'; import type { ProxyRequestMethod } from '../Router'; import type { RestArguments } from '../api'; diff --git a/src/api/Routes/gateway.ts b/src/api/Routes/gateway.ts index 3056215..0b62502 100644 --- a/src/api/Routes/gateway.ts +++ b/src/api/Routes/gateway.ts @@ -1,4 +1,4 @@ -import type { RESTGetAPIGatewayBotResult, RESTGetAPIGatewayResult } from 'discord-api-types/v10'; +import type { RESTGetAPIGatewayBotResult, RESTGetAPIGatewayResult } from '../../types'; import type { ProxyRequestMethod } from '../Router'; import type { RestArguments } from '../api'; diff --git a/src/api/Routes/guilds.ts b/src/api/Routes/guilds.ts index cd76bd5..d47404a 100644 --- a/src/api/Routes/guilds.ts +++ b/src/api/Routes/guilds.ts @@ -112,7 +112,7 @@ import type { RESTPutAPIGuildMemberResult, RESTPutAPIGuildMemberRoleResult, RESTPutAPIGuildTemplateSyncResult, -} from 'discord-api-types/v10'; +} from '../../types'; import type { Identify, OmitInsert } from '../../common'; import type { ProxyRequestMethod } from '../Router'; import type { RestArguments } from '../api'; diff --git a/src/api/Routes/interactions.ts b/src/api/Routes/interactions.ts index 97c3067..3ed1ff1 100644 --- a/src/api/Routes/interactions.ts +++ b/src/api/Routes/interactions.ts @@ -1,4 +1,4 @@ -import type { RESTPostAPIInteractionCallbackJSONBody } from 'discord-api-types/v10'; +import type { RESTPostAPIInteractionCallbackJSONBody } from '../../types'; import type { ProxyRequestMethod } from '../Router'; import type { RestArguments } from '../api'; diff --git a/src/api/Routes/invites.ts b/src/api/Routes/invites.ts index 2f31842..c285ce4 100644 --- a/src/api/Routes/invites.ts +++ b/src/api/Routes/invites.ts @@ -1,4 +1,4 @@ -import type { RESTDeleteAPIInviteResult, RESTGetAPIInviteQuery, RESTGetAPIInviteResult } from 'discord-api-types/v10'; +import type { RESTDeleteAPIInviteResult, RESTGetAPIInviteQuery, RESTGetAPIInviteResult } from '../../types'; import type { ProxyRequestMethod } from '../Router'; import type { RestArguments } from '../api'; diff --git a/src/api/Routes/stage-instances.ts b/src/api/Routes/stage-instances.ts index 5557e38..25a7f9d 100644 --- a/src/api/Routes/stage-instances.ts +++ b/src/api/Routes/stage-instances.ts @@ -5,7 +5,7 @@ import type { RESTPatchAPIStageInstanceResult, RESTPostAPIStageInstanceJSONBody, RESTPostAPIStageInstanceResult, -} from 'discord-api-types/v10'; +} from '../../types'; import type { ProxyRequestMethod } from '../Router'; import type { RestArguments } from '../api'; diff --git a/src/api/Routes/stickers.ts b/src/api/Routes/stickers.ts index 8fbeaa4..5d6779a 100644 --- a/src/api/Routes/stickers.ts +++ b/src/api/Routes/stickers.ts @@ -1,4 +1,4 @@ -import type { RESTGetAPIStickerResult, RESTGetNitroStickerPacksResult } from 'discord-api-types/v10'; +import type { RESTGetAPIStickerResult, RESTGetNitroStickerPacksResult } from '../../types'; import type { ProxyRequestMethod } from '../Router'; import type { RestArguments } from '../api'; diff --git a/src/api/Routes/users.ts b/src/api/Routes/users.ts index 2a95a71..0bb8b39 100644 --- a/src/api/Routes/users.ts +++ b/src/api/Routes/users.ts @@ -13,7 +13,7 @@ import type { RESTPostAPICurrentUserCreateDMChannelJSONBody, RESTPutAPICurrentUserApplicationRoleConnectionJSONBody, RESTPutAPICurrentUserApplicationRoleConnectionResult, -} from 'discord-api-types/v10'; +} from '../../types'; import type { ProxyRequestMethod } from '../Router'; import type { RestArguments } from '../api'; diff --git a/src/api/Routes/voice.ts b/src/api/Routes/voice.ts index e98a96c..4fc851a 100644 --- a/src/api/Routes/voice.ts +++ b/src/api/Routes/voice.ts @@ -1,4 +1,4 @@ -import type { RESTGetAPIVoiceRegionsResult } from 'discord-api-types/v10'; +import type { RESTGetAPIVoiceRegionsResult } from '../../types'; import type { ProxyRequestMethod } from '../Router'; import type { RestArguments } from '../api'; diff --git a/src/api/Routes/webhooks.ts b/src/api/Routes/webhooks.ts index d3fc4d4..e3901a2 100644 --- a/src/api/Routes/webhooks.ts +++ b/src/api/Routes/webhooks.ts @@ -21,7 +21,7 @@ import type { RESTPostAPIWebhookWithTokenSlackResult, RESTPostAPIWebhookWithTokenSlackWaitResult, RESTPostAPIWebhookWithTokenWaitResult, -} from 'discord-api-types/v10'; +} from '../../types'; import type { ProxyRequestMethod } from '../Router'; import type { RestArguments } from '../api'; diff --git a/src/api/api.ts b/src/api/api.ts index 2e0ffc0..c52a50c 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -1,4 +1,4 @@ -import { filetypeinfo } from 'magic-bytes.js'; +import { filetypemime } from 'magic-bytes.js'; import { randomUUID } from 'node:crypto'; import { Logger, delay, lazyLoadPackage } from '../common'; import { snowflakeToTimestamp } from '../structures/extra/functions'; @@ -353,14 +353,10 @@ export class ApiHandler { let contentType = file.contentType; if (!contentType) { - const [parsedType] = filetypeinfo(file.data); + const mime = filetypemime(Buffer.from(file.data))[0]; - if (parsedType) { - contentType = - OverwrittenMimeTypes[parsedType.mime as keyof typeof OverwrittenMimeTypes] ?? - parsedType.mime ?? - 'application/octet-stream'; - } + contentType = + OverwrittenMimeTypes[mime as keyof typeof OverwrittenMimeTypes] ?? mime ?? 'application/octet-stream'; } formData.append(fileKey, new Blob([file.data], { type: contentType }), file.name); diff --git a/src/api/utils/utils.ts b/src/api/utils/utils.ts index 1fa5836..35d9ef2 100644 --- a/src/api/utils/utils.ts +++ b/src/api/utils/utils.ts @@ -1,4 +1,4 @@ -import type { Snowflake } from 'discord-api-types/v10'; +import type { Snowflake } from '../../types'; /** * Calculates the default avatar index for a given user id. diff --git a/src/builders/ActionRow.ts b/src/builders/ActionRow.ts index 4db1cf2..315b6af 100644 --- a/src/builders/ActionRow.ts +++ b/src/builders/ActionRow.ts @@ -3,7 +3,7 @@ import { type APIActionRowComponent, type APIActionRowComponentTypes, type APIMessageActionRowComponent, -} from 'discord-api-types/v10'; +} from '../types'; import type { RestOrArray } from '../common/types/util'; import { BaseComponentBuilder } from './Base'; import { fromComponent } from './index'; diff --git a/src/builders/Attachment.ts b/src/builders/Attachment.ts index 19e930d..935cf4e 100644 --- a/src/builders/Attachment.ts +++ b/src/builders/Attachment.ts @@ -1,4 +1,4 @@ -import type { APIAttachment, RESTAPIAttachment } from 'discord-api-types/v10'; +import type { APIAttachment, RESTAPIAttachment } from '../types'; import { randomBytes } from 'node:crypto'; import path from 'node:path'; import { type UsingClient, throwError, type RawFile } from '..'; diff --git a/src/builders/Base.ts b/src/builders/Base.ts index 7762b4b..157658f 100644 --- a/src/builders/Base.ts +++ b/src/builders/Base.ts @@ -1,4 +1,4 @@ -import type { APIBaseComponent, ComponentType } from 'discord-api-types/v10'; +import type { APIBaseComponent, ComponentType } from '../types'; export abstract class BaseComponentBuilder< TYPE extends Partial> = APIBaseComponent, diff --git a/src/builders/Button.ts b/src/builders/Button.ts index 77f8069..4893e7e 100644 --- a/src/builders/Button.ts +++ b/src/builders/Button.ts @@ -1,9 +1,4 @@ -import { - type APIMessageComponentEmoji, - type ButtonStyle, - ComponentType, - type APIButtonComponent, -} from 'discord-api-types/v10'; +import { type APIMessageComponentEmoji, type ButtonStyle, ComponentType, type APIButtonComponent } from '../types'; import type { EmojiResolvable } from '../common'; import { resolvePartialEmoji } from '../structures/extra/functions'; diff --git a/src/builders/Embed.ts b/src/builders/Embed.ts index 324f46b..c8166c6 100644 --- a/src/builders/Embed.ts +++ b/src/builders/Embed.ts @@ -1,4 +1,4 @@ -import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter } from 'discord-api-types/v10'; +import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter } from '../types'; import { resolveColor, toSnakeCase, type ColorResolvable, type ObjectToLower, type RestOrArray } from '../common'; /** diff --git a/src/builders/Modal.ts b/src/builders/Modal.ts index 6905b23..a329eaf 100644 --- a/src/builders/Modal.ts +++ b/src/builders/Modal.ts @@ -4,7 +4,7 @@ import { type APITextInputComponent, ComponentType, type TextInputStyle, -} from 'discord-api-types/v10'; +} from '../types'; import type { RestOrArray } from '../common'; import type { ActionRow } from './ActionRow'; import { BaseComponentBuilder, type OptionValuesLength } from './Base'; diff --git a/src/builders/Poll.ts b/src/builders/Poll.ts index 73b255a..e26b6a2 100644 --- a/src/builders/Poll.ts +++ b/src/builders/Poll.ts @@ -1,4 +1,4 @@ -import { type APIPollMedia, PollLayoutType, type RESTAPIPollCreate } from 'discord-api-types/v10'; +import { type APIPollMedia, PollLayoutType, type RESTAPIPollCreate } from '../types'; import type { DeepPartial, EmojiResolvable, RestOrArray } from '../common'; import { throwError } from '..'; import { resolvePartialEmoji } from '../structures/extra/functions'; diff --git a/src/builders/SelectMenu.ts b/src/builders/SelectMenu.ts index cee39df..3abfae9 100644 --- a/src/builders/SelectMenu.ts +++ b/src/builders/SelectMenu.ts @@ -11,7 +11,7 @@ import { type ChannelType, ComponentType, SelectMenuDefaultValueType, -} from 'discord-api-types/v10'; +} from '../types'; import { throwError } from '..'; import type { EmojiResolvable, RestOrArray, ToClass } from '../common'; import type { diff --git a/src/builders/index.ts b/src/builders/index.ts index e87886c..800aef3 100644 --- a/src/builders/index.ts +++ b/src/builders/index.ts @@ -1,4 +1,4 @@ -import { type APIActionRowComponent, type APIActionRowComponentTypes, ComponentType } from 'discord-api-types/v10'; +import { type APIActionRowComponent, type APIActionRowComponentTypes, ComponentType } from '../types'; import { ActionRow } from './ActionRow'; import { Button } from './Button'; import { TextInput } from './Modal'; diff --git a/src/cache/index.ts b/src/cache/index.ts index e07cbd9..a6bcc71 100644 --- a/src/cache/index.ts +++ b/src/cache/index.ts @@ -17,6 +17,10 @@ import { VoiceStates } from './resources/voice-states'; import { Bans } from './resources/bans'; import { + ChannelType, + GatewayIntentBits, + GuildMemberFlags, + OverwriteType, type APIChannel, type APIEmoji, type APIGuildMember, @@ -24,12 +28,8 @@ import { type APISticker, type APITextChannel, type APIUser, - ChannelType, - GatewayIntentBits, - GuildMemberFlags, - OverwriteType, type GatewayDispatchPayload, -} from 'discord-api-types/v10'; +} from '../types'; import type { InternalOptions, UsingClient } from '../commands'; import { Overwrites } from './resources/overwrites'; import { Messages } from './resources/messages'; diff --git a/src/cache/resources/bans.ts b/src/cache/resources/bans.ts index 4215d48..f4453c5 100644 --- a/src/cache/resources/bans.ts +++ b/src/cache/resources/bans.ts @@ -1,4 +1,4 @@ -import type { APIBan, GatewayGuildBanModifyDispatchData } from 'discord-api-types/v10'; +import type { APIBan, GatewayGuildBanModifyDispatchData } from '../../types'; import type { ReturnCache } from '../..'; import { fakePromise } from '../../common'; import { GuildBasedResource } from './default/guild-based'; diff --git a/src/cache/resources/channels.ts b/src/cache/resources/channels.ts index 75276b2..5c6ced4 100644 --- a/src/cache/resources/channels.ts +++ b/src/cache/resources/channels.ts @@ -1,4 +1,4 @@ -import type { APIChannel } from 'discord-api-types/v10'; +import type { APIChannel } from '../../types'; import { fakePromise } from '../../common'; import type { AllChannels } from '../../structures'; import channelFrom from '../../structures/channels'; diff --git a/src/cache/resources/default/base.ts b/src/cache/resources/default/base.ts index 4622f1a..3d76139 100644 --- a/src/cache/resources/default/base.ts +++ b/src/cache/resources/default/base.ts @@ -1,6 +1,6 @@ -import type { GatewayIntentBits } from 'discord-api-types/v10'; import type { UsingClient } from '../../../commands'; import { fakePromise } from '../../../common'; +import type { GatewayIntentBits } from '../../../types'; import type { Cache, ReturnCache } from '../../index'; export class BaseResource { diff --git a/src/cache/resources/default/guild-based.ts b/src/cache/resources/default/guild-based.ts index a7804a1..0fbebe5 100644 --- a/src/cache/resources/default/guild-based.ts +++ b/src/cache/resources/default/guild-based.ts @@ -1,6 +1,6 @@ -import type { GatewayIntentBits } from 'discord-api-types/v10'; import type { UsingClient } from '../../../commands'; import { fakePromise } from '../../../common'; +import type { GatewayIntentBits } from '../../../types'; import type { Cache, ReturnCache } from '../../index'; export class GuildBasedResource { diff --git a/src/cache/resources/default/guild-related.ts b/src/cache/resources/default/guild-related.ts index cc696ea..9bc5e21 100644 --- a/src/cache/resources/default/guild-related.ts +++ b/src/cache/resources/default/guild-related.ts @@ -1,7 +1,7 @@ -import type { GatewayIntentBits } from 'discord-api-types/v10'; import type { BaseClient } from '../../../client/base'; import type { UsingClient } from '../../../commands'; import { fakePromise } from '../../../common'; +import type { GatewayIntentBits } from '../../../types'; import type { Cache, ReturnCache } from '../../index'; export class GuildRelatedResource { diff --git a/src/cache/resources/emojis.ts b/src/cache/resources/emojis.ts index 51e9966..913250d 100644 --- a/src/cache/resources/emojis.ts +++ b/src/cache/resources/emojis.ts @@ -1,4 +1,4 @@ -import type { APIEmoji } from 'discord-api-types/v10'; +import type { APIEmoji } from '../../types'; import type { ReturnCache } from '../..'; import { fakePromise } from '../../common'; import { GuildRelatedResource } from './default/guild-related'; diff --git a/src/cache/resources/guilds.ts b/src/cache/resources/guilds.ts index a350e09..855b93d 100644 --- a/src/cache/resources/guilds.ts +++ b/src/cache/resources/guilds.ts @@ -1,4 +1,4 @@ -import type { APIGuild, GatewayGuildCreateDispatchData } from 'discord-api-types/v10'; +import type { APIGuild, GatewayGuildCreateDispatchData } from '../../types'; import type { Cache, ReturnCache } from '..'; import { fakePromise } from '../../common'; import { BaseResource } from './default/base'; diff --git a/src/cache/resources/members.ts b/src/cache/resources/members.ts index 419771b..ba43765 100644 --- a/src/cache/resources/members.ts +++ b/src/cache/resources/members.ts @@ -1,4 +1,4 @@ -import type { APIGuildMember } from 'discord-api-types/v10'; +import type { APIGuildMember } from '../../types'; import type { ReturnCache } from '../..'; import { fakePromise } from '../../common'; import { GuildBasedResource } from './default/guild-based'; diff --git a/src/cache/resources/messages.ts b/src/cache/resources/messages.ts index fd6a94b..b39db42 100644 --- a/src/cache/resources/messages.ts +++ b/src/cache/resources/messages.ts @@ -1,4 +1,4 @@ -import type { APIMessage, APIUser } from 'discord-api-types/v10'; +import type { APIMessage, APIUser } from '../../types'; import { GuildRelatedResource } from './default/guild-related'; import type { MessageData, ReturnCache } from '../..'; import { fakePromise } from '../../common'; diff --git a/src/cache/resources/overwrites.ts b/src/cache/resources/overwrites.ts index 5fe5e73..39f64e8 100644 --- a/src/cache/resources/overwrites.ts +++ b/src/cache/resources/overwrites.ts @@ -1,4 +1,4 @@ -import type { APIOverwrite } from 'discord-api-types/v10'; +import type { APIOverwrite } from '../../types'; import type { ReturnCache } from '../..'; import { fakePromise } from '../../common/it/utils'; import { PermissionsBitField } from '../../structures/extra/Permissions'; diff --git a/src/cache/resources/presence.ts b/src/cache/resources/presence.ts index 02fef95..2a91495 100644 --- a/src/cache/resources/presence.ts +++ b/src/cache/resources/presence.ts @@ -1,4 +1,4 @@ -import type { GatewayPresenceUpdate } from 'discord-api-types/v10'; +import type { GatewayPresenceUpdate } from '../../types'; import { GuildRelatedResource } from './default/guild-related'; export class Presences extends GuildRelatedResource { diff --git a/src/cache/resources/roles.ts b/src/cache/resources/roles.ts index afc568d..8dd71ae 100644 --- a/src/cache/resources/roles.ts +++ b/src/cache/resources/roles.ts @@ -1,4 +1,4 @@ -import type { APIRole } from 'discord-api-types/v10'; +import type { APIRole } from '../../types'; import type { ReturnCache } from '../..'; import { fakePromise } from '../../common'; import { GuildRelatedResource } from './default/guild-related'; diff --git a/src/cache/resources/stage-instances.ts b/src/cache/resources/stage-instances.ts index 71eda10..f478f54 100644 --- a/src/cache/resources/stage-instances.ts +++ b/src/cache/resources/stage-instances.ts @@ -1,4 +1,4 @@ -import type { APIStageInstance } from 'discord-api-types/v10'; +import type { APIStageInstance } from '../../types'; import { GuildRelatedResource } from './default/guild-related'; export class StageInstances extends GuildRelatedResource { diff --git a/src/cache/resources/stickers.ts b/src/cache/resources/stickers.ts index 1b2571a..3b5036c 100644 --- a/src/cache/resources/stickers.ts +++ b/src/cache/resources/stickers.ts @@ -1,4 +1,4 @@ -import type { APISticker } from 'discord-api-types/v10'; +import type { APISticker } from '../../types'; import type { ReturnCache } from '../..'; import { fakePromise } from '../../common'; import { GuildRelatedResource } from './default/guild-related'; diff --git a/src/cache/resources/threads.ts b/src/cache/resources/threads.ts index ec1f1e9..9c9ba8c 100644 --- a/src/cache/resources/threads.ts +++ b/src/cache/resources/threads.ts @@ -1,4 +1,4 @@ -import type { APIThreadChannel } from 'discord-api-types/v10'; +import type { APIThreadChannel } from '../../types'; import type { ReturnCache } from '../..'; import { fakePromise } from '../../common'; import { GuildRelatedResource } from './default/guild-related'; diff --git a/src/cache/resources/users.ts b/src/cache/resources/users.ts index 55b47c9..e704d04 100644 --- a/src/cache/resources/users.ts +++ b/src/cache/resources/users.ts @@ -1,4 +1,4 @@ -import type { APIUser } from 'discord-api-types/v10'; +import type { APIUser } from '../../types'; import type { ReturnCache } from '../..'; import { fakePromise } from '../../common'; import { BaseResource } from './default/base'; diff --git a/src/cache/resources/voice-states.ts b/src/cache/resources/voice-states.ts index f9f0265..c5f2155 100644 --- a/src/cache/resources/voice-states.ts +++ b/src/cache/resources/voice-states.ts @@ -1,4 +1,4 @@ -import type { GatewayVoiceState } from 'discord-api-types/v10'; +import type { GatewayVoiceState } from '../../types'; import type { ReturnCache } from '../..'; import { fakePromise } from '../../common'; import { GuildBasedResource } from './default/guild-based'; diff --git a/src/client/base.ts b/src/client/base.ts index b3e0bf4..2e343c1 100644 --- a/src/client/base.ts +++ b/src/client/base.ts @@ -35,7 +35,7 @@ import { type MakeRequired, } from '../common'; -import type { LocaleString, RESTPostAPIChannelMessageJSONBody } from 'discord-api-types/rest/v10'; +import type { LocaleString, RESTPostAPIChannelMessageJSONBody } from '../types'; import type { Awaitable, DeepPartial, IntentStrings, OmitInsert, PermissionStrings, When } from '../common/types/util'; import { ComponentHandler } from '../components/handler'; import { LangsHandler } from '../langs/handler'; diff --git a/src/client/client.ts b/src/client/client.ts index 05b6478..7e7ecd6 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -1,4 +1,4 @@ -import { GatewayIntentBits, type GatewayDispatchPayload, type GatewayPresenceUpdateData } from 'discord-api-types/v10'; +import { type GatewayDispatchPayload, type GatewayPresenceUpdateData, GatewayIntentBits } from '../types'; import type { CommandContext, Message } from '..'; import { type Awaitable, diff --git a/src/client/httpclient.ts b/src/client/httpclient.ts index 86ed7c6..a1cd9ac 100644 --- a/src/client/httpclient.ts +++ b/src/client/httpclient.ts @@ -1,10 +1,5 @@ -import { - type APIInteractionResponse, - InteractionResponseType, - InteractionType, - type APIInteraction, -} from 'discord-api-types/v10'; -import { filetypeinfo } from 'magic-bytes.js'; +import { type APIInteractionResponse, InteractionResponseType, InteractionType, type APIInteraction } from '../types'; +import { filetypemime } from 'magic-bytes.js'; import type { HttpRequest, HttpResponse } from 'uWebSockets.js'; import { OverwrittenMimeTypes } from '../api'; import { isBufferLike } from '../api/utils/utils'; @@ -179,14 +174,12 @@ export class HttpClient extends BaseClient { let contentType = file.contentType; if (!contentType) { - const [parsedType] = filetypeinfo(file.data); + const mime = filetypemime(Buffer.from(file.data))[0]; - if (parsedType) { - contentType = - OverwrittenMimeTypes[parsedType.mime as keyof typeof OverwrittenMimeTypes] ?? - parsedType.mime ?? - 'application/octet-stream'; - } + contentType = + OverwrittenMimeTypes[mime as keyof typeof OverwrittenMimeTypes] ?? + mime ?? + 'application/octet-stream'; } response.append(fileKey, new Blob([file.data], { type: contentType }), file.name); } else { @@ -237,14 +230,12 @@ export class HttpClient extends BaseClient { let contentType = file.contentType; if (!contentType) { - const [parsedType] = filetypeinfo(file.data); + const mime = filetypemime(Buffer.from(file.data))[0]; - if (parsedType) { - contentType = - OverwrittenMimeTypes[parsedType.mime as keyof typeof OverwrittenMimeTypes] ?? - parsedType.mime ?? - 'application/octet-stream'; - } + contentType = + OverwrittenMimeTypes[mime as keyof typeof OverwrittenMimeTypes] ?? + mime ?? + 'application/octet-stream'; } response.append(fileKey, new Blob([file.data], { type: contentType }), file.name); } else { diff --git a/src/client/transformers.ts b/src/client/transformers.ts index eebc38a..2563b0b 100644 --- a/src/client/transformers.ts +++ b/src/client/transformers.ts @@ -1,4 +1,4 @@ -import type { ChannelType } from 'discord-api-types/v10'; +import type { ChannelType } from '../types'; import { type CustomStructures, OptionResolver } from '../commands'; import { AnonymousGuild, @@ -30,7 +30,7 @@ import { Webhook, WebhookMessage, } from '../structures'; -import type { StructStates } from '../common/types/util'; +import type { StructStates } from '../common/'; import { GuildBan } from '../structures/GuildBan'; export type PollStructure = InferCustomStructure; diff --git a/src/client/workerclient.ts b/src/client/workerclient.ts index 35e8de6..0a1bf54 100644 --- a/src/client/workerclient.ts +++ b/src/client/workerclient.ts @@ -1,4 +1,4 @@ -import { GatewayIntentBits, type GatewayDispatchPayload, type GatewaySendPayload } from 'discord-api-types/v10'; +import { type GatewayDispatchPayload, type GatewaySendPayload, GatewayIntentBits } from '../types'; import { randomUUID } from 'node:crypto'; import { ApiHandler, Logger } from '..'; import type { Cache } from '../cache'; diff --git a/src/commands/applications/chat.ts b/src/commands/applications/chat.ts index 57a476a..efb5928 100644 --- a/src/commands/applications/chat.ts +++ b/src/commands/applications/chat.ts @@ -7,7 +7,7 @@ import { type APIApplicationCommandOption, type APIApplicationCommandSubcommandGroupOption, type LocaleString, -} from 'discord-api-types/v10'; +} from '../../types'; import type { ComponentContext, MenuCommandContext, diff --git a/src/commands/applications/chatcontext.ts b/src/commands/applications/chatcontext.ts index afdc913..ddda765 100644 --- a/src/commands/applications/chatcontext.ts +++ b/src/commands/applications/chatcontext.ts @@ -1,4 +1,4 @@ -import { MessageFlags } from 'discord-api-types/v10'; +import { MessageFlags } from '../../types'; import type { AllChannels, InferWithPrefix, Message, ReturnCache } from '../..'; import type { Client, WorkerClient } from '../../client'; import type { If, UnionToTuple, When } from '../../common'; diff --git a/src/commands/applications/menu.ts b/src/commands/applications/menu.ts index 5b34b6c..363d589 100644 --- a/src/commands/applications/menu.ts +++ b/src/commands/applications/menu.ts @@ -3,7 +3,7 @@ import type { ApplicationIntegrationType, InteractionContextType, LocaleString, -} from 'discord-api-types/v10'; +} from '../../types'; import { magicImport, type PermissionStrings } from '../../common'; import type { RegisteredMiddlewares } from '../decorators'; import type { MenuCommandContext } from './menucontext'; diff --git a/src/commands/applications/menucontext.ts b/src/commands/applications/menucontext.ts index ec635c8..332422f 100644 --- a/src/commands/applications/menucontext.ts +++ b/src/commands/applications/menucontext.ts @@ -1,4 +1,4 @@ -import { type APIMessage, ApplicationCommandType, MessageFlags } from 'discord-api-types/v10'; +import { type APIMessage, ApplicationCommandType, MessageFlags } from '../../types'; import type { ContextMenuCommand, ReturnCache } from '../..'; import { toSnakeCase, diff --git a/src/commands/applications/options.ts b/src/commands/applications/options.ts index 06d677a..987a17a 100644 --- a/src/commands/applications/options.ts +++ b/src/commands/applications/options.ts @@ -1,8 +1,4 @@ -import { - ApplicationCommandOptionType, - type APIApplicationCommandOptionChoice, - type ChannelType, -} from 'discord-api-types/v10'; +import { ApplicationCommandOptionType, type APIApplicationCommandOptionChoice, type ChannelType } from '../../types'; import type { AutocompleteCallback, MenuCommandContext, diff --git a/src/commands/applications/shared.ts b/src/commands/applications/shared.ts index 0c668f3..c049db8 100644 --- a/src/commands/applications/shared.ts +++ b/src/commands/applications/shared.ts @@ -1,6 +1,6 @@ -import type { ChannelType } from 'discord-api-types/v10'; import type { BaseClient } from '../../client/base'; import type { IsStrictlyUndefined } from '../../common'; +import type { ChannelType } from '../../types'; import type { RegisteredMiddlewares } from '../decorators'; export type OKFunction = (value: T) => void; diff --git a/src/commands/decorators.ts b/src/commands/decorators.ts index a0540dc..bb53277 100644 --- a/src/commands/decorators.ts +++ b/src/commands/decorators.ts @@ -4,7 +4,7 @@ import { InteractionContextType, PermissionFlagsBits, type LocaleString, -} from 'discord-api-types/v10'; +} from '../types'; import type { FlatObjectKeys, PermissionStrings } from '../common'; import type { CommandOption, OptionsRecord, SubCommand } from './applications/chat'; import type { DefaultLocale, ExtraProps, IgnoreCommand, MiddlewareContext } from './applications/shared'; diff --git a/src/commands/handle.ts b/src/commands/handle.ts index ec24841..6f323c5 100644 --- a/src/commands/handle.ts +++ b/src/commands/handle.ts @@ -7,9 +7,9 @@ import { InteractionContextType, type APIApplicationCommandInteractionDataOption, ApplicationCommandOptionType, - ChannelType, type APIInteractionDataResolvedChannel, -} from 'discord-api-types/v10'; + ChannelType, +} from '../types'; import { Command, type ContextOptionsResolved, diff --git a/src/commands/handler.ts b/src/commands/handler.ts index 68ac2fa..f517d97 100644 --- a/src/commands/handler.ts +++ b/src/commands/handler.ts @@ -9,7 +9,7 @@ import { type APIApplicationCommandSubcommandGroupOption, type APIApplicationCommandChannelOption, type LocalizationMap, -} from 'discord-api-types/v10'; +} from '../types'; import { basename, dirname } from 'node:path'; import type { Logger, MakeRequired, NulleableCoalising, OmitInsert } from '../common'; import { BaseHandler } from '../common'; @@ -50,7 +50,7 @@ export class CommandHandler extends BaseHandler { } protected shouldUploadLocales(locales?: LocalizationMap | null, cachedLocales?: LocalizationMap | null) { - if (!locales && !cachedLocales) return false; + if (!(locales || cachedLocales)) return false; if (!locales && cachedLocales) return true; if (locales && !cachedLocales) return true; if (locales && cachedLocales) { diff --git a/src/commands/optionresolver.ts b/src/commands/optionresolver.ts index e383303..3f3f56d 100644 --- a/src/commands/optionresolver.ts +++ b/src/commands/optionresolver.ts @@ -7,7 +7,7 @@ import { type APIRole, type APIUser, ApplicationCommandOptionType, -} from 'discord-api-types/v10'; +} from '../types'; import { Attachment } from '..'; import type { MakeRequired } from '../common'; import type { AllChannels } from '../structures'; diff --git a/src/common/bot/watcher.ts b/src/common/bot/watcher.ts index 6746602..791c3e0 100644 --- a/src/common/bot/watcher.ts +++ b/src/common/bot/watcher.ts @@ -1,4 +1,4 @@ -import type { GatewayDispatchPayload, GatewaySendPayload } from 'discord-api-types/v10'; +import type { GatewayDispatchPayload, GatewaySendPayload } from '../../types'; import { execSync } from 'node:child_process'; import { ApiHandler, Router } from '../../api'; import { BaseClient, type InternalRuntimeConfig } from '../../client/base'; diff --git a/src/common/shorters/bans.ts b/src/common/shorters/bans.ts index 0502127..ee9cd4a 100644 --- a/src/common/shorters/bans.ts +++ b/src/common/shorters/bans.ts @@ -3,7 +3,7 @@ import type { RESTGetAPIGuildBansQuery, RESTPostAPIGuildBulkBanJSONBody, RESTPutAPIGuildBanJSONBody, -} from 'discord-api-types/v10'; +} from '../../types'; import { BaseShorter } from './base'; import { Transformers } from '../../client/transformers'; diff --git a/src/common/shorters/channels.ts b/src/common/shorters/channels.ts index 5fd93e5..b88900b 100644 --- a/src/common/shorters/channels.ts +++ b/src/common/shorters/channels.ts @@ -1,13 +1,11 @@ -import { - type APIChannel, - PermissionFlagsBits, - type RESTGetAPIChannelMessagesQuery, - type RESTPatchAPIChannelJSONBody, - type RESTPostAPIChannelThreadsJSONBody, - type RESTPostAPIGuildForumThreadsJSONBody, - type ChannelType, - type APIGuildChannel, -} from 'discord-api-types/v10'; +import type { + APIChannel, + RESTGetAPIChannelMessagesQuery, + RESTPatchAPIChannelJSONBody, + RESTPostAPIChannelThreadsJSONBody, + RESTPostAPIGuildForumThreadsJSONBody, + APIGuildChannel, +} from '../../types'; import { BaseChannel, type GuildRole, type GuildMember } from '../../structures'; import channelFrom, { type AllChannels } from '../../structures/channels'; import { PermissionsBitField } from '../../structures/extra/Permissions'; @@ -15,6 +13,7 @@ import { BaseShorter } from './base'; import { MergeOptions } from '../it/utils'; import { type MessageStructure, Transformers } from '../../client/transformers'; import type { MakeRequired } from '../types/util'; +import { type ChannelType, PermissionFlagsBits } from '../../types'; export class ChannelShorter extends BaseShorter { /** diff --git a/src/common/shorters/emojis.ts b/src/common/shorters/emojis.ts index dfd04b6..89c0104 100644 --- a/src/common/shorters/emojis.ts +++ b/src/common/shorters/emojis.ts @@ -1,4 +1,4 @@ -import type { APIEmoji, RESTPatchAPIGuildEmojiJSONBody, RESTPostAPIGuildEmojiJSONBody } from 'discord-api-types/v10'; +import type { APIEmoji, RESTPatchAPIGuildEmojiJSONBody, RESTPostAPIGuildEmojiJSONBody } from '../../types'; import { resolveImage } from '../../builders'; import type { ImageResolvable } from '../types/resolvables'; import type { OmitInsert } from '../types/util'; diff --git a/src/common/shorters/guilds.ts b/src/common/shorters/guilds.ts index e1206c5..84d2e7e 100644 --- a/src/common/shorters/guilds.ts +++ b/src/common/shorters/guilds.ts @@ -10,7 +10,7 @@ import type { RESTPostAPIAutoModerationRuleJSONBody, RESTPostAPIGuildChannelJSONBody, RESTPostAPIGuildsJSONBody, -} from 'discord-api-types/v10'; +} from '../../types'; import { resolveFiles } from '../../builders'; import { BaseChannel, Guild, GuildMember, type CreateStickerBodyRequest } from '../../structures'; import channelFrom from '../../structures/channels'; diff --git a/src/common/shorters/members.ts b/src/common/shorters/members.ts index 20f1fde..37d514c 100644 --- a/src/common/shorters/members.ts +++ b/src/common/shorters/members.ts @@ -1,12 +1,12 @@ -import { FormattingPatterns } from 'discord-api-types/globals'; -import type { - APIGuildMember, - RESTGetAPIGuildMembersQuery, - RESTGetAPIGuildMembersSearchQuery, - RESTPatchAPIGuildMemberJSONBody, - RESTPutAPIGuildBanJSONBody, - RESTPutAPIGuildMemberJSONBody, -} from 'discord-api-types/v10'; +import { + type APIGuildMember, + type RESTGetAPIGuildMembersQuery, + type RESTGetAPIGuildMembersSearchQuery, + type RESTPatchAPIGuildMemberJSONBody, + type RESTPutAPIGuildBanJSONBody, + type RESTPutAPIGuildMemberJSONBody, + FormattingPatterns, +} from '../../types'; import { PermissionsBitField } from '../../structures/extra/Permissions'; import type { GuildMemberResolvable } from '../types/resolvables'; import { BaseShorter } from './base'; diff --git a/src/common/shorters/messages.ts b/src/common/shorters/messages.ts index 6af363c..a1b8987 100644 --- a/src/common/shorters/messages.ts +++ b/src/common/shorters/messages.ts @@ -2,7 +2,7 @@ import type { RESTPatchAPIChannelMessageJSONBody, RESTPostAPIChannelMessageJSONBody, RESTPostAPIChannelMessagesThreadsJSONBody, -} from 'discord-api-types/v10'; +} from '../../types'; import { resolveFiles } from '../../builders'; import { MessagesMethods } from '../../structures'; diff --git a/src/common/shorters/reactions.ts b/src/common/shorters/reactions.ts index a10a4d8..ae3af20 100644 --- a/src/common/shorters/reactions.ts +++ b/src/common/shorters/reactions.ts @@ -1,4 +1,4 @@ -import type { RESTGetAPIChannelMessageReactionUsersQuery } from 'discord-api-types/v10'; +import type { RESTGetAPIChannelMessageReactionUsersQuery } from '../../types'; import { encodeEmoji, resolveEmoji } from '../../structures/extra/functions'; import type { EmojiResolvable } from '../types/resolvables'; import { BaseShorter } from './base'; diff --git a/src/common/shorters/roles.ts b/src/common/shorters/roles.ts index fa2233b..89f37fd 100644 --- a/src/common/shorters/roles.ts +++ b/src/common/shorters/roles.ts @@ -3,7 +3,7 @@ import type { RESTPatchAPIGuildRoleJSONBody, RESTPatchAPIGuildRolePositionsJSONBody, RESTPostAPIGuildRoleJSONBody, -} from 'discord-api-types/v10'; +} from '../../types'; import { BaseShorter } from './base'; import { Transformers } from '../../client/transformers'; diff --git a/src/common/shorters/templates.ts b/src/common/shorters/templates.ts index 50fb9d1..ddb1c43 100644 --- a/src/common/shorters/templates.ts +++ b/src/common/shorters/templates.ts @@ -1,4 +1,4 @@ -import type { RESTPatchAPIGuildTemplateJSONBody, RESTPostAPIGuildTemplatesJSONBody } from 'discord-api-types/v10'; +import type { RESTPatchAPIGuildTemplateJSONBody, RESTPostAPIGuildTemplatesJSONBody } from '../../types'; import { BaseShorter } from './base'; import { Transformers } from '../../client/transformers'; diff --git a/src/common/shorters/threads.ts b/src/common/shorters/threads.ts index 4f3e060..703b33b 100644 --- a/src/common/shorters/threads.ts +++ b/src/common/shorters/threads.ts @@ -6,7 +6,7 @@ import type { RESTPostAPIChannelMessagesThreadsJSONBody, RESTPostAPIChannelThreadsJSONBody, RESTPostAPIGuildForumThreadsJSONBody, -} from 'discord-api-types/v10'; +} from '../../types'; import channelFrom from '../../structures/channels'; import { BaseShorter } from './base'; import type { MakeRequired, When } from '../types/util'; diff --git a/src/common/shorters/webhook.ts b/src/common/shorters/webhook.ts index 34ce44c..3513ca2 100644 --- a/src/common/shorters/webhook.ts +++ b/src/common/shorters/webhook.ts @@ -3,7 +3,7 @@ import type { RESTPatchAPIWebhookWithTokenJSONBody, RESTPostAPIChannelWebhookJSONBody, RESTPostAPIWebhookWithTokenJSONBody, -} from 'discord-api-types/v10'; +} from '../../types'; import { resolveFiles } from '../../builders'; import { MessagesMethods, diff --git a/src/common/types/resolvables.ts b/src/common/types/resolvables.ts index 81d1ba2..70be9c7 100644 --- a/src/common/types/resolvables.ts +++ b/src/common/types/resolvables.ts @@ -1,4 +1,4 @@ -import type { APIPartialEmoji } from 'discord-api-types/v10'; +import type { APIPartialEmoji } from '../../types'; import type { EmbedColors } from '..'; import type { Attachment, AttachmentDataType, AttachmentResolvable } from '../../builders'; import type { GuildMember } from '../../structures'; diff --git a/src/common/types/util.ts b/src/common/types/util.ts index 93aa5dd..aebf8c9 100644 --- a/src/common/types/util.ts +++ b/src/common/types/util.ts @@ -1,4 +1,4 @@ -import type { GatewayIntentBits, PermissionFlagsBits } from 'discord-api-types/v10'; +import type { GatewayIntentBits, PermissionFlagsBits } from '../../types'; export type ToClass = new ( ...args: any[] diff --git a/src/common/types/write.ts b/src/common/types/write.ts index 0f3c155..ed8e9fb 100644 --- a/src/common/types/write.ts +++ b/src/common/types/write.ts @@ -10,7 +10,7 @@ import type { RESTPatchAPIWebhookWithTokenMessageJSONBody, RESTPostAPIChannelMessageJSONBody, RESTPostAPIWebhookWithTokenJSONBody, -} from 'discord-api-types/v10'; +} from '../../types'; import type { RawFile } from '../../api'; import type { ActionRow, diff --git a/src/components/ActionRow.ts b/src/components/ActionRow.ts index 1a3e402..b257ddb 100644 --- a/src/components/ActionRow.ts +++ b/src/components/ActionRow.ts @@ -1,4 +1,4 @@ -import type { APIMessageActionRowComponent, ComponentType } from 'discord-api-types/v10'; +import type { APIMessageActionRowComponent, ComponentType } from '../types'; import { BaseComponent } from './BaseComponent'; import type { ActionRowMessageComponents } from './index'; import { componentFactory } from './index'; diff --git a/src/components/BaseComponent.ts b/src/components/BaseComponent.ts index d8d6e00..332c661 100644 --- a/src/components/BaseComponent.ts +++ b/src/components/BaseComponent.ts @@ -9,7 +9,7 @@ import { type APITextInputComponent, type APIUserSelectComponent, ComponentType, -} from 'discord-api-types/v10'; +} from '../types'; import { fromComponent } from '../builders'; export class BaseComponent { diff --git a/src/components/BaseSelectMenuComponent.ts b/src/components/BaseSelectMenuComponent.ts index e79fc88..d7eee81 100644 --- a/src/components/BaseSelectMenuComponent.ts +++ b/src/components/BaseSelectMenuComponent.ts @@ -1,4 +1,4 @@ -import type { ComponentType } from 'discord-api-types/v10'; +import type { ComponentType } from '../types'; import { BaseComponent } from './BaseComponent'; export type APISelectMenuComponentTypes = diff --git a/src/components/ButtonComponent.ts b/src/components/ButtonComponent.ts index 5be0da4..19b78fc 100644 --- a/src/components/ButtonComponent.ts +++ b/src/components/ButtonComponent.ts @@ -4,7 +4,7 @@ import type { APIButtonComponentWithURL, ButtonStyle, ComponentType, -} from 'discord-api-types/v10'; +} from '../types'; import { Button } from '../builders'; import { BaseComponent } from './BaseComponent'; diff --git a/src/components/ChannelSelectMenuComponent.ts b/src/components/ChannelSelectMenuComponent.ts index f265256..8c9ad96 100644 --- a/src/components/ChannelSelectMenuComponent.ts +++ b/src/components/ChannelSelectMenuComponent.ts @@ -1,4 +1,4 @@ -import type { ComponentType } from 'discord-api-types/v10'; +import type { ComponentType } from '../types'; import { BaseSelectMenuComponent } from './BaseSelectMenuComponent'; export class ChannelSelectMenuComponent extends BaseSelectMenuComponent { diff --git a/src/components/MentionableSelectMenuComponent.ts b/src/components/MentionableSelectMenuComponent.ts index 21456fd..6754cf0 100644 --- a/src/components/MentionableSelectMenuComponent.ts +++ b/src/components/MentionableSelectMenuComponent.ts @@ -1,4 +1,4 @@ -import type { ComponentType } from 'discord-api-types/v10'; +import type { ComponentType } from '../types'; import { BaseSelectMenuComponent } from './BaseSelectMenuComponent'; export class MentionableSelectMenuComponent extends BaseSelectMenuComponent { diff --git a/src/components/RoleSelectMenuComponent.ts b/src/components/RoleSelectMenuComponent.ts index 949e889..926aa72 100644 --- a/src/components/RoleSelectMenuComponent.ts +++ b/src/components/RoleSelectMenuComponent.ts @@ -1,4 +1,4 @@ -import type { ComponentType } from 'discord-api-types/v10'; +import type { ComponentType } from '../types'; import { BaseSelectMenuComponent } from './BaseSelectMenuComponent'; export class RoleSelectMenuComponent extends BaseSelectMenuComponent { diff --git a/src/components/StringSelectMenuComponent.ts b/src/components/StringSelectMenuComponent.ts index c7d18e5..46b0bad 100644 --- a/src/components/StringSelectMenuComponent.ts +++ b/src/components/StringSelectMenuComponent.ts @@ -1,4 +1,4 @@ -import type { ComponentType } from 'discord-api-types/v10'; +import type { ComponentType } from '../types'; import { BaseSelectMenuComponent } from './BaseSelectMenuComponent'; export class StringSelectMenuComponent extends BaseSelectMenuComponent { diff --git a/src/components/TextInputComponent.ts b/src/components/TextInputComponent.ts index 984e5d6..be738a9 100644 --- a/src/components/TextInputComponent.ts +++ b/src/components/TextInputComponent.ts @@ -1,4 +1,4 @@ -import type { ComponentType } from 'discord-api-types/v10'; +import type { ComponentType } from '../types'; import { BaseComponent } from './BaseComponent'; export class TextInputComponent extends BaseComponent { diff --git a/src/components/UserSelectMenuComponent.ts b/src/components/UserSelectMenuComponent.ts index b02f755..92fcdb2 100644 --- a/src/components/UserSelectMenuComponent.ts +++ b/src/components/UserSelectMenuComponent.ts @@ -1,4 +1,4 @@ -import type { ComponentType } from 'discord-api-types/v10'; +import type { ComponentType } from '../types'; import { BaseSelectMenuComponent } from './BaseSelectMenuComponent'; export class UserSelectMenuComponent extends BaseSelectMenuComponent { diff --git a/src/components/componentcommand.ts b/src/components/componentcommand.ts index 1d4b250..aae4430 100644 --- a/src/components/componentcommand.ts +++ b/src/components/componentcommand.ts @@ -1,4 +1,4 @@ -import { ComponentType } from 'discord-api-types/v10'; +import { ComponentType } from '../types'; import type { ContextComponentCommandInteractionMap, ComponentContext } from './componentcontext'; import type { ExtraProps, RegisteredMiddlewares, UsingClient } from '../commands'; diff --git a/src/components/componentcontext.ts b/src/components/componentcontext.ts index 1b51ef8..cc43692 100644 --- a/src/components/componentcontext.ts +++ b/src/components/componentcontext.ts @@ -1,4 +1,4 @@ -import { ComponentType, MessageFlags } from 'discord-api-types/v10'; +import { ComponentType, MessageFlags } from '../types'; import type { AllChannels, ButtonInteraction, diff --git a/src/components/index.ts b/src/components/index.ts index 692d149..a30e122 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -1,4 +1,4 @@ -import { type APIMessageActionRowComponent, ButtonStyle, ComponentType } from 'discord-api-types/v10'; +import { type APIMessageActionRowComponent, ButtonStyle, ComponentType } from '../types'; import { BaseComponent } from './BaseComponent'; import { ButtonComponent, LinkButtonComponent, SKUButtonComponent } from './ButtonComponent'; import { ChannelSelectMenuComponent } from './ChannelSelectMenuComponent'; diff --git a/src/components/modalcontext.ts b/src/components/modalcontext.ts index 8861436..8170723 100644 --- a/src/components/modalcontext.ts +++ b/src/components/modalcontext.ts @@ -1,4 +1,4 @@ -import { MessageFlags } from 'discord-api-types/v10'; +import { MessageFlags } from '../types'; import type { AllChannels, ModalCommand, ModalSubmitInteraction, ReturnCache } from '..'; import type { CommandMetadata, ExtendContext, GlobalMetadata, RegisteredMiddlewares, UsingClient } from '../commands'; import { BaseContext } from '../commands/basecontext'; diff --git a/src/events/handler.ts b/src/events/handler.ts index 1bfc1d5..e1ddc6a 100644 --- a/src/events/handler.ts +++ b/src/events/handler.ts @@ -3,7 +3,7 @@ import type { GatewayMessageCreateDispatch, GatewayMessageDeleteBulkDispatch, GatewayMessageDeleteDispatch, -} from 'discord-api-types/v10'; +} from '../types'; import type { Client, WorkerClient } from '../client'; import { BaseHandler, ReplaceRegex, magicImport, type MakeRequired, type SnakeCase } from '../common'; import type { ClientEvents } from '../events/hooks'; diff --git a/src/events/hooks/application_command.ts b/src/events/hooks/application_command.ts index 465e2f1..a38064f 100644 --- a/src/events/hooks/application_command.ts +++ b/src/events/hooks/application_command.ts @@ -1,4 +1,4 @@ -import type { GatewayApplicationCommandPermissionsUpdateDispatchData } from 'discord-api-types/v10'; +import type { GatewayApplicationCommandPermissionsUpdateDispatchData } from '../../types'; import { toCamelCase } from '../../common'; import type { UsingClient } from '../../commands'; diff --git a/src/events/hooks/auto_moderation.ts b/src/events/hooks/auto_moderation.ts index ae561de..b6a9a84 100644 --- a/src/events/hooks/auto_moderation.ts +++ b/src/events/hooks/auto_moderation.ts @@ -3,7 +3,7 @@ import type { GatewayAutoModerationRuleCreateDispatchData, GatewayAutoModerationRuleDeleteDispatchData, GatewayAutoModerationRuleUpdateDispatchData, -} from 'discord-api-types/v10'; +} from '../../types'; import { toCamelCase } from '../../common'; import type { UsingClient } from '../../commands'; import { Transformers } from '../../client/transformers'; diff --git a/src/events/hooks/channel.ts b/src/events/hooks/channel.ts index 6c8f8bd..e6e03ed 100644 --- a/src/events/hooks/channel.ts +++ b/src/events/hooks/channel.ts @@ -3,7 +3,7 @@ import type { GatewayChannelDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayChannelUpdateDispatchData, -} from 'discord-api-types/v10'; +} from '../../types'; import { toCamelCase } from '../../common'; import type { AllChannels } from '../../structures'; diff --git a/src/events/hooks/dispatch.ts b/src/events/hooks/dispatch.ts index 8504cdb..6832fd8 100644 --- a/src/events/hooks/dispatch.ts +++ b/src/events/hooks/dispatch.ts @@ -1,4 +1,4 @@ -import type { GatewayDispatchPayload, GatewayReadyDispatchData, GatewayResumedDispatch } from 'discord-api-types/v10'; +import type { GatewayDispatchPayload, GatewayReadyDispatchData, GatewayResumedDispatch } from '../../types'; import type { UsingClient } from '../../commands'; import { Transformers } from '../../client/transformers'; diff --git a/src/events/hooks/entitlement.ts b/src/events/hooks/entitlement.ts index 3b6fdbe..fc99c81 100644 --- a/src/events/hooks/entitlement.ts +++ b/src/events/hooks/entitlement.ts @@ -1,4 +1,4 @@ -import type { APIEntitlement } from 'discord-api-types/v10'; +import type { APIEntitlement } from '../../types'; import { toCamelCase } from '../../common'; import type { UsingClient } from '../../commands'; diff --git a/src/events/hooks/guild.ts b/src/events/hooks/guild.ts index 4538702..052c218 100644 --- a/src/events/hooks/guild.ts +++ b/src/events/hooks/guild.ts @@ -20,7 +20,7 @@ import type { GatewayGuildScheduledEventUserRemoveDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildUpdateDispatchData, -} from 'discord-api-types/v10'; +} from '../../types'; import { toCamelCase } from '../../common'; import type { UsingClient } from '../../commands'; import { diff --git a/src/events/hooks/integration.ts b/src/events/hooks/integration.ts index 862234d..ca24e51 100644 --- a/src/events/hooks/integration.ts +++ b/src/events/hooks/integration.ts @@ -2,7 +2,7 @@ import type { GatewayIntegrationCreateDispatchData, GatewayIntegrationDeleteDispatchData, GatewayIntegrationUpdateDispatchData, -} from 'discord-api-types/v10'; +} from '../../types'; import { toCamelCase } from '../../common'; import type { UsingClient } from '../../commands'; import { Transformers } from '../../client/transformers'; diff --git a/src/events/hooks/interactions.ts b/src/events/hooks/interactions.ts index 9c02d70..d38681b 100644 --- a/src/events/hooks/interactions.ts +++ b/src/events/hooks/interactions.ts @@ -1,4 +1,4 @@ -import type { GatewayInteractionCreateDispatchData } from 'discord-api-types/v10'; +import type { GatewayInteractionCreateDispatchData } from '../../types'; import { BaseInteraction } from '../../structures'; import type { UsingClient } from '../../commands'; diff --git a/src/events/hooks/invite.ts b/src/events/hooks/invite.ts index c698ad5..cd80479 100644 --- a/src/events/hooks/invite.ts +++ b/src/events/hooks/invite.ts @@ -1,4 +1,4 @@ -import type { GatewayInviteCreateDispatchData, GatewayInviteDeleteDispatchData } from 'discord-api-types/v10'; +import type { GatewayInviteCreateDispatchData, GatewayInviteDeleteDispatchData } from '../../types'; import type { UsingClient } from '../../commands'; import { toCamelCase } from '../../common'; diff --git a/src/events/hooks/message.ts b/src/events/hooks/message.ts index 860273a..87f8b9f 100644 --- a/src/events/hooks/message.ts +++ b/src/events/hooks/message.ts @@ -9,7 +9,7 @@ import type { GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayMessageUpdateDispatchData, -} from 'discord-api-types/v10'; +} from '../../types'; import { type MakeRequired, type PartialClass, toCamelCase, type ObjectToLower } from '../../common'; import type { UsingClient } from '../../commands'; import { type MessageStructure, Transformers } from '../../client/transformers'; diff --git a/src/events/hooks/presence.ts b/src/events/hooks/presence.ts index e0b7491..cd20c80 100644 --- a/src/events/hooks/presence.ts +++ b/src/events/hooks/presence.ts @@ -1,4 +1,4 @@ -import type { GatewayPresenceUpdateDispatchData } from 'discord-api-types/v10'; +import type { GatewayPresenceUpdateDispatchData } from '../../types'; import type { UsingClient } from '../../commands'; import { toCamelCase } from '../../common'; diff --git a/src/events/hooks/stage.ts b/src/events/hooks/stage.ts index 2e4ec19..ef5592d 100644 --- a/src/events/hooks/stage.ts +++ b/src/events/hooks/stage.ts @@ -2,7 +2,7 @@ import type { GatewayStageInstanceCreateDispatchData, GatewayStageInstanceDeleteDispatchData, GatewayStageInstanceUpdateDispatchData, -} from 'discord-api-types/v10'; +} from '../../types'; import type { UsingClient } from '../../commands'; import { type ObjectToLower, toCamelCase } from '../../common'; import type { StageInstances } from '../../cache/resources/stage-instances'; diff --git a/src/events/hooks/thread.ts b/src/events/hooks/thread.ts index 023de54..a593ee4 100644 --- a/src/events/hooks/thread.ts +++ b/src/events/hooks/thread.ts @@ -5,7 +5,7 @@ import type { GatewayThreadMemberUpdateDispatchData, GatewayThreadMembersUpdateDispatchData, GatewayThreadUpdateDispatchData, -} from 'discord-api-types/v10'; +} from '../../types'; import { toCamelCase } from '../../common'; import type { UsingClient } from '../../commands'; import { type ThreadChannelStructure, Transformers } from '../../client/transformers'; diff --git a/src/events/hooks/typing.ts b/src/events/hooks/typing.ts index 9be61a3..b1c3ca8 100644 --- a/src/events/hooks/typing.ts +++ b/src/events/hooks/typing.ts @@ -1,4 +1,4 @@ -import type { GatewayTypingStartDispatchData } from 'discord-api-types/v10'; +import type { GatewayTypingStartDispatchData } from '../../types'; import { toCamelCase } from '../../common'; import type { UsingClient } from '../../commands'; import { Transformers } from '../../client/transformers'; diff --git a/src/events/hooks/user.ts b/src/events/hooks/user.ts index 77b3ad0..e470de3 100644 --- a/src/events/hooks/user.ts +++ b/src/events/hooks/user.ts @@ -1,4 +1,4 @@ -import type { GatewayUserUpdateDispatchData } from 'discord-api-types/v10'; +import type { GatewayUserUpdateDispatchData } from '../../types'; import type { UsingClient } from '../../commands'; import { Transformers, type UserStructure } from '../../client/transformers'; diff --git a/src/events/hooks/webhook.ts b/src/events/hooks/webhook.ts index 19ce5ea..5d0006c 100644 --- a/src/events/hooks/webhook.ts +++ b/src/events/hooks/webhook.ts @@ -1,4 +1,4 @@ -import type { GatewayWebhooksUpdateDispatchData } from 'discord-api-types/v10'; +import type { GatewayWebhooksUpdateDispatchData } from '../../types'; import { toCamelCase } from '../../common'; import type { UsingClient } from '../../commands'; diff --git a/src/index.ts b/src/index.ts index 427ec29..4570d23 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { GatewayIntentBits } from 'discord-api-types/gateway/v10'; +import { GatewayIntentBits } from './types'; import { BaseClient, type BaseClientOptions, @@ -69,7 +69,8 @@ export const config = { ? typeof data.intents === 'number' ? data.intents : data.intents?.reduce( - (pr, acc) => pr | (typeof acc === 'number' ? acc : GatewayIntentBits[acc]), + (pr, acc) => + pr | (typeof acc === 'number' ? acc : GatewayIntentBits[acc as keyof typeof GatewayIntentBits]), 0, ) ?? 0 : 0, diff --git a/src/langs/handler.ts b/src/langs/handler.ts index 6fa4667..d342d93 100644 --- a/src/langs/handler.ts +++ b/src/langs/handler.ts @@ -1,7 +1,7 @@ -import type { Locale, LocaleString } from 'discord-api-types/v10'; import { BaseHandler } from '../common'; import { LangRouter } from './router'; import type { FileLoaded } from '../commands/handler'; +import type { LocaleString, Locale } from '../types'; export class LangsHandler extends BaseHandler { values: Partial> = {}; diff --git a/src/structures/AutoModerationRule.ts b/src/structures/AutoModerationRule.ts index 11b4697..941d6c4 100644 --- a/src/structures/AutoModerationRule.ts +++ b/src/structures/AutoModerationRule.ts @@ -1,10 +1,10 @@ +import type { UsingClient } from '../commands'; +import type { MethodContext, ObjectToLower } from '../common'; import type { APIAutoModerationRule, RESTPatchAPIAutoModerationRuleJSONBody, RESTPostAPIAutoModerationRuleJSONBody, -} from 'discord-api-types/v10'; -import type { UsingClient } from '../commands'; -import type { MethodContext, ObjectToLower } from '../common'; +} from '../types'; import { DiscordBase } from './extra/DiscordBase'; export interface AutoModerationRule extends ObjectToLower {} diff --git a/src/structures/ClientUser.ts b/src/structures/ClientUser.ts index be9b5e6..2bd8a8e 100644 --- a/src/structures/ClientUser.ts +++ b/src/structures/ClientUser.ts @@ -1,5 +1,5 @@ -import type { GatewayReadyDispatchData, RESTPatchAPICurrentUserJSONBody } from 'discord-api-types/v10'; import type { UsingClient } from '../commands'; +import type { GatewayReadyDispatchData, RESTPatchAPICurrentUserJSONBody } from '../types'; import { User } from './User'; export class ClientUser extends User { diff --git a/src/structures/Guild.ts b/src/structures/Guild.ts index 5f5c85f..2b595c6 100644 --- a/src/structures/Guild.ts +++ b/src/structures/Guild.ts @@ -1,9 +1,3 @@ -import type { - APIGuild, - APIPartialGuild, - GatewayGuildCreateDispatchData, - RESTPatchAPIGuildJSONBody, -} from 'discord-api-types/v10'; import type { UsingClient } from '../commands'; import type { ObjectToLower, StructPropState, StructStates, ToClass } from '../common/types/util'; import { AutoModerationRule } from './AutoModerationRule'; @@ -16,6 +10,7 @@ import { BaseChannel, WebhookGuildMethods } from './channels'; import { BaseGuild } from './extra/BaseGuild'; import type { DiscordBase } from './extra/DiscordBase'; import { GuildBan } from './GuildBan'; +import type { APIGuild, APIPartialGuild, GatewayGuildCreateDispatchData, RESTPatchAPIGuildJSONBody } from '../types'; export interface Guild extends ObjectToLower>, DiscordBase {} export class Guild extends (BaseGuild as unknown as ToClass< diff --git a/src/structures/GuildBan.ts b/src/structures/GuildBan.ts index 672a3ea..5143197 100644 --- a/src/structures/GuildBan.ts +++ b/src/structures/GuildBan.ts @@ -1,8 +1,8 @@ -import type { APIBan, RESTGetAPIGuildBansQuery } from 'discord-api-types/v10'; import type { UsingClient } from '../commands'; import { Formatter, type MethodContext, type ObjectToLower } from '../common'; import { DiscordBase } from './extra/DiscordBase'; import type { BanShorter } from '../common/shorters/bans'; +import type { APIBan, RESTGetAPIGuildBansQuery } from '../types'; export interface GuildBan extends DiscordBase, ObjectToLower> {} diff --git a/src/structures/GuildEmoji.ts b/src/structures/GuildEmoji.ts index 007fe13..80b0228 100644 --- a/src/structures/GuildEmoji.ts +++ b/src/structures/GuildEmoji.ts @@ -1,7 +1,7 @@ -import type { APIEmoji, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildEmojiJSONBody } from 'discord-api-types/v10'; import type { BaseCDNUrlOptions } from '../api'; import type { UsingClient } from '../commands'; import { Formatter, type EmojiShorter, type MethodContext, type ObjectToLower } from '../common'; +import type { APIEmoji, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildEmojiJSONBody } from '../types'; import { DiscordBase } from './extra/DiscordBase'; export interface GuildEmoji extends DiscordBase, ObjectToLower> {} diff --git a/src/structures/GuildMember.ts b/src/structures/GuildMember.ts index c532309..229101f 100644 --- a/src/structures/GuildMember.ts +++ b/src/structures/GuildMember.ts @@ -9,21 +9,27 @@ export type GuildMemberData = import type { APIGuildMember, - APIInteractionDataResolvedGuildMember, - APIUser, - GatewayGuildMemberAddDispatchData, GatewayGuildMemberUpdateDispatchData, - RESTGetAPIGuildMembersQuery, - RESTGetAPIGuildMembersSearchQuery, - RESTPatchAPIGuildMemberJSONBody, + GatewayGuildMemberAddDispatchData, + APIInteractionDataResolvedGuildMember, RESTPutAPIGuildBanJSONBody, + RESTPatchAPIGuildMemberJSONBody, + RESTGetAPIGuildMembersSearchQuery, RESTPutAPIGuildMemberJSONBody, -} from 'discord-api-types/v10'; + RESTGetAPIGuildMembersQuery, + APIUser, +} from '../types'; import type { UsingClient } from '../commands'; -import { Formatter, type MessageCreateBodyRequest, type ObjectToLower, type ToClass } from '../common'; -import type { ImageOptions, MethodContext } from '../common/types/options'; -import type { GuildMemberResolvable } from '../common/types/resolvables'; import { PermissionsBitField } from './extra/Permissions'; +import { + Formatter, + type MessageCreateBodyRequest, + type ObjectToLower, + type ToClass, + type ImageOptions, + type MethodContext, + type GuildMemberResolvable, +} from '../common'; import { Transformers, type UserStructure } from '../client/transformers'; export interface BaseGuildMember extends DiscordBase, ObjectToLower> {} diff --git a/src/structures/GuildPreview.ts b/src/structures/GuildPreview.ts index 9d0895b..e8b0023 100644 --- a/src/structures/GuildPreview.ts +++ b/src/structures/GuildPreview.ts @@ -1,5 +1,5 @@ -import type { APIGuildPreview, APIPartialGuild } from 'discord-api-types/v10'; import type { UsingClient } from '../commands'; +import type { APIGuildPreview, APIPartialGuild } from '../types'; import { AnonymousGuild } from './AnonymousGuild'; /** diff --git a/src/structures/GuildRole.ts b/src/structures/GuildRole.ts index 9a02f7a..6c6e7dc 100644 --- a/src/structures/GuildRole.ts +++ b/src/structures/GuildRole.ts @@ -3,7 +3,7 @@ import type { RESTPatchAPIGuildRoleJSONBody, RESTPatchAPIGuildRolePositionsJSONBody, RESTPostAPIGuildRoleJSONBody, -} from 'discord-api-types/v10'; +} from '../types'; import type { UsingClient } from '../commands'; import { Formatter, type MethodContext, type ObjectToLower } from '../common'; import { DiscordBase } from './extra/DiscordBase'; diff --git a/src/structures/GuildTemplate.ts b/src/structures/GuildTemplate.ts index 749574f..e788a7e 100644 --- a/src/structures/GuildTemplate.ts +++ b/src/structures/GuildTemplate.ts @@ -1,8 +1,4 @@ -import type { - APITemplate, - RESTPatchAPIGuildTemplateJSONBody, - RESTPostAPIGuildTemplatesJSONBody, -} from 'discord-api-types/v10'; +import type { APITemplate, RESTPatchAPIGuildTemplateJSONBody, RESTPostAPIGuildTemplatesJSONBody } from '../types'; import type { UsingClient } from '../commands'; import type { MethodContext, ObjectToLower } from '../common'; import { Base } from './extra/Base'; diff --git a/src/structures/Interaction.ts b/src/structures/Interaction.ts index bcba2af..abd40b2 100644 --- a/src/structures/Interaction.ts +++ b/src/structures/Interaction.ts @@ -36,7 +36,7 @@ import { type MessageFlags, type RESTPostAPIInteractionCallbackJSONBody, type RESTAPIAttachment, -} from 'discord-api-types/v10'; +} from '../types'; import { mix } from 'ts-mixer'; import type { RawFile } from '../api'; import { ActionRow, Embed, Modal, PollBuilder, resolveAttachment, resolveFiles } from '../builders'; diff --git a/src/structures/Message.ts b/src/structures/Message.ts index 8e683f0..d7474e3 100644 --- a/src/structures/Message.ts +++ b/src/structures/Message.ts @@ -5,7 +5,7 @@ import type { APIMessage, APIUser, GatewayMessageCreateDispatchData, -} from 'discord-api-types/v10'; +} from '../types'; import type { ListenerOptions } from '../builders'; import type { UsingClient } from '../commands'; import { toCamelCase, type ObjectToLower } from '../common'; diff --git a/src/structures/Poll.ts b/src/structures/Poll.ts index 196e42e..070482c 100644 --- a/src/structures/Poll.ts +++ b/src/structures/Poll.ts @@ -1,4 +1,4 @@ -import type { APIPoll } from 'discord-api-types/v10'; +import type { APIPoll } from '../types'; import { toCamelCase, type ObjectToLower } from '../common'; import { Base } from './extra/Base'; import type { UsingClient } from '../commands'; diff --git a/src/structures/Sticker.ts b/src/structures/Sticker.ts index 633e6c0..d36d216 100644 --- a/src/structures/Sticker.ts +++ b/src/structures/Sticker.ts @@ -1,8 +1,4 @@ -import type { - APISticker, - RESTPatchAPIGuildStickerJSONBody, - RESTPostAPIGuildStickerFormDataBody, -} from 'discord-api-types/v10'; +import type { APISticker, RESTPatchAPIGuildStickerJSONBody, RESTPostAPIGuildStickerFormDataBody } from '../types'; import type { RawFile, UsingClient } from '..'; import type { Attachment, AttachmentBuilder } from '../builders'; import type { MethodContext, ObjectToLower } from '../common'; diff --git a/src/structures/User.ts b/src/structures/User.ts index 2eceeb3..aee2801 100644 --- a/src/structures/User.ts +++ b/src/structures/User.ts @@ -1,7 +1,7 @@ -import type { APIUser } from 'discord-api-types/v10'; import { calculateUserDefaultAvatarIndex } from '../api'; import { Formatter, type MessageCreateBodyRequest, type ObjectToLower } from '../common'; import type { ImageOptions } from '../common/types/options'; +import type { APIUser } from '../types'; import { DiscordBase } from './extra/DiscordBase'; export interface User extends ObjectToLower {} diff --git a/src/structures/Webhook.ts b/src/structures/Webhook.ts index 139cd4c..64557f8 100644 --- a/src/structures/Webhook.ts +++ b/src/structures/Webhook.ts @@ -7,7 +7,7 @@ import type { RESTPatchAPIWebhookJSONBody, RESTPatchAPIWebhookWithTokenJSONBody, RESTPostAPIWebhookWithTokenQuery, -} from 'discord-api-types/v10'; +} from '../types'; import type { UsingClient } from '../commands'; import type { ImageOptions, diff --git a/src/structures/channels.ts b/src/structures/channels.ts index 73be71c..298b1ee 100644 --- a/src/structures/channels.ts +++ b/src/structures/channels.ts @@ -1,30 +1,30 @@ import { - ChannelFlags, - ChannelType, - type RESTAPIAttachment, - VideoQualityMode, type APIChannelBase, - type APIDMChannel, - type APIGuildCategoryChannel, - type APIGuildChannel, - type APIGuildForumChannel, - type APIGuildForumDefaultReactionEmoji, - type APIGuildForumTag, - type APIGuildMediaChannel, - type APIGuildStageVoiceChannel, - type APIGuildVoiceChannel, - type APINewsChannel, - type APITextChannel, - type APIThreadChannel, - type RESTGetAPIChannelMessageReactionUsersQuery, type RESTPatchAPIChannelJSONBody, - type RESTPatchAPIGuildChannelPositionsJSONBody, - type RESTPostAPIChannelWebhookJSONBody, type RESTPostAPIGuildChannelJSONBody, - type RESTPostAPIGuildForumThreadsJSONBody, - type SortOrderType, + type RESTPatchAPIGuildChannelPositionsJSONBody, + type APIGuildChannel, + type RESTGetAPIChannelMessageReactionUsersQuery, + type RESTAPIAttachment, + type APITextChannel, + type APIGuildForumTag, type ThreadAutoArchiveDuration, -} from 'discord-api-types/v10'; + type APIGuildForumDefaultReactionEmoji, + type SortOrderType, + type RESTPostAPIGuildForumThreadsJSONBody, + type RESTPostAPIChannelWebhookJSONBody, + type APIDMChannel, + type APIGuildVoiceChannel, + type APIGuildStageVoiceChannel, + type APIGuildMediaChannel, + type APIGuildForumChannel, + type APIThreadChannel, + ChannelFlags, + type APIGuildCategoryChannel, + type APINewsChannel, + ChannelType, + VideoQualityMode, +} from '../types'; import { mix } from 'ts-mixer'; import { ActionRow, Embed, PollBuilder, resolveAttachment } from '../builders'; import type { UsingClient } from '../commands'; diff --git a/src/structures/extra/BaseGuild.ts b/src/structures/extra/BaseGuild.ts index d6422b5..7b44d05 100644 --- a/src/structures/extra/BaseGuild.ts +++ b/src/structures/extra/BaseGuild.ts @@ -1,6 +1,6 @@ -import { type APIPartialGuild, GuildFeature } from 'discord-api-types/v10'; import type { ObjectToLower } from '../../common'; import type { ImageOptions } from '../../common/types/options'; +import { type APIPartialGuild, GuildFeature } from '../../types'; import { DiscordBase } from './DiscordBase'; export interface BaseGuild extends ObjectToLower {} diff --git a/src/structures/extra/Permissions.ts b/src/structures/extra/Permissions.ts index 876a712..c6da596 100644 --- a/src/structures/extra/Permissions.ts +++ b/src/structures/extra/Permissions.ts @@ -1,5 +1,5 @@ -import { PermissionFlagsBits } from 'discord-api-types/v10'; import type { PermissionStrings } from '../../common'; +import { PermissionFlagsBits } from '../../types'; import { BitField, type BitFieldResolvable } from './BitField'; export class PermissionsBitField extends BitField { diff --git a/src/structures/extra/functions.ts b/src/structures/extra/functions.ts index 8180b8b..90f5b18 100644 --- a/src/structures/extra/functions.ts +++ b/src/structures/extra/functions.ts @@ -1,9 +1,6 @@ -import { FormattingPatterns } from 'discord-api-types/globals'; -import type { APIPartialEmoji } from 'discord-api-types/v10'; import type { Cache } from '../../cache'; -import type { TypeArray } from '../../common'; -import { DiscordEpoch } from '../../common'; -import type { EmojiResolvable } from '../../common/types/resolvables'; +import { DiscordEpoch, type EmojiResolvable, type TypeArray } from '../../common'; +import { type APIPartialEmoji, FormattingPatterns } from '../../types'; /** * Convert a timestamp to a snowflake. * @param timestamp The timestamp to convert. * @returns The snowflake. */ export function snowflakeToTimestamp(id: string): bigint { diff --git a/src/types/README.md b/src/types/README.md new file mode 100644 index 0000000..e05f9e4 --- /dev/null +++ b/src/types/README.md @@ -0,0 +1,105 @@ +# Discord API Types + +[![discord-api-types](https://raw.githubusercontent.com/discordjs/discord-api-types/main/website/static/svgs/logo_long_blurple.svg)](https://github.com/discordjs/discord-api-types) + +[![GitHub](https://img.shields.io/github/license/discordjs/discord-api-types)](https://github.com/discordjs/discord-api-types/blob/main/LICENSE.md) +[![npm](https://img.shields.io/npm/v/discord-api-types?color=crimson&logo=npm)](https://www.npmjs.com/package/discord-api-types) +[![deno](https://img.shields.io/npm/v/discord-api-types?color=blue&label=deno&logo=deno)](https://deno.land/x/discord_api_types) +[![Patreon Donate](https://img.shields.io/badge/patreon-donate-brightgreen.svg?label=Donate%20with%20Patreon&logo=patreon&colorB=F96854&link=https://www.patreon.com/vladfrangu)](https://www.patreon.com/vladfrangu) +[![Ko-fi Donate](https://img.shields.io/badge/kofi-donate-brightgreen.svg?label=Donate%20with%20Ko-fi&logo=ko-fi&colorB=F16061&link=https://ko-fi.com/wolfgalvlad&logoColor=FFFFFF)](https://ko-fi.com/wolfgalvlad) +[![GitHub Sponsors](https://img.shields.io/badge/patreon-donate-brightgreen.svg?label=Sponsor%20through%20GitHub&logo=github&colorB=F96854&link=https://github.com/sponsors/vladfrangu)](https://github.com/sponsors/vladfrangu) +[![Powered by Vercel](https://raw.githubusercontent.com/discordjs/discord-api-types/main/website/static/powered-by-vercel.svg)](https://vercel.com?utm_source=discordjs&utm_campaign=oss) + +Simple type definitions for the [Discord API](https://discord.com/developers/docs/intro). + +## Installation + +Install with [npm](https://www.npmjs.com/) / [yarn](https://yarnpkg.com) / [pnpm](https://pnpm.js.org/): + +```sh +npm install discord-api-types +yarn add discord-api-types +pnpm add discord-api-types +``` + +### Usage + +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/v10'); +``` + +```ts +// TypeScript/ES Module support +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/v10'); +``` + +```ts +// TypeScript/ES Module support +import { GatewayVersion } from 'discord-api-types/gateway/v10'; +``` + +> _**Note:** The `v*` exports (`discord-api-types/v*`) include the appropriate version of `gateway`, `payloads`, `rest`, `rpc`, and `utils` you specified, alongside the `globals` exports_ + +### Deno + +We also provide typings compatible with the [deno](https://deno.land/) runtime. You have 3 ways you can import them: + +1. Directly from GitHub + +```ts +// Importing a specific API version +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/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/v10?dts'; +``` + +## Project Structure + +The exports of each API version is split into three main parts: + +- Everything exported with the `API` prefix represents a payload you may get from the REST API _or_ the Gateway. + +- Everything exported with the `Gateway` prefix represents data that ONLY comes from or is directly related to the Gateway. + +- Everything exported with the `REST` prefix represents data that ONLY comes from or is directly related to the REST API. + + - For endpoint options, they will follow the following structure: `REST` where the type represents what it will return. + + - For example, `RESTPostAPIChannelMessageJSONBody` or `RESTGetAPIGatewayBotInfoResult`. + + - Some exported types (specifically OAuth2 related ones) may not respect this entire structure due to the nature of the fields. They will start with either `RESTOAuth2` or with something similar to `RESTOAuth2` + + - If a type ends with `Result`, then it represents the expected result by calling its accompanying route. + + - Types that are exported as `never` usually mean the result will be a `204 No Content`, so you can safely ignore it. This does **not** account for errors. + +- Anything else that is miscellaneous will be exported based on what it represents (for example the `REST` route object). + +- There may be types exported that are identical for all versions. These will be exported as is and can be found in the `globals` file. They will still be prefixed accordingly as described above. + +**A note about how types are documented**: This package will add types only for known and documented properties that are present in Discord's [API Documentation repository](https://github.com/discord/discord-api-docs), +that are mentioned in an open pull request, or known through other means _and have received the green light to be used_. +Anything else will not be documented (for example client only types). + +With that aside, we may allow certain types that are not documented in the [API Documentation repository](https://github.com/discord/discord-api-docs) on a case by case basis. +They will be documented with an `@unstable` tag and are not subject with the same versioning rules. diff --git a/src/types/gateway.ts b/src/types/gateway.ts new file mode 100644 index 0000000..fce9346 --- /dev/null +++ b/src/types/gateway.ts @@ -0,0 +1,1969 @@ +// https://github.com/discordjs/discord-api-types/blob/main/gateway/v10.ts + +import type { Snowflake, ChannelType, GatewayDispatchEvents, GatewayOpcodes } from './index'; +import type { GatewayPresenceUpdate } from './payloads/gateway'; +import type { + APIApplication, + APIApplicationCommandPermission, + APIAutoModerationRule, + APIAutoModerationAction, + 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, + AutoModerationRuleTriggerType, + APIAuditLogEntry, + APIEntitlement, +} from './payloads/index'; +import type { ReactionType } from './rest/index'; +import type { Nullable } from './utils'; + +/** + * https://discord.com/developers/docs/topics/gateway#connecting-gateway-url-query-string-params + */ +export interface GatewayURLQuery { + v: string; + encoding: 'etf' | 'json'; + compress?: 'zlib-stream'; +} + +/** + * Types extracted from https://discord.com/developers/docs/topics/gateway + */ + +export type GatewaySendPayload = + | GatewayHeartbeat + | GatewayIdentify + | GatewayRequestGuildMembers + | GatewayResume + | GatewayUpdatePresence + | GatewayVoiceStateUpdate; + +export type GatewayReceivePayload = + | GatewayDispatchPayload + | GatewayHeartbeatAck + | GatewayHeartbeatRequest + | GatewayHello + | GatewayInvalidSession + | GatewayReconnect; + +export type GatewayDispatchPayload = + | GatewayApplicationCommandPermissionsUpdateDispatch + | GatewayAutoModerationActionExecutionDispatch + | GatewayAutoModerationRuleCreateDispatch + | GatewayAutoModerationRuleDeleteDispatch + | GatewayAutoModerationRuleModifyDispatch + | GatewayChannelModifyDispatch + | GatewayChannelPinsUpdateDispatch + | GatewayEntitlementModifyDispatch + | GatewayGuildAuditLogEntryCreateDispatch + | GatewayGuildBanModifyDispatch + | GatewayGuildCreateDispatch + | GatewayGuildDeleteDispatch + | GatewayGuildEmojisUpdateDispatch + | GatewayGuildIntegrationsUpdateDispatch + | GatewayGuildMemberAddDispatch + | GatewayGuildMemberRemoveDispatch + | GatewayGuildMembersChunkDispatch + | GatewayGuildMemberUpdateDispatch + | GatewayGuildModifyDispatch + | GatewayGuildRoleDeleteDispatch + | GatewayGuildRoleModifyDispatch + | GatewayGuildScheduledEventCreateDispatch + | GatewayGuildScheduledEventDeleteDispatch + | GatewayGuildScheduledEventUpdateDispatch + | GatewayGuildScheduledEventUserAddDispatch + | GatewayGuildScheduledEventUserRemoveDispatch + | GatewayGuildStickersUpdateDispatch + | GatewayIntegrationCreateDispatch + | GatewayIntegrationDeleteDispatch + | GatewayIntegrationUpdateDispatch + | GatewayInteractionCreateDispatch + | GatewayInviteCreateDispatch + | GatewayInviteDeleteDispatch + | GatewayMessageCreateDispatch + | GatewayMessageDeleteBulkDispatch + | GatewayMessageDeleteDispatch + | GatewayMessagePollVoteAddDispatch + | GatewayMessagePollVoteRemoveDispatch + | GatewayMessageReactionAddDispatch + | GatewayMessageReactionRemoveAllDispatch + | GatewayMessageReactionRemoveDispatch + | GatewayMessageReactionRemoveEmojiDispatch + | GatewayMessageUpdateDispatch + | GatewayPresenceUpdateDispatch + | GatewayReadyDispatch + | GatewayResumedDispatch + | GatewayStageInstanceCreateDispatch + | GatewayStageInstanceDeleteDispatch + | GatewayStageInstanceUpdateDispatch + | GatewayThreadCreateDispatch + | GatewayThreadDeleteDispatch + | GatewayThreadListSyncDispatch + | GatewayThreadMembersUpdateDispatch + | GatewayThreadMemberUpdateDispatch + | GatewayThreadUpdateDispatch + | GatewayTypingStartDispatch + | GatewayUserUpdateDispatch + | GatewayVoiceServerUpdateDispatch + | GatewayVoiceStateUpdateDispatch + | GatewayWebhooksUpdateDispatch; + +// #region Dispatch Payloads + +/** + * https://discord.com/developers/docs/topics/gateway-events#hello + */ +export interface GatewayHello extends NonDispatchPayload { + op: GatewayOpcodes.Hello; + d: GatewayHelloData; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#hello + */ +export interface GatewayHelloData { + /** + * The interval (in milliseconds) the client should heartbeat with + */ + heartbeat_interval: number; +} + +/** + * https://discord.com/developers/docs/topics/gateway#sending-heartbeats + */ +export interface GatewayHeartbeatRequest extends NonDispatchPayload { + op: GatewayOpcodes.Heartbeat; + d: never; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#heartbeat + */ +export interface GatewayHeartbeatAck extends NonDispatchPayload { + op: GatewayOpcodes.HeartbeatAck; + d: never; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#invalid-session + */ +export interface GatewayInvalidSession extends NonDispatchPayload { + op: GatewayOpcodes.InvalidSession; + d: GatewayInvalidSessionData; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#invalid-session + */ +export type GatewayInvalidSessionData = boolean; + +/** + * https://discord.com/developers/docs/topics/gateway-events#reconnect + */ +export interface GatewayReconnect extends NonDispatchPayload { + op: GatewayOpcodes.Reconnect; + d: never; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#ready + */ +export type GatewayReadyDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway-events#ready + */ +export interface GatewayReadyDispatchData { + /** + * Gateway version + * + * See https://discord.com/developers/docs/reference#api-versioning + */ + 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; + /** + * Gateway url for resuming connections + */ + resume_gateway_url: 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-events#resumed + */ +export type GatewayResumedDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-create + * https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-update + * https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-delete + */ +export type GatewayAutoModerationRuleModifyDispatch = DataPayload< + | GatewayDispatchEvents.AutoModerationRuleCreate + | GatewayDispatchEvents.AutoModerationRuleDelete + | GatewayDispatchEvents.AutoModerationRuleUpdate, + GatewayAutoModerationRuleModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-create + * https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-update + * https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-delete + */ +export type GatewayAutoModerationRuleModifyDispatchData = APIAutoModerationRule; + +/** + * https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-create + */ +export type GatewayAutoModerationRuleCreateDispatch = GatewayAutoModerationRuleModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-create + */ +export type GatewayAutoModerationRuleCreateDispatchData = GatewayAutoModerationRuleModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-update + */ +export type GatewayAutoModerationRuleUpdateDispatch = GatewayAutoModerationRuleModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-update + */ +export type GatewayAutoModerationRuleUpdateDispatchData = GatewayAutoModerationRuleModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-delete + */ +export type GatewayAutoModerationRuleDeleteDispatch = GatewayAutoModerationRuleModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-delete + */ +export type GatewayAutoModerationRuleDeleteDispatchData = GatewayAutoModerationRuleModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#auto-moderation-action-execution + */ +export type GatewayAutoModerationActionExecutionDispatch = DataPayload< + GatewayDispatchEvents.AutoModerationActionExecution, + GatewayAutoModerationActionExecutionDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#auto-moderation-action-execution + */ +export interface GatewayAutoModerationActionExecutionDispatchData { + /** + * The id of the guild in which action was executed + */ + guild_id: Snowflake; + /** + * The action which was executed + */ + action: APIAutoModerationAction; + /** + * The id of the rule which action belongs to + */ + rule_id: Snowflake; + /** + * The trigger type of rule which was triggered + */ + rule_trigger_type: AutoModerationRuleTriggerType; + /** + * The id of the user which generated the content which triggered the rule + */ + user_id: Snowflake; + /** + * The id of the channel in which user content was posted + */ + channel_id?: Snowflake; + /** + * The id of any user message which content belongs to + * + * This field will not be present if message was blocked by AutoMod or content was not part of any message + */ + message_id?: Snowflake; + /** + * The id of any system auto moderation messages posted as a result of this action + * + * This field will not be present if this event does not correspond to an action with type {@link AutoModerationActionType.SendAlertMessage} + */ + alert_system_message_id?: Snowflake; + /** + * The user generated text content + * + * `MESSAGE_CONTENT` (`1 << 15`) gateway intent is required to receive non-empty values from this field + */ + content: string; + /** + * The word or phrase configured in the rule that triggered the rule + */ + matched_keyword: string | null; + /** + * The substring in content that triggered the rule + * + * `MESSAGE_CONTENT` (`1 << 15`) gateway intent is required to receive non-empty values from this field + */ + matched_content: string | null; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#application-command-permissions-update + */ +export type GatewayApplicationCommandPermissionsUpdateDispatch = DataPayload< + GatewayDispatchEvents.ApplicationCommandPermissionsUpdate, + GatewayApplicationCommandPermissionsUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#application-command-permissions-update + */ +export interface GatewayApplicationCommandPermissionsUpdateDispatchData { + /** + * ID of the command or the application ID + */ + id: Snowflake; + /** + * ID of the application the command belongs to + */ + application_id: Snowflake; + /** + * ID of the guild + */ + guild_id: Snowflake; + /** + * Permissions for the command in the guild, max of 100 + */ + permissions: APIApplicationCommandPermission[]; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#channel-create + * https://discord.com/developers/docs/topics/gateway-events#channel-update + * https://discord.com/developers/docs/topics/gateway-events#channel-delete + */ +export type GatewayChannelModifyDispatch = DataPayload< + GatewayDispatchEvents.ChannelCreate | GatewayDispatchEvents.ChannelDelete | GatewayDispatchEvents.ChannelUpdate, + GatewayChannelModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#channel-create + * https://discord.com/developers/docs/topics/gateway-events#channel-update + * https://discord.com/developers/docs/topics/gateway-events#channel-delete + */ +export type GatewayChannelModifyDispatchData = APIChannel; + +/** + * https://discord.com/developers/docs/topics/gateway-events#channel-create + */ +export type GatewayChannelCreateDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#channel-create + */ +export type GatewayChannelCreateDispatchData = GatewayChannelModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#channel-update + */ +export type GatewayChannelUpdateDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#channel-update + */ +export type GatewayChannelUpdateDispatchData = GatewayChannelModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#channel-delete + */ +export type GatewayChannelDeleteDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#channel-delete + */ +export type GatewayChannelDeleteDispatchData = GatewayChannelModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#channel-pins-update + */ +export type GatewayChannelPinsUpdateDispatch = DataPayload< + GatewayDispatchEvents.ChannelPinsUpdate, + GatewayChannelPinsUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#entitlement-create + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementModifyDispatchData = APIEntitlement; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementModifyDispatch = DataPayload< + | GatewayDispatchEvents.EntitlementCreate + | GatewayDispatchEvents.EntitlementDelete + | GatewayDispatchEvents.EntitlementUpdate, + GatewayEntitlementModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + */ +export type GatewayEntitlementCreateDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + */ +export type GatewayEntitlementCreateDispatch = GatewayEntitlementModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + */ +export type GatewayEntitlementUpdateDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + */ +export type GatewayEntitlementUpdateDispatch = GatewayEntitlementModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementDeleteDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementDeleteDispatch = GatewayEntitlementModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-create + */ +export type GatewayGuildModifyDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-update + */ +export type GatewayGuildModifyDispatchData = APIGuild; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-create + */ +export type GatewayGuildCreateDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-create + * https://discord.com/developers/docs/topics/gateway-events#guild-create-guild-create-extra-fields + */ +export interface GatewayGuildCreateDispatchData extends APIGuild { + /** + * When this guild was joined at + * + * **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway-events#guild-create) event** + */ + joined_at: string; + /** + * `true` if this is considered a large guild + * + * **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway-events#guild-create) event** + */ + large: boolean; + /** + * `true` if this guild is unavailable due to an outage + */ + unavailable?: boolean; + /** + * Total number of members in this guild + * + * **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway-events#guild-create) event** + */ + member_count: number; + /** + * States of members currently in voice channels; lacks the `guild_id` key + * + * **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway-events#guild-create) event** + * + * See https://discord.com/developers/docs/resources/voice#voice-state-object + */ + voice_states: Omit[]; + /** + * Users in the guild + * + * **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway-events#guild-create) event** + * + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ + members: APIGuildMember[]; + /** + * Channels in the guild + * + * **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway-events#guild-create) event** + * + * See https://discord.com/developers/docs/resources/channel#channel-object + */ + channels: APIChannel[]; + /** + * Threads in the guild + * + * **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway-events#guild-create) event** + * + * See https://discord.com/developers/docs/resources/channel#channel-object + */ + threads: APIChannel[]; + /** + * Presences of the members in the guild, will only include non-offline members if the size is greater than `large_threshold` + * + * **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway-events#guild-create) event** + * + * See https://discord.com/developers/docs/topics/gateway-events#presence-update + */ + presences: GatewayPresenceUpdate[]; + /** + * The stage instances in the guild + * + * **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway-events#guild-create) event** + * + * See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-stage-instance-structure + */ + stage_instances: APIStageInstance[]; + /** + * The scheduled events in the guild + * + * **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway-events#guild-create) event** + * + * https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object + */ + guild_scheduled_events: APIGuildScheduledEvent[]; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-update + */ +export type GatewayGuildUpdateDispatch = GatewayGuildModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-update + */ +export type GatewayGuildUpdateDispatchData = GatewayGuildModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-delete + */ +export type GatewayGuildDeleteDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-delete + */ +export type GatewayGuildDeleteDispatchData = APIUnavailableGuild; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-ban-add + * https://discord.com/developers/docs/topics/gateway-events#guild-ban-remove + */ +export type GatewayGuildBanModifyDispatch = DataPayload< + GatewayDispatchEvents.GuildBanAdd | GatewayDispatchEvents.GuildBanRemove, + GatewayGuildBanModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-ban-add + * https://discord.com/developers/docs/topics/gateway-events#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-events#guild-ban-add + */ +export type GatewayGuildBanAddDispatch = GatewayGuildBanModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-ban-add + */ +export type GatewayGuildBanAddDispatchData = GatewayGuildBanModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-ban-remove + */ +export type GatewayGuildBanRemoveDispatch = GatewayGuildBanModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-ban-remove + */ +export type GatewayGuildBanRemoveDispatchData = GatewayGuildBanModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-emojis-update + */ +export type GatewayGuildEmojisUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildEmojisUpdate, + GatewayGuildEmojisUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#guild-stickers-update + */ +export type GatewayGuildStickersUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildStickersUpdate, + GatewayGuildStickersUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#guild-integrations-update + */ +export type GatewayGuildIntegrationsUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildIntegrationsUpdate, + GatewayGuildIntegrationsUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-integrations-update + */ +export interface GatewayGuildIntegrationsUpdateDispatchData { + /** + * ID of the guild whose integrations were updated + */ + guild_id: Snowflake; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-member-add + */ +export type GatewayGuildMemberAddDispatch = DataPayload< + GatewayDispatchEvents.GuildMemberAdd, + GatewayGuildMemberAddDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-member-add + */ +export interface GatewayGuildMemberAddDispatchData extends APIGuildMember { + /** + * The id of the guild + */ + guild_id: Snowflake; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-member-remove + */ +export type GatewayGuildMemberRemoveDispatch = DataPayload< + GatewayDispatchEvents.GuildMemberRemove, + GatewayGuildMemberRemoveDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#guild-member-update + */ +export type GatewayGuildMemberUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildMemberUpdate, + GatewayGuildMemberUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-member-update + */ +export type GatewayGuildMemberUpdateDispatchData = Nullable> & + Omit & + Partial> & + Required> & { + /** + * The id of the guild + */ + guild_id: Snowflake; + }; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-members-chunk + */ +export type GatewayGuildMembersChunkDispatch = DataPayload< + GatewayDispatchEvents.GuildMembersChunk, + GatewayGuildMembersChunkDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#update-presence + */ +export type GatewayGuildMembersChunkPresence = Omit; + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#update-presence + */ + presences?: GatewayGuildMembersChunkPresence[]; + /** + * The nonce used in the Guild Members Request + * + * See https://discord.com/developers/docs/topics/gateway-events#request-guild-members + */ + nonce?: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-role-create + * https://discord.com/developers/docs/topics/gateway-events#guild-role-update + */ +export type GatewayGuildRoleModifyDispatch = DataPayload< + GatewayDispatchEvents.GuildRoleCreate | GatewayDispatchEvents.GuildRoleUpdate, + GatewayGuildRoleModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-role-create + * https://discord.com/developers/docs/topics/gateway-events#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-events#guild-role-create + */ +export type GatewayGuildRoleCreateDispatch = GatewayGuildRoleModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-role-create + */ +export type GatewayGuildRoleCreateDispatchData = GatewayGuildRoleModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-role-update + */ +export type GatewayGuildRoleUpdateDispatch = GatewayGuildRoleModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-role-update + */ +export type GatewayGuildRoleUpdateDispatchData = GatewayGuildRoleModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-role-delete + */ +export type GatewayGuildRoleDeleteDispatch = DataPayload< + GatewayDispatchEvents.GuildRoleDelete, + GatewayGuildRoleDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#integration-create + */ +export type GatewayIntegrationCreateDispatch = DataPayload< + GatewayDispatchEvents.IntegrationCreate, + GatewayIntegrationCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#integration-create + */ +export type GatewayIntegrationCreateDispatchData = APIGuildIntegration & { guild_id: Snowflake }; + +/** + * https://discord.com/developers/docs/topics/gateway-events#integration-update + */ +export type GatewayIntegrationUpdateDispatch = DataPayload< + GatewayDispatchEvents.IntegrationUpdate, + GatewayIntegrationUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#integration-update + */ +export type GatewayIntegrationUpdateDispatchData = APIGuildIntegration & { guild_id: Snowflake }; + +/** + * https://discord.com/developers/docs/topics/gateway-events#integration-update + */ +export type GatewayIntegrationDeleteDispatch = DataPayload< + GatewayDispatchEvents.IntegrationDelete, + GatewayIntegrationDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#interaction-create + */ +export type GatewayInteractionCreateDispatch = DataPayload< + GatewayDispatchEvents.InteractionCreate, + GatewayInteractionCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#interaction-create + */ +export type GatewayInteractionCreateDispatchData = APIInteraction; + +/** + * https://discord.com/developers/docs/topics/gateway-events#invite-create + */ +export type GatewayInviteCreateDispatch = DataPayload< + GatewayDispatchEvents.InviteCreate, + GatewayInviteCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#invite-delete + */ +export type GatewayInviteDeleteDispatch = DataPayload< + GatewayDispatchEvents.InviteDelete, + GatewayInviteDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#message-create + */ +export type GatewayMessageCreateDispatch = DataPayload< + GatewayDispatchEvents.MessageCreate, + GatewayMessageCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#message-create + */ +export type GatewayMessageCreateDispatchData = GatewayMessageEventExtraFields & Omit; + +/** + * https://discord.com/developers/docs/topics/gateway-events#message-update + */ +export type GatewayMessageUpdateDispatch = DataPayload< + GatewayDispatchEvents.MessageUpdate, + GatewayMessageUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#message-update + */ +export type GatewayMessageUpdateDispatchData = GatewayMessageEventExtraFields & + Omit, 'mentions'> & { + /** + * ID of the message + */ + id: Snowflake; + /** + * ID of the channel the message was sent in + */ + channel_id: Snowflake; + }; + +export interface GatewayMessageEventExtraFields { + /** + * ID of the guild the message was sent in + */ + guild_id?: Snowflake; + /** + * 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?: Omit; + /** + * 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 })[]; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#message-delete + */ +export type GatewayMessageDeleteDispatch = DataPayload< + GatewayDispatchEvents.MessageDelete, + GatewayMessageDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#message-delete-bulk + */ +export type GatewayMessageDeleteBulkDispatch = DataPayload< + GatewayDispatchEvents.MessageDeleteBulk, + GatewayMessageDeleteBulkDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#message-reaction-add + */ +export type GatewayMessageReactionAddDispatch = ReactionData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#message-reaction-add + */ +export type GatewayMessageReactionAddDispatchData = GatewayMessageReactionAddDispatch['d']; + +/** + * https://discord.com/developers/docs/topics/gateway-events#message-reaction-remove + */ +export type GatewayMessageReactionRemoveDispatch = ReactionData< + GatewayDispatchEvents.MessageReactionRemove, + 'burst_colors' | 'member' | 'message_author_id' +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#message-reaction-remove + */ +export type GatewayMessageReactionRemoveDispatchData = GatewayMessageReactionRemoveDispatch['d']; + +/** + * https://discord.com/developers/docs/topics/gateway-events#message-reaction-remove-all + */ +export type GatewayMessageReactionRemoveAllDispatch = DataPayload< + GatewayDispatchEvents.MessageReactionRemoveAll, + GatewayMessageReactionRemoveAllDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#message-reaction-remove-all + */ +export type GatewayMessageReactionRemoveAllDispatchData = MessageReactionRemoveData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#message-reaction-remove-emoji + */ +export type GatewayMessageReactionRemoveEmojiDispatch = DataPayload< + GatewayDispatchEvents.MessageReactionRemoveEmoji, + GatewayMessageReactionRemoveEmojiDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#message-reaction-remove-emoji + */ +export interface GatewayMessageReactionRemoveEmojiDispatchData extends MessageReactionRemoveData { + /** + * The emoji that was removed + */ + emoji: APIEmoji; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#presence-update + */ +export type GatewayPresenceUpdateDispatch = DataPayload< + GatewayDispatchEvents.PresenceUpdate, + GatewayPresenceUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#presence-update + */ +export type GatewayPresenceUpdateDispatchData = RawGatewayPresenceUpdate; + +/** + * https://discord.com/developers/docs/topics/gateway-events#stage-instance-create + */ +export type GatewayStageInstanceCreateDispatch = DataPayload< + GatewayDispatchEvents.StageInstanceCreate, + GatewayStageInstanceCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#stage-instance-create + */ +export type GatewayStageInstanceCreateDispatchData = APIStageInstance; + +/** + * https://discord.com/developers/docs/topics/gateway-events#stage-instance-delete + */ +export type GatewayStageInstanceDeleteDispatch = DataPayload< + GatewayDispatchEvents.StageInstanceDelete, + GatewayStageInstanceDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#stage-instance-delete + */ +export type GatewayStageInstanceDeleteDispatchData = APIStageInstance; + +/** + * https://discord.com/developers/docs/topics/gateway-events#stage-instance-update + */ +export type GatewayStageInstanceUpdateDispatch = DataPayload< + GatewayDispatchEvents.StageInstanceUpdate, + GatewayStageInstanceUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#stage-instance-update + */ +export type GatewayStageInstanceUpdateDispatchData = APIStageInstance; + +/** + * https://discord.com/developers/docs/topics/gateway-events#thread-list-sync + */ +export type GatewayThreadListSyncDispatch = DataPayload< + GatewayDispatchEvents.ThreadListSync, + GatewayThreadListSyncDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#thread-list-sync + */ +export type GatewayThreadListSyncDispatchData = RawGatewayThreadListSync; + +/** + * https://discord.com/developers/docs/topics/gateway-events#thread-members-update + */ +export type GatewayThreadMembersUpdateDispatch = DataPayload< + GatewayDispatchEvents.ThreadMembersUpdate, + GatewayThreadMembersUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#thread-members-update + */ +export type GatewayThreadMembersUpdateDispatchData = RawGatewayThreadMembersUpdate; + +/** + * https://discord.com/developers/docs/topics/gateway-events#thread-member-update + */ +export type GatewayThreadMemberUpdateDispatch = DataPayload< + GatewayDispatchEvents.ThreadMemberUpdate, + GatewayThreadMemberUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#thread-member-update + */ +export type GatewayThreadMemberUpdateDispatchData = APIThreadMember & { guild_id: Snowflake }; + +/** + * @deprecated This type doesn't accurately reflect the Discord API. + * Use {@apilink GatewayThreadCreateDispatch}, + * {@apilink GatewayThreadUpdateDispatch}, or + * {@apilink GatewayThreadDeleteDispatch} instead. + * https://discord.com/developers/docs/topics/gateway-events#thread-create + * https://discord.com/developers/docs/topics/gateway-events#thread-update + * https://discord.com/developers/docs/topics/gateway-events#thread-delete + */ +export type GatewayThreadModifyDispatch = DataPayload< + GatewayDispatchEvents.ThreadCreate | GatewayDispatchEvents.ThreadDelete | GatewayDispatchEvents.ThreadUpdate, + GatewayChannelModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#thread-create + */ +export type GatewayThreadCreateDispatch = DataPayload< + GatewayDispatchEvents.ThreadCreate, + GatewayThreadCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#thread-update + */ +export type GatewayThreadUpdateDispatch = DataPayload< + GatewayDispatchEvents.ThreadUpdate, + GatewayThreadUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#thread-update + */ +export type GatewayThreadUpdateDispatchData = APIThreadChannel; + +/** + * https://discord.com/developers/docs/topics/gateway-events#thread-delete + */ +export type GatewayThreadDeleteDispatch = DataPayload< + GatewayDispatchEvents.ThreadDelete, + GatewayThreadDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#thread-delete + */ +export interface GatewayThreadDeleteDispatchData { + /** + * The id of the channel + */ + id: Snowflake; + /** + * The id of the guild + */ + guild_id: Snowflake; + /** + * The id of the parent channel of the thread + */ + parent_id: Snowflake; + /** + * The type of the channel + * + * See https://discord.com/developers/docs/resources/channel#channel-object-channel-types + */ + type: ChannelType; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#typing-start + */ +export type GatewayTypingStartDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#user-update + */ +export type GatewayUserUpdateDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway-events#user-update + */ +export type GatewayUserUpdateDispatchData = APIUser; + +/** + * https://discord.com/developers/docs/topics/gateway-events#voice-state-update + */ +export type GatewayVoiceStateUpdateDispatch = DataPayload< + GatewayDispatchEvents.VoiceStateUpdate, + GatewayVoiceStateUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#voice-state-update + */ +export type GatewayVoiceStateUpdateDispatchData = GatewayVoiceState; + +/** + * https://discord.com/developers/docs/topics/gateway-events#voice-server-update + */ +export type GatewayVoiceServerUpdateDispatch = DataPayload< + GatewayDispatchEvents.VoiceServerUpdate, + GatewayVoiceServerUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#webhooks-update + */ +export type GatewayWebhooksUpdateDispatch = DataPayload< + GatewayDispatchEvents.WebhooksUpdate, + GatewayWebhooksUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#webhooks-update + */ +export interface GatewayWebhooksUpdateDispatchData { + /** + * The id of the guild + */ + guild_id: Snowflake; + /** + * The id of the channel + */ + channel_id: Snowflake; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-audit-log-entry-create + */ +export type GatewayGuildAuditLogEntryCreateDispatch = DataPayload< + GatewayDispatchEvents.GuildAuditLogEntryCreate, + GatewayGuildAuditLogEntryCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-audit-log-entry-create + */ +export interface GatewayGuildAuditLogEntryCreateDispatchData extends APIAuditLogEntry { + /** + * ID of the guild + */ + guild_id: Snowflake; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#message-poll-vote-add + */ +export type GatewayMessagePollVoteAddDispatch = DataPayload< + GatewayDispatchEvents.MessagePollVoteAdd, + GatewayMessagePollVoteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#message-poll-vote-remove + */ +export type GatewayMessagePollVoteRemoveDispatch = DataPayload< + GatewayDispatchEvents.MessagePollVoteRemove, + GatewayMessagePollVoteDispatchData +>; + +export interface GatewayMessagePollVoteDispatchData { + /** + * ID of the user + */ + user_id: Snowflake; + /** + * ID of the channel + */ + channel_id: Snowflake; + /** + * ID of the message + */ + message_id: Snowflake; + /** + * ID of the guild + */ + guild_id?: Snowflake; + /** + * ID of the answer + */ + answer_id: number; +} + +// #endregion Dispatch Payloads + +// #region Sendable Payloads + +/** + * https://discord.com/developers/docs/topics/gateway#sending-heartbeats + */ +export interface GatewayHeartbeat { + op: GatewayOpcodes.Heartbeat; + d: GatewayHeartbeatData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#sending-heartbeats + */ +export type GatewayHeartbeatData = number | null; + +/** + * https://discord.com/developers/docs/topics/gateway-events#identify + */ +export interface GatewayIdentify { + op: GatewayOpcodes.Identify; + d: GatewayIdentifyData; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#identify + */ +export interface GatewayIdentifyData { + /** + * Authentication token + */ + token: string; + /** + * Connection properties + * + * See https://discord.com/developers/docs/topics/gateway-events#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-events#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-events#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-events#resume + */ +export interface GatewayResume { + op: GatewayOpcodes.Resume; + d: GatewayResumeData; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#request-guild-members + */ +export interface GatewayRequestGuildMembers { + op: GatewayOpcodes.RequestGuildMembers; + d: GatewayRequestGuildMembersData; +} + +export interface GatewayRequestGuildMembersDataBase { + /** + * ID of the guild to get members for + */ + guild_id: Snowflake; + /** + * Used to specify if we want the presences of the matched members + */ + presences?: boolean; + /** + * 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-events#guild-members-chunk + */ + nonce?: string; +} + +export interface GatewayRequestGuildMembersDataWithUserIds extends GatewayRequestGuildMembersDataBase { + /** + * Used to specify which users you wish to fetch + */ + user_ids: Snowflake | Snowflake[]; +} + +export interface GatewayRequestGuildMembersDataWithQuery extends GatewayRequestGuildMembersDataBase { + /** + * 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; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#request-guild-members + */ +export type GatewayRequestGuildMembersData = + | GatewayRequestGuildMembersDataWithQuery + | GatewayRequestGuildMembersDataWithUserIds; + +/** + * https://discord.com/developers/docs/topics/gateway-events#update-voice-state + */ +export interface GatewayVoiceStateUpdate { + op: GatewayOpcodes.VoiceStateUpdate; + d: GatewayVoiceStateUpdateData; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#update-presence + */ +export interface GatewayUpdatePresence { + op: GatewayOpcodes.PresenceUpdate; + d: GatewayPresenceUpdateData; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#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-events#activity-object + */ + activities: GatewayActivityUpdateData[]; + /** + * The user's new status + * + * See https://discord.com/developers/docs/topics/gateway-events#update-presence-status-types + */ + status: PresenceUpdateStatus; + /** + * Whether or not the client is afk + */ + afk: boolean; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#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; + /** + * The id of the user that posted the message that was reacted to + */ + message_author_id?: Snowflake; + /** + * True if this is a super-reaction + */ + burst: boolean; + /** + * Colors used for super-reaction animation in "#rrggbb" format + */ + burst_colors: string[]; + /** + * The type of reaction + */ + type: ReactionType; + }, + 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/src/types/index.ts b/src/types/index.ts index c2ae89b..3a4621e 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1 +1,17 @@ -export * from 'discord-api-types/v10'; +export * from './gateway'; +export * from './rest'; +export * from './payloads'; +export * from './rest'; +export * from './utils'; + +/** + * https://discord.com/developers/docs/reference#snowflakes + */ +export type Snowflake = string; + +/** + * https://discord.com/developers/docs/topics/permissions + * + * @internal + */ +export type Permissions = string; diff --git a/src/types/payloads/_interactions/_applicationCommands/_chatInput/attachment.ts b/src/types/payloads/_interactions/_applicationCommands/_chatInput/attachment.ts new file mode 100644 index 0000000..9857f6e --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/_chatInput/attachment.ts @@ -0,0 +1,11 @@ +import type { Snowflake } from '../../../../index'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandAttachmentOption = + APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataAttachmentOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Attachment, + Snowflake +>; diff --git a/src/types/payloads/_interactions/_applicationCommands/_chatInput/base.ts b/src/types/payloads/_interactions/_applicationCommands/_chatInput/base.ts new file mode 100644 index 0000000..c14e598 --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/_chatInput/base.ts @@ -0,0 +1,30 @@ +import type { LocalizationMap } from '../../../../index'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +export interface APIApplicationCommandOptionBase { + type: Type; + name: string; + name_localizations?: LocalizationMap | null; + description: string; + description_localizations?: LocalizationMap | null; + required?: boolean; +} + +export interface APIInteractionDataOptionBase { + name: string; + type: T; + value: D; +} + +export type APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + Base extends APIApplicationCommandOptionBase, + ChoiceType extends APIApplicationCommandOptionChoice, +> = + | (Base & { + autocomplete: true; + choices?: []; + }) + | (Base & { + autocomplete?: false; + choices?: ChoiceType[]; + }); diff --git a/src/types/payloads/_interactions/_applicationCommands/_chatInput/boolean.ts b/src/types/payloads/_interactions/_applicationCommands/_chatInput/boolean.ts new file mode 100644 index 0000000..7a1ef71 --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/_chatInput/boolean.ts @@ -0,0 +1,9 @@ +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandBooleanOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataBooleanOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Boolean, + boolean +>; diff --git a/src/types/payloads/_interactions/_applicationCommands/_chatInput/channel.ts b/src/types/payloads/_interactions/_applicationCommands/_chatInput/channel.ts new file mode 100644 index 0000000..131aafa --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/_chatInput/channel.ts @@ -0,0 +1,14 @@ +import type { ChannelType, Snowflake } from '../../../../index'; + +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export interface APIApplicationCommandChannelOption + extends APIApplicationCommandOptionBase { + channel_types?: Exclude[]; +} + +export type APIApplicationCommandInteractionDataChannelOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Channel, + Snowflake +>; diff --git a/src/types/payloads/_interactions/_applicationCommands/_chatInput/integer.ts b/src/types/payloads/_interactions/_applicationCommands/_chatInput/integer.ts new file mode 100644 index 0000000..fa27b09 --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/_chatInput/integer.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +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 maximum value permitted. + */ + max_value?: number; +} + +export type APIApplicationCommandIntegerOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandIntegerOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataIntegerOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/src/types/payloads/_interactions/_applicationCommands/_chatInput/mentionable.ts b/src/types/payloads/_interactions/_applicationCommands/_chatInput/mentionable.ts new file mode 100644 index 0000000..7bead38 --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/_chatInput/mentionable.ts @@ -0,0 +1,11 @@ +import type { Snowflake } from '../../../../index'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandMentionableOption = + APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataMentionableOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Mentionable, + Snowflake +>; diff --git a/src/types/payloads/_interactions/_applicationCommands/_chatInput/number.ts b/src/types/payloads/_interactions/_applicationCommands/_chatInput/number.ts new file mode 100644 index 0000000..39f81b6 --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/_chatInput/number.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +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 maximum value permitted. + */ + max_value?: number; +} + +export type APIApplicationCommandNumberOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandNumberOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataNumberOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/src/types/payloads/_interactions/_applicationCommands/_chatInput/role.ts b/src/types/payloads/_interactions/_applicationCommands/_chatInput/role.ts new file mode 100644 index 0000000..d4fed46 --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/_chatInput/role.ts @@ -0,0 +1,10 @@ +import type { Snowflake } from '../../../../index'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandRoleOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataRoleOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Role, + Snowflake +>; diff --git a/src/types/payloads/_interactions/_applicationCommands/_chatInput/shared.ts b/src/types/payloads/_interactions/_applicationCommands/_chatInput/shared.ts new file mode 100644 index 0000000..5b28eaf --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/_chatInput/shared.ts @@ -0,0 +1,27 @@ +import type { LocalizationMap } from '../../..'; + +/** + * 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; + name_localizations?: LocalizationMap | null; + value: ValueType; +} diff --git a/src/types/payloads/_interactions/_applicationCommands/_chatInput/string.ts b/src/types/payloads/_interactions/_applicationCommands/_chatInput/string.ts new file mode 100644 index 0000000..ba62df0 --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/_chatInput/string.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +interface APIApplicationCommandStringOptionBase + extends APIApplicationCommandOptionBase { + /** + * For option type `STRING`, the minimum allowed length (minimum of `0`, maximum of `6000`). + */ + min_length?: number; + /** + * For option type `STRING`, the maximum allowed length (minimum of `1`, maximum of `6000`). + */ + max_length?: number; +} + +export type APIApplicationCommandStringOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandStringOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataStringOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/src/types/payloads/_interactions/_applicationCommands/_chatInput/subcommand.ts b/src/types/payloads/_interactions/_applicationCommands/_chatInput/subcommand.ts new file mode 100644 index 0000000..1b4b948 --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/_chatInput/subcommand.ts @@ -0,0 +1,14 @@ +import type { APIApplicationCommandBasicOption, APIApplicationCommandInteractionDataBasicOption } from '../chatInput'; +import type { APIApplicationCommandOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export interface APIApplicationCommandSubcommandOption + extends APIApplicationCommandOptionBase { + options?: APIApplicationCommandBasicOption[]; +} + +export interface APIApplicationCommandInteractionDataSubcommandOption { + name: string; + type: ApplicationCommandOptionType.Subcommand; + options?: APIApplicationCommandInteractionDataBasicOption[]; +} diff --git a/src/types/payloads/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts b/src/types/payloads/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts new file mode 100644 index 0000000..c575257 --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts @@ -0,0 +1,17 @@ +import type { APIApplicationCommandOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; +import type { + APIApplicationCommandInteractionDataSubcommandOption, + APIApplicationCommandSubcommandOption, +} from './subcommand'; + +export interface APIApplicationCommandSubcommandGroupOption + extends APIApplicationCommandOptionBase { + options?: APIApplicationCommandSubcommandOption[]; +} + +export interface APIApplicationCommandInteractionDataSubcommandGroupOption { + name: string; + type: ApplicationCommandOptionType.SubcommandGroup; + options: APIApplicationCommandInteractionDataSubcommandOption[]; +} diff --git a/src/types/payloads/_interactions/_applicationCommands/_chatInput/user.ts b/src/types/payloads/_interactions/_applicationCommands/_chatInput/user.ts new file mode 100644 index 0000000..af48cc4 --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/_chatInput/user.ts @@ -0,0 +1,10 @@ +import type { Snowflake } from '../../../..'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandUserOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataUserOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.User, + Snowflake +>; diff --git a/src/types/payloads/_interactions/_applicationCommands/chatInput.ts b/src/types/payloads/_interactions/_applicationCommands/chatInput.ts new file mode 100644 index 0000000..eaa604a --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/chatInput.ts @@ -0,0 +1,130 @@ +import type { APIInteractionDataResolved } from '../../index'; +import type { APIApplicationCommandInteractionWrapper, ApplicationCommandType } from '../applicationCommands'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base'; +import type { + APIApplicationCommandAttachmentOption, + APIApplicationCommandInteractionDataAttachmentOption, +} from './_chatInput/attachment'; +import type { + APIApplicationCommandBooleanOption, + APIApplicationCommandInteractionDataBooleanOption, +} from './_chatInput/boolean'; +import type { + APIApplicationCommandChannelOption, + APIApplicationCommandInteractionDataChannelOption, +} from './_chatInput/channel'; +import type { + APIApplicationCommandIntegerOption, + APIApplicationCommandInteractionDataIntegerOption, +} from './_chatInput/integer'; +import type { + APIApplicationCommandInteractionDataMentionableOption, + APIApplicationCommandMentionableOption, +} from './_chatInput/mentionable'; +import type { + APIApplicationCommandInteractionDataNumberOption, + APIApplicationCommandNumberOption, +} from './_chatInput/number'; +import type { + APIApplicationCommandInteractionDataRoleOption, + APIApplicationCommandRoleOption, +} from './_chatInput/role'; +import type { + APIApplicationCommandInteractionDataStringOption, + APIApplicationCommandStringOption, +} from './_chatInput/string'; +import type { + APIApplicationCommandInteractionDataSubcommandOption, + APIApplicationCommandSubcommandOption, +} from './_chatInput/subcommand'; +import type { + APIApplicationCommandInteractionDataSubcommandGroupOption, + APIApplicationCommandSubcommandGroupOption, +} from './_chatInput/subcommandGroup'; +import type { + APIApplicationCommandInteractionDataUserOption, + APIApplicationCommandUserOption, +} from './_chatInput/user'; +import type { APIBaseApplicationCommandInteractionData } from './internals'; + +export * from './_chatInput/attachment'; +export * from './_chatInput/base'; +export * from './_chatInput/boolean'; +export * from './_chatInput/channel'; +export * from './_chatInput/integer'; +export * from './_chatInput/mentionable'; +export * from './_chatInput/number'; +export * from './_chatInput/role'; +export * from './_chatInput/shared'; +export * from './_chatInput/string'; +export * from './_chatInput/subcommand'; +export * from './_chatInput/subcommandGroup'; +export * from './_chatInput/user'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure + */ +export type APIApplicationCommandBasicOption = + | APIApplicationCommandAttachmentOption + | APIApplicationCommandBooleanOption + | APIApplicationCommandChannelOption + | APIApplicationCommandIntegerOption + | APIApplicationCommandMentionableOption + | APIApplicationCommandNumberOption + | APIApplicationCommandRoleOption + | APIApplicationCommandStringOption + | APIApplicationCommandUserOption; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure + */ +export type APIApplicationCommandOption = + | APIApplicationCommandBasicOption + | APIApplicationCommandSubcommandGroupOption + | APIApplicationCommandSubcommandOption; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-interaction-data-option-structure + */ +export type APIApplicationCommandInteractionDataOption = + | APIApplicationCommandInteractionDataBasicOption + | APIApplicationCommandInteractionDataSubcommandGroupOption + | APIApplicationCommandInteractionDataSubcommandOption; + +export type APIApplicationCommandInteractionDataBasicOption = + | APIApplicationCommandInteractionDataAttachmentOption + | APIApplicationCommandInteractionDataBooleanOption + | APIApplicationCommandInteractionDataChannelOption + | APIApplicationCommandInteractionDataIntegerOption + | APIApplicationCommandInteractionDataMentionableOption + | APIApplicationCommandInteractionDataNumberOption + | APIApplicationCommandInteractionDataRoleOption + | APIApplicationCommandInteractionDataStringOption + | APIApplicationCommandInteractionDataUserOption; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data + */ +export interface APIChatInputApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + options?: APIApplicationCommandInteractionDataOption[]; + resolved?: APIInteractionDataResolved; +} + +/** + * 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/src/types/payloads/_interactions/_applicationCommands/contextMenu.ts b/src/types/payloads/_interactions/_applicationCommands/contextMenu.ts new file mode 100644 index 0000000..52b216f --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/contextMenu.ts @@ -0,0 +1,91 @@ +import type { Snowflake } from '../../../index'; +import type { APIMessage } from '../../channel'; +import type { APIApplicationCommandInteractionWrapper, ApplicationCommandType } from '../applicationCommands'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper, APIUserInteractionDataResolved } from '../base'; +import type { APIBaseApplicationCommandInteractionData } from './internals'; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data + */ +export interface APIUserApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + target_id: Snowflake; + resolved: APIUserInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data + */ +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 + */ +export type APIContextMenuInteractionData = + | APIMessageApplicationCommandInteractionData + | APIUserApplicationCommandInteractionData; + +/** + * 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 = APIMessageApplicationCommandInteraction | APIUserApplicationCommandInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuDMInteraction = + | APIMessageApplicationCommandDMInteraction + | APIUserApplicationCommandDMInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuGuildInteraction = + | APIMessageApplicationCommandGuildInteraction + | APIUserApplicationCommandGuildInteraction; diff --git a/src/types/payloads/_interactions/_applicationCommands/internals.ts b/src/types/payloads/_interactions/_applicationCommands/internals.ts new file mode 100644 index 0000000..fd01a4d --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/internals.ts @@ -0,0 +1,9 @@ +import type { Snowflake } from '../../../index'; +import type { ApplicationCommandType } from '../applicationCommands'; + +export interface APIBaseApplicationCommandInteractionData { + id: Snowflake; + type: Type; + name: string; + guild_id?: Snowflake; +} diff --git a/src/types/payloads/_interactions/_applicationCommands/permissions.ts b/src/types/payloads/_interactions/_applicationCommands/permissions.ts new file mode 100644 index 0000000..eac4d58 --- /dev/null +++ b/src/types/payloads/_interactions/_applicationCommands/permissions.ts @@ -0,0 +1,59 @@ +import type { Snowflake } from '../../../index'; + +/** + * 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 or the application id if that permission applies to all commands + */ + 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, user or channel. Can also be a permission constant + */ + id: Snowflake; + /** + * Role, user or channel + */ + 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, + Channel, +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-constants + */ +export const APIApplicationCommandPermissionsConstant = { + // eslint-disable-next-line unicorn/prefer-native-coercion-functions + Everyone: (guildId: bigint | string): Snowflake => String(guildId), + AllChannels: (guildId: bigint | string): Snowflake => String(BigInt(guildId) - 1n), +}; diff --git a/src/types/payloads/_interactions/applicationCommands.ts b/src/types/payloads/_interactions/applicationCommands.ts new file mode 100644 index 0000000..3fdcb5c --- /dev/null +++ b/src/types/payloads/_interactions/applicationCommands.ts @@ -0,0 +1,187 @@ +import type { LocalizationMap, Permissions, Snowflake } from '../..'; +import type { + APIApplicationCommandOption, + APIChatInputApplicationCommandDMInteraction, + APIChatInputApplicationCommandGuildInteraction, + APIChatInputApplicationCommandInteraction, + APIChatInputApplicationCommandInteractionData, +} from './_applicationCommands/chatInput'; +import type { + APIContextMenuDMInteraction, + APIContextMenuGuildInteraction, + APIContextMenuInteraction, + APIContextMenuInteractionData, +} from './_applicationCommands/contextMenu'; +import type { APIBaseInteraction } from './base'; +import type { InteractionType } from './responses'; + +export * from './_applicationCommands/chatInput'; +export * from './_applicationCommands/contextMenu'; +export * from './_applicationCommands/permissions'; + +/** + * 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 `^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$` + */ + name: string; + /** + * Localization dictionary for the name field. Values follow the same restrictions as name + */ + name_localizations?: LocalizationMap | null; + /** + * The localized name + */ + name_localized?: string; + /** + * 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands + */ + description: string; + /** + * Localization dictionary for the description field. Values follow the same restrictions as description + */ + description_localizations?: LocalizationMap | null; + /** + * The localized description + */ + description_localized?: string; + /** + * The parameters for the `CHAT_INPUT` command, max 25 + */ + options?: APIApplicationCommandOption[]; + /** + * Set of permissions represented as a bitset + */ + default_member_permissions: Permissions | null; + /** + * Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible + * + * @deprecated Use `contexts` instead + */ + dm_permission?: boolean; + /** + * Whether the command is enabled by default when the app is added to a guild + * + * If missing, this property should be assumed as `true` + * + * @deprecated Use `dm_permission` and/or `default_member_permissions` instead + */ + default_permission?: boolean; + /** + * Indicates whether the command is age-restricted, defaults to `false` + */ + nsfw?: boolean; + /** + * Installation context(s) where the command is available, only for globally-scoped commands. Defaults to `GUILD_INSTALL ([0])` + * + * @unstable + */ + integration_types?: ApplicationIntegrationType[]; + /** + * Interaction context(s) where the command can be used, only for globally-scoped commands. By default, all interaction context types included for new commands `[0,1,2]`. + * + * @unstable + */ + contexts?: InteractionContextType[] | null; + /** + * 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/resources/application#application-object-application-integration-types + */ +export enum ApplicationIntegrationType { + /** + * App is installable to servers + */ + GuildInstall = 0, + /** + * App is installable to users + */ + UserInstall = 1, +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-context-types + */ +export enum InteractionContextType { + /** + * Interaction can be used within servers + */ + Guild = 0, + /** + * Interaction can be used within DMs with the app's bot user + */ + BotDM = 1, + /** + * Interaction can be used within Group DMs and DMs other than the app's bot user + */ + PrivateChannel = 2, +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data + */ +export type APIApplicationCommandInteractionData = + | APIChatInputApplicationCommandInteractionData + | APIContextMenuInteractionData; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandInteractionWrapper = + APIBaseInteraction & + Required< + Pick< + APIBaseInteraction, + 'app_permissions' | 'channel_id' | 'channel' | '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/src/types/payloads/_interactions/autocomplete.ts b/src/types/payloads/_interactions/autocomplete.ts new file mode 100644 index 0000000..0c54b7d --- /dev/null +++ b/src/types/payloads/_interactions/autocomplete.ts @@ -0,0 +1,33 @@ +import type { + APIBaseInteraction, + APIChatInputApplicationCommandInteractionData, + APIDMInteractionWrapper, + APIGuildInteractionWrapper, + InteractionType, +} from '../index'; + +export type APIApplicationCommandAutocompleteInteraction = APIBaseInteraction< + InteractionType.ApplicationCommandAutocomplete, + APIChatInputApplicationCommandInteractionData +> & + Required< + Pick< + APIBaseInteraction< + InteractionType.ApplicationCommandAutocomplete, + Required> + >, + '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/src/types/payloads/_interactions/base.ts b/src/types/payloads/_interactions/base.ts new file mode 100644 index 0000000..19692a0 --- /dev/null +++ b/src/types/payloads/_interactions/base.ts @@ -0,0 +1,245 @@ +import type { InteractionContextType, ApplicationIntegrationType } from '..'; +import type { ChannelType, Snowflake } from '../..'; + +import type { LocaleString } from '../../rest'; +import type { + APIAttachment, + APIChannel, + APIMessage, + APIPartialChannel, + APIThreadChannel, + ThreadChannelType, +} from '../channel'; +import type { APIGuildMember } from '../guild'; +import type { APIEntitlement } from '../monetization'; +import type { APIRole } from '../permissions'; +import type { APIUser } from '../user'; +import type { InteractionType } from './responses'; + +/** + * https://discord.com/developers/docs/resources/channel#message-interaction-metadata-object + */ +export interface APIMessageInteractionMetadata { + /** + * ID of the interaction + */ + id: Snowflake; + /** + * Type of interaction + */ + type: InteractionType; + /** + * User who triggered the interaction + */ + user: APIUser; + /** + * IDs for installation context(s) related to an interaction. Details in Authorizing Integration Owners Object + */ + authorizing_integration_owners: APIAuthorizingIntegrationOwnersMap; + /** + * ID of the original response message, present only on follow-up messages + */ + original_response_message_id?: Snowflake; + /** + * ID of the message that contained interactive component, present only on messages created from component interactions + */ + interacted_message_id?: Snowflake; + /** + * Metadata for the interaction that was used to open the modal, present only on modal submit interactions + */ + triggering_interaction_metadata?: APIMessageInteractionMetadata; +} + +export type PartialAPIMessageInteractionGuildMember = Pick< + APIGuildMember, + | 'avatar' + | 'communication_disabled_until' + | 'deaf' + | 'joined_at' + | 'mute' + | 'nick' + | 'pending' + | 'premium_since' + | 'roles' +>; + +/** + * 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 application command, including subcommands and subcommand groups + */ + 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?: Partial & Pick; + /** + * The id of the channel it was sent from + * + * @deprecated Use {@apilink APIBaseInteraction#channel} instead + */ + 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; + /** + * Bitwise set of permissions the app or bot has within the channel the interaction was sent from + */ + app_permissions: Permissions; + /** + * The selected language of the invoking user + */ + locale: LocaleString; + /** + * The guild's preferred locale, if invoked in a guild + */ + guild_locale?: LocaleString; + /** + * For monetized apps, any entitlements for the invoking user, representing access to premium SKUs + */ + entitlements: APIEntitlement[]; + /** + * Mapping of installation contexts that the interaction was authorized for to related user or guild IDs. + */ + authorizing_integration_owners: APIAuthorizingIntegrationOwnersMap; + /** + * Context where the interaction was triggered from + */ + context?: InteractionContextType; +} + +export type APIAuthorizingIntegrationOwnersMap = { + [key in ApplicationIntegrationType]?: Snowflake; +}; + +export type APIDMInteractionWrapper> = Omit< + Original, + 'guild_id' | 'member' +> & + Required>; + +export type APIGuildInteractionWrapper> = Omit< + Original, + 'user' +> & + Required>; + +export interface APIInteractionDataResolvedChannelBase extends Required { + type: T; + permissions: Permissions; +} + +/** + * https://discord.com/developers/docs/resources/channel#channel-object + */ +export type APIInteractionDataResolvedChannel = + | APIInteractionDataResolvedChannelBase> + | (APIInteractionDataResolvedChannelBase & + Pick); + +/** + * 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-resolved-data-structure + */ +export interface APIInteractionDataResolved { + users?: Record; + roles?: Record; + members?: Record; + channels?: Record; + attachments?: Record; +} + +/** + * @deprecated Renamed to `APIInteractionDataResolved` + */ +export type APIChatInputApplicationCommandInteractionDataResolved = APIInteractionDataResolved; + +/** + * `users` and optional `members` from APIInteractionDataResolved, for user commands and user selects + */ +export type APIUserInteractionDataResolved = Pick & + Required>; + +/** + * @deprecated Renamed to `APIUserInteractionDataResolved` + */ +export type APIUserApplicationCommandInteractionDataResolved = APIUserInteractionDataResolved; diff --git a/src/types/payloads/_interactions/messageComponents.ts b/src/types/payloads/_interactions/messageComponents.ts new file mode 100644 index 0000000..5221198 --- /dev/null +++ b/src/types/payloads/_interactions/messageComponents.ts @@ -0,0 +1,97 @@ +import type { Snowflake } from '../../index'; +import type { ComponentType } from '../channel'; +import type { APIBaseInteraction, InteractionType } from '../interactions'; +import type { + APIDMInteractionWrapper, + APIGuildInteractionWrapper, + APIInteractionDataResolved, + APIUserInteractionDataResolved, +} from './base'; + +export type APIMessageComponentInteraction = APIBaseInteraction< + InteractionType.MessageComponent, + APIMessageComponentInteractionData +> & + Required< + Pick< + APIBaseInteraction, + 'app_permissions' | 'channel_id' | 'channel' | 'data' | 'message' + > + >; + +export type APIMessageComponentButtonInteraction = APIBaseInteraction< + InteractionType.MessageComponent, + APIMessageButtonInteractionData +> & + Required< + Pick< + APIBaseInteraction, + 'app_permissions' | 'channel_id' | 'channel' | 'data' | 'message' + > + >; + +export type APIMessageComponentSelectMenuInteraction = APIBaseInteraction< + InteractionType.MessageComponent, + APIMessageSelectMenuInteractionData +> & + Required< + Pick< + APIBaseInteraction, + 'app_permissions' | 'channel_id' | 'channel' | '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 APIMessageStringSelectInteractionData + extends APIMessageComponentBaseInteractionData { + values: string[]; +} + +export interface APIMessageUserSelectInteractionData + extends APIMessageComponentBaseInteractionData { + values: Snowflake[]; + resolved: APIUserInteractionDataResolved; +} + +export interface APIMessageRoleSelectInteractionData + extends APIMessageComponentBaseInteractionData { + values: Snowflake[]; + resolved: Required>; +} + +export interface APIMessageMentionableSelectInteractionData + extends APIMessageComponentBaseInteractionData { + values: Snowflake[]; + resolved: Pick; +} + +export interface APIMessageChannelSelectInteractionData + extends APIMessageComponentBaseInteractionData { + values: Snowflake[]; + resolved: Required>; +} + +export type APIMessageSelectMenuInteractionData = + | APIMessageChannelSelectInteractionData + | APIMessageMentionableSelectInteractionData + | APIMessageRoleSelectInteractionData + | APIMessageStringSelectInteractionData + | APIMessageUserSelectInteractionData; + +export type APIMessageComponentDMInteraction = APIDMInteractionWrapper; + +export type APIMessageComponentGuildInteraction = APIGuildInteractionWrapper; diff --git a/src/types/payloads/_interactions/modalSubmit.ts b/src/types/payloads/_interactions/modalSubmit.ts new file mode 100644 index 0000000..5184a13 --- /dev/null +++ b/src/types/payloads/_interactions/modalSubmit.ts @@ -0,0 +1,49 @@ +import type { APIActionRowComponent, APIModalActionRowComponent } from '../channel'; +import type { + APIBaseInteraction, + APIDMInteractionWrapper, + APIGuildInteractionWrapper, + ComponentType, + InteractionType, +} from '../index'; + +export interface ModalSubmitComponent { + type: ComponentType; + custom_id: string; + value: string; +} + +export interface ModalSubmitActionRowComponent + extends Omit, 'components'> { + components: ModalSubmitComponent[]; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-modal-submit-data-structure + */ +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/src/types/payloads/_interactions/ping.ts b/src/types/payloads/_interactions/ping.ts new file mode 100644 index 0000000..06eb95a --- /dev/null +++ b/src/types/payloads/_interactions/ping.ts @@ -0,0 +1,4 @@ +import type { APIBaseInteraction } from './base'; +import type { InteractionType } from './responses'; + +export type APIPingInteraction = Omit, 'locale'>; diff --git a/src/types/payloads/_interactions/responses.ts b/src/types/payloads/_interactions/responses.ts new file mode 100644 index 0000000..0b0e55e --- /dev/null +++ b/src/types/payloads/_interactions/responses.ts @@ -0,0 +1,135 @@ +import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../index'; +import type { APIActionRowComponent, APIModalActionRowComponent } from '../channel'; +import type { MessageFlags } from '../index'; +import type { APIApplicationCommandOptionChoice } from './applicationCommands'; + +/** + * 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 = + | APIApplicationCommandAutocompleteResponse + | APIInteractionResponseChannelMessageWithSource + | APIInteractionResponseDeferredChannelMessageWithSource + | APIInteractionResponseDeferredMessageUpdate + | APIInteractionResponsePong + | APIInteractionResponseUpdateMessage + | APIModalInteractionResponse + | APIPremiumRequiredInteractionResponse; + +export interface APIInteractionResponsePong { + type: InteractionResponseType.Pong; +} + +export interface APIApplicationCommandAutocompleteResponse { + type: InteractionResponseType.ApplicationCommandAutocompleteResult; + data: APICommandAutocompleteInteractionResponseCallbackData; +} + +export interface APIModalInteractionResponse { + type: InteractionResponseType.Modal; + data: APIModalInteractionResponseCallbackData; +} + +export interface APIPremiumRequiredInteractionResponse { + type: InteractionResponseType.PremiumRequired; +} + +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, + /** + * Respond to an interaction with an upgrade button, only available for apps with monetization enabled + * + * @deprecated See https://discord.com/developers/docs/change-log#premium-apps-new-premium-button-style-deep-linking-url-schemes + */ + PremiumRequired, +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-data-structure + */ +export type APIInteractionResponseCallbackData = Omit< + RESTPostAPIWebhookWithTokenJSONBody, + 'avatar_url' | 'username' +> & { 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/src/types/payloads/application.ts b/src/types/payloads/application.ts new file mode 100644 index 0000000..7f2cee8 --- /dev/null +++ b/src/types/payloads/application.ts @@ -0,0 +1,296 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/application + */ + +import type { LocalizationMap } from '.'; +import type { Snowflake } from '..'; +import type { APIPartialGuild } from './guild'; +import type { ApplicationIntegrationType } from './interactions'; +import type { OAuth2Scopes } from './oauth2'; +import type { APITeam } from './teams'; +import type { APIUser } from './user'; + +/** + * 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; + /** + * Partial user object for the bot user associated with the application + */ + bot?: APIUser; + /** + * 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; + /** + * An empty string + * + * @deprecated This field 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#getticket + */ + 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; + /** + * A partial object of the associated guild + */ + guild?: APIPartialGuild; + /** + * 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; + /** + * Approximate count of guilds the application has been added to + */ + approximate_guild_count?: number; + /** + * Array of redirect URIs for the application + */ + redirect_uris?: string[]; + /** + * The interactions endpoint URL for the application + */ + interactions_endpoint_url?: string; + /** + * The application's role connection verification entry point, + * which when configured will render the app as a verification method in the guild role verification configuration + */ + role_connections_verification_url?: string; + /** + * Up to 5 tags of max 20 characters each describing the content and functionality of the application + */ + tags?: [string, string?, string?, string?, string?]; + /** + * Settings for the application's default in-app authorization link, if enabled + */ + install_params?: APIApplicationInstallParams; + /** + * Default scopes and permissions for each supported installation context. Value for each key is an integration type configuration object + * + * @unstable + */ + integration_types_config?: APIApplicationIntegrationTypesConfigMap; + /** + * The application's default custom authorization link, if enabled + */ + custom_install_url?: string; +} + +export interface APIApplicationInstallParams { + scopes: OAuth2Scopes[]; + permissions: Permissions; +} + +export interface APIApplicationIntegrationTypeConfiguration { + oauth2_install_params?: APIApplicationInstallParams; +} + +export type APIApplicationIntegrationTypesConfigMap = { + [key in ApplicationIntegrationType]?: APIApplicationIntegrationTypeConfiguration; +}; + +/** + * https://discord.com/developers/docs/resources/application#application-object-application-flags + */ +export enum ApplicationFlags { + /** + * @unstable This application flag is currently not documented by Discord but has a known value which we will try to keep up to date. + */ + EmbeddedReleased = 1 << 1, + /** + * @unstable This application flag is currently not documented by Discord but has a known value which we will try to keep up to date. + */ + ManagedEmoji = 1 << 2, + /** + * @unstable This application flag is currently not documented by Discord but has a known value which we will try to keep up to date. + */ + EmbeddedIAP = 1 << 3, + /** + * @unstable This application flag is currently not documented by Discord but has a known value which we will try to keep up to date. + */ + GroupDMCreate = 1 << 4, + /** + * Indicates if an app uses the Auto Moderation API + */ + ApplicationAutoModerationRuleCreateBadge = 1 << 6, + /** + * @unstable This application flag is currently not documented by Discord but has a known value which we will try to keep up to date. + */ + RPCHasConnected = 1 << 11, + /** + * Intent required for bots in 100 or more servers to receive `presence_update` events + */ + GatewayPresence = 1 << 12, + /** + * Intent required for bots in under 100 servers to receive `presence_update` events, found in Bot Settings + */ + GatewayPresenceLimited = 1 << 13, + /** + * Intent required for bots in 100 or more servers to receive member-related events like `guild_member_add`. + * See list of member-related events [under `GUILD_MEMBERS`](https://discord.com/developers/docs/topics/gateway#list-of-intents) + */ + GatewayGuildMembers = 1 << 14, + /** + * Intent required for bots in under 100 servers to receive member-related events like `guild_member_add`, found in Bot Settings. + * See list of member-related events [under `GUILD_MEMBERS`](https://discord.com/developers/docs/topics/gateway#list-of-intents) + */ + GatewayGuildMembersLimited = 1 << 15, + /** + * Indicates unusual growth of an app that prevents verification + */ + VerificationPendingGuildLimit = 1 << 16, + /** + * Indicates if an app is embedded within the Discord client (currently unavailable publicly) + */ + Embedded = 1 << 17, + /** + * Intent required for bots in 100 or more servers to receive [message content](https://support-dev.discord.com/hc/en-us/articles/4404772028055) + */ + GatewayMessageContent = 1 << 18, + /** + * Intent required for bots in under 100 servers to receive [message content](https://support-dev.discord.com/hc/en-us/articles/4404772028055), + * found in Bot Settings + */ + GatewayMessageContentLimited = 1 << 19, + /** + * @unstable This application flag is currently not documented by Discord but has a known value which we will try to keep up to date. + */ + EmbeddedFirstParty = 1 << 20, + /** + * Indicates if an app has registered global [application commands](https://discord.com/developers/docs/interactions/application-commands) + */ + ApplicationCommandBadge = 1 << 23, +} + +/** + * https://discord.com/developers/docs/resources/application-role-connection-metadata#application-role-connection-metadata-object-application-role-connection-metadata-structure + */ +export interface APIApplicationRoleConnectionMetadata { + /** + * Type of metadata value + */ + type: ApplicationRoleConnectionMetadataType; + /** + * Dictionary key for the metadata field (must be `a-z`, `0-9`, or `_` characters; 1-50 characters) + */ + key: string; + /** + * Name of the metadata field (1-100 characters) + */ + name: string; + /** + * Translations of the name + */ + name_localizations?: LocalizationMap; + /** + * Description of the metadata field (1-200 characters) + */ + description: string; + /** + * Translations of the description + */ + description_localizations?: LocalizationMap; +} + +/** + * https://discord.com/developers/docs/resources/application-role-connection-metadata#application-role-connection-metadata-object-application-role-connection-metadata-type + */ +export enum ApplicationRoleConnectionMetadataType { + /** + * The metadata value (`integer`) is less than or equal to the guild's configured value (`integer`) + */ + IntegerLessThanOrEqual = 1, + /** + * The metadata value (`integer`) is greater than or equal to the guild's configured value (`integer`) + */ + IntegerGreaterThanOrEqual, + /** + * The metadata value (`integer`) is equal to the guild's configured value (`integer`) + */ + IntegerEqual, + /** + * The metadata value (`integer`) is not equal to the guild's configured value (`integer`) + */ + IntegerNotEqual, + /** + * The metadata value (`ISO8601 string`) is less than or equal to the guild's configured value (`integer`; days before current date) + */ + DatetimeLessThanOrEqual, + /** + * The metadata value (`ISO8601 string`) is greater than or equal to the guild's configured value (`integer`; days before current date) + */ + DatetimeGreaterThanOrEqual, + /** + * The metadata value (`integer`) is equal to the guild's configured value (`integer`; `1`) + */ + BooleanEqual, + /** + * The metadata value (`integer`) is not equal to the guild's configured value (`integer`; `1`) + */ + BooleanNotEqual, +} diff --git a/src/types/payloads/auditLog.ts b/src/types/payloads/auditLog.ts new file mode 100644 index 0000000..f51f9f7 --- /dev/null +++ b/src/types/payloads/auditLog.ts @@ -0,0 +1,879 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/audit-log + */ + +import type { Snowflake } from '..'; +import type { + APIAutoModerationAction, + APIAutoModerationRule, + APIAutoModerationRuleTriggerMetadata, + AutoModerationRuleEventType, + AutoModerationRuleTriggerType, +} from './autoModeration'; +import type { APIChannel, APIGuildForumDefaultReactionEmoji, APIGuildForumTag, APIOverwrite } from './channel'; +import type { + APIGuildIntegration, + APIGuildIntegrationType, + GuildDefaultMessageNotifications, + GuildExplicitContentFilter, + GuildMFALevel, + GuildSystemChannelFlags, + GuildVerificationLevel, + IntegrationExpireBehavior, +} from './guild'; +import type { + APIGuildScheduledEvent, + GuildScheduledEventEntityType, + GuildScheduledEventStatus, +} from './guildScheduledEvent'; +import type { APIApplicationCommand } from './interactions'; +import type { APIRole } from './permissions'; +import type { StageInstancePrivacyLevel } from './stageInstance'; +import type { StickerFormatType } from './sticker'; +import type { APIUser } from './user'; +import type { APIWebhook } from './webhook'; + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure + */ +export interface APIAuditLog { + /** + * List of application commands found in the audit log + * + * See https://discord.com/developers/docs/interactions/application-commands#application-command-object + */ + application_commands: APIApplicationCommand[]; + /** + * 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[]; + /** + * List of auto moderation rules referenced in the audit log + * + * See https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object + */ + auto_moderation_rules: APIAutoModerationRule[]; + /** + * 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, + + ApplicationCommandPermissionUpdate = 121, + + AutoModerationRuleCreate = 140, + AutoModerationRuleUpdate, + AutoModerationRuleDelete, + AutoModerationBlockMessage, + AutoModerationFlagToChannel, + AutoModerationUserCommunicationDisabled, + + CreatorMonetizationRequestCreated = 150, + CreatorMonetizationTermsAccepted, + + OnboardingPromptCreate = 163, + OnboardingPromptUpdate, + OnboardingPromptDelete, + OnboardingCreate, + OnboardingUpdate, + + HomeSettingsCreate = 190, + HomeSettingsUpdate, +} + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info + */ +export interface APIAuditLogOptions { + /** + * Name of the Auto Moderation rule that was triggered + * + * Present from: + * - AUTO_MODERATION_BLOCK_MESSAGE + * - AUTO_MODERATION_FLAG_TO_CHANNEL + * - AUTO_MODERATION_USER_COMMUNICATION_DISABLED + */ + auto_moderation_rule_name?: string; + /** + * Trigger type of the Auto Moderation rule that was triggered + * + * Present from: + * - AUTO_MODERATION_BLOCK_MESSAGE + * - AUTO_MODERATION_FLAG_TO_CHANNEL + * - AUTO_MODERATION_USER_COMMUNICATION_DISABLED + */ + auto_moderation_rule_trigger_type?: AuditLogRuleTriggerType; + /** + * 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 + * - AUTO_MODERATION_BLOCK_MESSAGE + * - AUTO_MODERATION_FLAG_TO_CHANNEL + * - AUTO_MODERATION_USER_COMMUNICATION_DISABLED + */ + 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; + + /** + * Type of integration which performed the action + * + * Present from: + * - MEMBER_KICK + * - MEMBER_ROLE_UPDATE + */ + integration_type?: APIGuildIntegrationType; +} + +export enum AuditLogOptionsType { + Role = '0', + Member = '1', +} + +export type AuditLogRuleTriggerType = `${AutoModerationRuleTriggerType}`; + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure + */ +export type APIAuditLogChange = + | APIAuditLogChangeKey$Add + | APIAuditLogChangeKey$Remove + | APIAuditLogChangeKeyActions + | APIAuditLogChangeKeyAFKChannelId + | APIAuditLogChangeKeyAFKTimeout + | APIAuditLogChangeKeyAllow + | APIAuditLogChangeKeyApplicationId + | APIAuditLogChangeKeyArchived + | APIAuditLogChangeKeyAsset + | APIAuditLogChangeKeyAutoArchiveDuration + | APIAuditLogChangeKeyAvailable + | APIAuditLogChangeKeyAvailableTags + | APIAuditLogChangeKeyAvatarHash + | APIAuditLogChangeKeyBannerHash + | APIAuditLogChangeKeyBitrate + | APIAuditLogChangeKeyChannelId + | APIAuditLogChangeKeyCode + | APIAuditLogChangeKeyColor + | APIAuditLogChangeKeyCommunicationDisabledUntil + | APIAuditLogChangeKeyDeaf + | APIAuditLogChangeKeyDefaultAutoArchiveDuration + | APIAuditLogChangeKeyDefaultMessageNotifications + | APIAuditLogChangeKeyDefaultReactionEmoji + | APIAuditLogChangeKeyDefaultThreadRateLimitPerUser + | APIAuditLogChangeKeyDeny + | APIAuditLogChangeKeyDescription + | APIAuditLogChangeKeyDiscoverySplashHash + | APIAuditLogChangeKeyEnabled + | APIAuditLogChangeKeyEnableEmoticons + | APIAuditLogChangeKeyEntityType + | APIAuditLogChangeKeyEventType + | APIAuditLogChangeKeyExemptChannels + | APIAuditLogChangeKeyExemptRoles + | APIAuditLogChangeKeyExpireBehavior + | APIAuditLogChangeKeyExpireGracePeriod + | APIAuditLogChangeKeyExplicitContentFilter + | APIAuditLogChangeKeyFlags + | APIAuditLogChangeKeyFormatType + | APIAuditLogChangeKeyGuildId + | APIAuditLogChangeKeyHoist + | APIAuditLogChangeKeyIconHash + | APIAuditLogChangeKeyId + | APIAuditLogChangeKeyImageHash + | APIAuditLogChangeKeyInviterId + | APIAuditLogChangeKeyLocation + | APIAuditLogChangeKeyLocked + | APIAuditLogChangeKeyMaxAge + | APIAuditLogChangeKeyMaxUses + | APIAuditLogChangeKeyMentionable + | APIAuditLogChangeKeyMFALevel + | APIAuditLogChangeKeyMute + | APIAuditLogChangeKeyName + | APIAuditLogChangeKeyNick + | APIAuditLogChangeKeyNSFW + | APIAuditLogChangeKeyOwnerId + | APIAuditLogChangeKeyPermissionOverwrites + | APIAuditLogChangeKeyPermissions + | APIAuditLogChangeKeyPosition + | APIAuditLogChangeKeyPreferredLocale + | APIAuditLogChangeKeyPrivacyLevel + | APIAuditLogChangeKeyPruneDeleteDays + | APIAuditLogChangeKeyPublicUpdatesChannelId + | APIAuditLogChangeKeyRateLimitPerUser + | APIAuditLogChangeKeyRegion + | APIAuditLogChangeKeyRulesChannelId + | APIAuditLogChangeKeySplashHash + | APIAuditLogChangeKeyStatus + | APIAuditLogChangeKeySystemChannelFlags + | APIAuditLogChangeKeySystemChannelId + | APIAuditLogChangeKeyTags + | APIAuditLogChangeKeyTemporary + | APIAuditLogChangeKeyTopic + | APIAuditLogChangeKeyTriggerMetadata + | APIAuditLogChangeKeyTriggerType + | APIAuditLogChangeKeyType + | APIAuditLogChangeKeyUserLimit + | APIAuditLogChangeKeyUses + | APIAuditLogChangeKeyVanityURLCode + | APIAuditLogChangeKeyVerificationLevel + | APIAuditLogChangeKeyWidgetChannelId + | APIAuditLogChangeKeyWidgetEnabled; + +/** + * 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 scheduled event's cover image is changed + */ +export type APIAuditLogChangeKeyImageHash = AuditLogChangeData<'image_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 safety_alerts_channel_id is changed + */ +export type APIAuditLogChangeKeySafetyAlertsChannelId = AuditLogChangeData<'safety_alerts_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', Pick[]>; + +/** + * Returned when role(s) are removed + */ +export type APIAuditLogChangeKey$Remove = AuditLogChangeData<'$remove', Pick[]>; + +/** + * 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_flags is changed + */ +export type APIAuditLogChangeKeySystemChannelFlags = AuditLogChangeData< + 'system_channel_flags', + GuildSystemChannelFlags +>; + +/** + * 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>; + +/** + * Represents a change where the key is a snowflake. + * Currently, the only known instance of this is returned when permissions for a command were updated () + */ +export type APIAuditLogChangeKeySnowflake = AuditLogChangeData; + +/** + * 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>; + +/** + * Returned when an auto moderation rule's trigger type is changed (only in rule creation or deletion) + */ +export type APIAuditLogChangeKeyTriggerType = AuditLogChangeData<'trigger_type', AutoModerationRuleTriggerType>; + +/** + * Returned when an auto moderation rule's event type is changed + */ +export type APIAuditLogChangeKeyEventType = AuditLogChangeData<'event_type', AutoModerationRuleEventType>; + +/** + * Returned when an auto moderation rule's trigger metadata is changed + */ +export type APIAuditLogChangeKeyTriggerMetadata = AuditLogChangeData< + 'trigger_metadata', + APIAutoModerationRuleTriggerMetadata +>; + +/** + * Returned when an auto moderation rule's actions is changed + */ +export type APIAuditLogChangeKeyActions = AuditLogChangeData<'actions', APIAutoModerationAction[]>; + +/** + * Returned when an auto moderation rule's enabled status is changed + */ +export type APIAuditLogChangeKeyEnabled = AuditLogChangeData<'enabled', boolean>; + +/** + * Returned when an auto moderation rule's exempt roles is changed + */ +export type APIAuditLogChangeKeyExemptRoles = AuditLogChangeData<'exempt_roles', Snowflake[]>; + +/** + * Returned when an auto moderation rule's exempt channels is changed + */ +export type APIAuditLogChangeKeyExemptChannels = AuditLogChangeData<'exempt_channels', Snowflake[]>; + +/** + * Returned when a guild forum's available tags gets changed + */ +export type APIAuditLogChangeKeyAvailableTags = AuditLogChangeData<'available_tags', APIGuildForumTag[]>; + +/** + * Returned when a guild forum's default reaction emoji gets changed + */ +export type APIAuditLogChangeKeyDefaultReactionEmoji = AuditLogChangeData< + 'default_reaction_emoji', + APIGuildForumDefaultReactionEmoji +>; + +/** + * Returned when a channel flag gets changed + */ +export type APIAuditLogChangeKeyFlags = AuditLogChangeData<'flags', number>; + +/** + * Returned when a thread's amount of seconds a user has to wait before creating another thread + * gets changed + */ +export type APIAuditLogChangeKeyDefaultThreadRateLimitPerUser = AuditLogChangeData< + 'default_thread_rate_limit_per_user', + number +>; + +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/src/types/payloads/autoModeration.ts b/src/types/payloads/autoModeration.ts new file mode 100644 index 0000000..2a98ca9 --- /dev/null +++ b/src/types/payloads/autoModeration.ts @@ -0,0 +1,228 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/auto-moderation + */ + +import type { Snowflake } from '../index'; + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-auto-moderation-rule-structure + */ +export interface APIAutoModerationRule { + /** + * The id of this rule + */ + id: Snowflake; + /** + * The guild which this rule belongs to + */ + guild_id: Snowflake; + /** + * The rule name + */ + name: string; + /** + * The user id who created this rule + */ + creator_id: Snowflake; + /** + * The rule event type + */ + event_type: AutoModerationRuleEventType; + /** + * The rule trigger type + */ + trigger_type: AutoModerationRuleTriggerType; + /** + * The rule trigger metadata + */ + trigger_metadata: APIAutoModerationRuleTriggerMetadata; + /** + * The actions which will execute when this rule is triggered + */ + actions: APIAutoModerationAction[]; + /** + * Whether this rule is enabled + */ + enabled: boolean; + /** + * The role ids that shouldn't be affected by this rule (Maximum of 20) + */ + exempt_roles: Snowflake[]; + /** + * The channel ids that shouldn't be affected by this rule (Maximum of 50) + */ + exempt_channels: Snowflake[]; +} + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types + */ +export enum AutoModerationRuleTriggerType { + /** + * Check if content contains words from a user defined list of keywords (Maximum of 6 per guild) + */ + Keyword = 1, + /** + * Check if content represents generic spam (Maximum of 1 per guild) + */ + Spam = 3, + /** + * Check if content contains words from internal pre-defined wordsets (Maximum of 1 per guild) + */ + KeywordPreset, + /** + * Check if content contains more mentions than allowed (Maximum of 1 per guild) + */ + MentionSpam, + /** + * Check if member profile contains words from a user defined list of keywords (Maximum of 1 per guild) + */ + MemberProfile, +} + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata + */ +export interface APIAutoModerationRuleTriggerMetadata { + /** + * Substrings which will be searched for in content (Maximum of 1000) + * + * A keyword can be a phrase which contains multiple words. Wildcard symbols can be used to customize how each string will be matched. Each keyword must be 60 characters or less + * See [keyword matching strategies](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) + * + * Associated trigger types: {@link AutoModerationRuleTriggerType.Keyword}, {@link AutoModerationRuleTriggerType.MemberProfile} + */ + keyword_filter?: string[]; + /** + * The internally pre-defined wordsets which will be searched for in content + * + * Associated trigger type: {@link AutoModerationRuleTriggerType.KeywordPreset} + */ + presets?: AutoModerationRuleKeywordPresetType[]; + /** + * Substrings which will be exempt from triggering the preset trigger type (Maximum of 1000) + * + * A allowed-word can be a phrase which contains multiple words. Wildcard symbols can be used to customize how each string will be matched. Each keyword must be 60 characters or less + * See [keyword matching strategies](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) + * + * Associated trigger types: {@link AutoModerationRuleTriggerType.Keyword}, {@link AutoModerationRuleTriggerType.KeywordPreset}, {@link AutoModerationRuleTriggerType.MemberProfile} + */ + allow_list?: string[]; + /** + * Regular expression patterns which will be matched against content (Maximum of 10) + * + * Only Rust flavored regex is currently supported (Maximum of 260 characters) + * + * Associated trigger types: {@link AutoModerationRuleTriggerType.Keyword}, {@link AutoModerationRuleTriggerType.MemberProfile} + */ + regex_patterns?: string[]; + /** + * Total number of mentions (role & user) allowed per message (Maximum of 50) + * + * Associated trigger type: {@link AutoModerationRuleTriggerType.MentionSpam} + */ + mention_total_limit?: number; + /** + * Whether to automatically detect mention raids + * + * Associated trigger type: {@link AutoModerationRuleTriggerType.MentionSpam} + */ + mention_raid_protection_enabled?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-preset-types + */ +export enum AutoModerationRuleKeywordPresetType { + /** + * Words that may be considered forms of swearing or cursing + */ + Profanity = 1, + /** + * Words that refer to sexually explicit behavior or activity + */ + SexualContent, + /** + * Personal insults or words that may be considered hate speech + */ + Slurs, +} + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types + */ +export enum AutoModerationRuleEventType { + /** + * When a member sends or edits a message in the guild + */ + MessageSend = 1, + /** + * When a member edits their profile + */ + MemberUpdate, +} + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-auto-moderation-action-structure + */ +export interface APIAutoModerationAction { + /** + * The action type + */ + type: AutoModerationActionType; + /** + * Additional metadata needed during execution for this specific action type + * + * Will only be omitted if the action type is {@link AutoModerationActionType.BlockMessage} + */ + metadata?: APIAutoModerationActionMetadata; +} + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-action-types + */ +export enum AutoModerationActionType { + /** + * Blocks a member's message and prevents it from being posted. + * A custom explanation can be specified and shown to members whenever their message is blocked + */ + BlockMessage = 1, + /** + * Logs user content to a specified channel + */ + SendAlertMessage, + /** + * Timeout user for specified duration, this action type can be set if the bot has `MODERATE_MEMBERS` permission + */ + Timeout, + /** + * Prevents a member from using text, voice, or other interactions + */ + BlockMemberInteraction, +} + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-action-metadata + */ +export interface APIAutoModerationActionMetadata { + /** + * Channel to which user content should be logged + * + * Associated action type: {@link AutoModerationActionType.SendAlertMessage} + */ + channel_id?: Snowflake; + /** + * Timeout duration in seconds (Maximum of 4 weeks - 2419200 seconds) + * + * Only available if using {@link AutoModerationRuleTriggerType.Keyword} + * + * Associated action type: {@link AutoModerationActionType.Timeout} + */ + duration_seconds?: number; + /** + * Additional explanation that will be shown to members whenever their message is blocked (Maximum 150 characters) + * + * Associated action type {@link AutoModerationActionType.BlockMessage} + */ + custom_message?: string; +} diff --git a/src/types/payloads/channel.ts b/src/types/payloads/channel.ts new file mode 100644 index 0000000..4c39307 --- /dev/null +++ b/src/types/payloads/channel.ts @@ -0,0 +1,1830 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/channel + */ + +import type { Permissions, Snowflake, ChannelType, OverwriteType, VideoQualityMode } from '../index'; +import type { APIApplication } from './application'; +import type { APIPartialEmoji } from './emoji'; +import type { APIGuildMember } from './guild'; +import type { APIInteractionDataResolved, APIMessageInteraction, APIMessageInteractionMetadata } from './interactions'; +import type { APIRole } from './permissions'; +import type { APIPoll } from './poll'; +import type { APISticker, APIStickerItem } from './sticker'; +import type { APIUser } from './user'; + +/** + * 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 (1-100 characters) + */ + name?: string | null; +} + +/** + * 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; + flags?: ChannelFlags; +} + +export type TextChannelType = + | ChannelType.AnnouncementThread + | ChannelType.DM + | ChannelType.GroupDM + | ChannelType.GuildAnnouncement + | ChannelType.GuildStageVoice + | ChannelType.GuildText + | ChannelType.GuildVoice + | ChannelType.PrivateThread + | ChannelType.PublicThread; + +export type GuildChannelType = Exclude; + +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; + /** + * 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; + /** + * 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 interface APIGuildChannel extends Omit, 'name'> { + /** + * The name of the channel (1-100 characters) + */ + name: string; + /** + * 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 Omit, 'name'>, + APIGuildChannel { + /** + * Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity + */ + default_auto_archive_duration?: ThreadAutoArchiveDuration; + /** + * The initial `rate_limit_per_user` to set on newly created threads. + * This field is copied to the thread at creation time and does not live update + */ + default_thread_rate_limit_per_user?: number; + /** + * The channel topic (0-1024 characters) + */ + topic?: string | null; +} + +export type APITextChannel = APIGuildTextChannel; +export type APINewsChannel = APIGuildTextChannel; +export type APIGuildCategoryChannel = APIGuildChannel; + +export interface APIVoiceChannelBase + extends APIGuildChannel, + Omit, 'last_pin_timestamp' | 'name'> { + /** + * The bitrate (in bits) of the voice or stage channel + */ + bitrate?: number; + /** + * The user limit of the voice or stage 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 or stage channel, `1` when not present + * + * See https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes + */ + video_quality_mode?: VideoQualityMode; +} + +export type APIGuildVoiceChannel = APIVoiceChannelBase; + +export type APIGuildStageVoiceChannel = APIVoiceChannelBase; + +export interface APIDMChannelBase extends Omit, 'rate_limit_per_user'> { + /** + * The recipients of the DM + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + recipients?: APIUser[]; +} + +export interface APIDMChannel extends Omit, 'name'> { + /** + * The name of the channel (always null for DM channels) + */ + name: null; +} + +export interface APIGroupDMChannel extends Omit, 'name'> { + /** + * The name of the channel (1-100 characters) + */ + name: string | null; + /** + * 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; + /** + * Whether the channel is managed by an OAuth2 application + */ + managed?: boolean; +} + +export type ThreadChannelType = ChannelType.AnnouncementThread | ChannelType.PrivateThread | ChannelType.PublicThread; + +export interface APIThreadChannel + extends Omit, 'name'>, + APIGuildChannel { + /** + * 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; + /** + * Number of messages (not including the initial message or deleted messages) in a thread + * + * If the thread was created before July 1, 2022, it stops counting at 50 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; + /** + * ID of the thread creator + */ + owner_id?: Snowflake; + /** + * Number of messages ever sent in a thread + * + * Similar to `message_count` on message creation, but won't decrement when a message is deleted + */ + total_message_sent?: number; + /** + * The IDs of the set of tags that have been applied to a thread in a thread-only channel + */ + applied_tags: Snowflake[]; +} + +/** + * https://discord.com/developers/docs/resources/channel#forum-tag-object-forum-tag-structure + */ +export interface APIGuildForumTag { + /** + * The id of the tag + */ + id: Snowflake; + /** + * The name of the tag (0-20 characters) + */ + name: string; + /** + * Whether this tag can only be added to or removed from threads by a member with the `MANAGE_THREADS` permission + */ + moderated: boolean; + /** + * The id of a guild's custom emoji + */ + emoji_id: Snowflake | null; + /** + * The unicode character of the emoji + */ + emoji_name: string | null; +} + +/** + * https://discord.com/developers/docs/resources/channel#default-reaction-object-default-reaction-structure + */ +export interface APIGuildForumDefaultReactionEmoji { + /** + * The id of a guild's custom emoji + */ + emoji_id: Snowflake | null; + /** + * The unicode character of the emoji + */ + emoji_name: string | null; +} + +/** + * https://discord.com/developers/docs/resources/channel/#channel-object-sort-order-types + */ +export enum SortOrderType { + /** + * Sort forum posts by activity + */ + LatestActivity, + /** + * Sort forum posts by creation time (from most recent to oldest) + */ + CreationDate, +} + +/** + * https://discord.com/developers/docs/resources/channel/#channel-object-forum-layout-types + */ +export enum ForumLayoutType { + /** + * No default has been set for forum channel + */ + NotSet, + /** + * Display posts as a list + */ + ListView, + /** + * Display posts as a collection of tiles + */ + GalleryView, +} + +export interface APIThreadOnlyChannel + extends APIGuildChannel { + /** + * The channel topic (0-4096 characters) + */ + topic?: string | null; + /** + * The id of the last thread created in this channel (may not point to an existing or valid thread) + */ + last_message_id?: Snowflake | null; + /** + * Amount of seconds a user has to wait before creating another thread (0-21600); + * bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected + * + * 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; + /** + * 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; + /** + * Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity + */ + default_auto_archive_duration?: ThreadAutoArchiveDuration; + /** + * The set of tags that can be used in a thread-only channel + */ + available_tags: APIGuildForumTag[]; + /** + * The initial `rate_limit_per_user` to set on newly created threads. + * This field is copied to the thread at creation time and does not live update + */ + default_thread_rate_limit_per_user?: number; + /** + * The emoji to show in the add reaction button on a thread in a thread-only channel + */ + default_reaction_emoji: APIGuildForumDefaultReactionEmoji | null; + /** + * The default sort order type used to order posts in a thread-only channel + */ + default_sort_order: SortOrderType | null; +} + +export interface APIGuildForumChannel extends APIThreadOnlyChannel { + /** + * The default layout type used to display posts in a forum channel. Defaults to `0`, which indicates a layout view has not been set by a channel admin + */ + default_forum_layout: ForumLayoutType; +} + +export type APIGuildMediaChannel = APIThreadOnlyChannel; + +/** + * https://discord.com/developers/docs/resources/channel#channel-object-channel-structure + */ +export type APIChannel = + | APIDMChannel + | APIGroupDMChannel + | APIGuildCategoryChannel + | APIGuildForumChannel + | APIGuildMediaChannel + | APIGuildStageVoiceChannel + | APIGuildVoiceChannel + | APINewsChannel + | APITextChannel + | APIThreadChannel; + +/** + * 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; + /** + * 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; + /** + * Contents of the message + * + * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field + * + * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot > Privileged Gateway Intents**. + * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway + * + * See https://support-dev.discord.com/hc/articles/4404772028055 + */ + 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[]; + /** + * 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 + * + * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field + * + * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot > Privileged Gateway Intents**. + * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway + * + * See https://support-dev.discord.com/hc/articles/4404772028055 + */ + attachments: APIAttachment[]; + /** + * Any embedded content + * + * See https://discord.com/developers/docs/resources/channel#embed-object + * + * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field + * + * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot > Privileged Gateway Intents**. + * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway + * + * See https://support-dev.discord.com/hc/articles/4404772028055 + */ + 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?: number | string; + /** + * 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/application#application-object + */ + 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-reference-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 sent as a result of an interaction + * + * @unstable + */ + interaction_metadata?: APIMessageInteractionMetadata; + /** + * Sent if the message is a response to an Interaction + * + * @deprecated In favor of `interaction_metadata` + */ + 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 + * + * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field + * + * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot > Privileged Gateway Intents**. + * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway + * + * See https://support-dev.discord.com/hc/articles/4404772028055 + */ + 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[]; + /** + * A generally increasing integer (there may be gaps or duplicates) that represents the approximate position of the message in a thread + * + * It can be used to estimate the relative position of the message in a thread in company with `total_message_sent` on parent thread + */ + position?: number; + /** + * Data of the role subscription purchase or renewal that prompted this `ROLE_SUBSCRIPTION_PURCHASE` message + */ + role_subscription_data?: APIMessageRoleSubscriptionData; + /** + * Data for users, members, channels, and roles in the message's auto-populated select menus + * + * See https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure + */ + resolved?: APIInteractionDataResolved; + /** + * A poll! + * + * The `MESSAGE_CONTENT` privileged gateway intent is required for verified applications to receive a non-empty value from this field + * + * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot > Privileged Gateway Intents**. + * You also need to specify the intent bit value (`1 << 15`) if you are connecting to the gateway + * + * See https://support-dev.discord.com/hc/articles/4404772028055 + */ + poll?: APIPoll; + /** + * The call associated with the message + */ + call?: APIMessageCall; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-types + */ +export enum MessageType { + Default, + RecipientAdd, + RecipientRemove, + Call, + ChannelNameChange, + ChannelIconChange, + ChannelPinnedMessage, + UserJoin, + GuildBoost, + GuildBoostTier1, + GuildBoostTier2, + GuildBoostTier3, + ChannelFollowAdd, + + GuildDiscoveryDisqualified = 14, + GuildDiscoveryRequalified, + GuildDiscoveryGracePeriodInitialWarning, + GuildDiscoveryGracePeriodFinalWarning, + ThreadCreated, + Reply, + ChatInputCommand, + ThreadStarterMessage, + GuildInviteReminder, + ContextMenuCommand, + AutoModerationAction, + RoleSubscriptionPurchase, + InteractionPremiumUpsell, + StageStart, + StageEnd, + StageSpeaker, + /** + * @unstable https://github.com/discord/discord-api-docs/pull/5927#discussion_r1107678548 + */ + StageRaiseHand, + StageTopic, + GuildApplicationPremiumSubscription, + + GuildIncidentAlertModeEnabled = 36, + GuildIncidentAlertModeDisabled, + GuildIncidentReportRaid, + GuildIncidentReportFalseAlarm, +} + +/** + * 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-reference-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, + /** + * @unstable This message flag is currently not documented by Discord but has a known value which we will try to keep up to date. + */ + ShouldShowLinkNotDiscordWarning = 1 << 10, + /** + * This message will not trigger push and desktop notifications + */ + SuppressNotifications = 1 << 12, + /** + * This message is a voice message + */ + IsVoiceMessage = 1 << 13, +} + +/** + * https://discord.com/developers/docs/resources/channel#message-call-object-message-call-object-structure + */ +export interface APIMessageCall { + /** + * Array of user ids that participated in the call + */ + participants: Snowflake[]; + /** + * ISO8601 timestamp when the call ended + */ + ended_timestamp?: string | null; +} + +/** + * https://discord.com/developers/docs/resources/channel#role-subscription-data-object-role-subscription-data-object-structure + */ +export interface APIMessageRoleSubscriptionData { + /** + * The id of the SKU and listing the user is subscribed to + */ + role_subscription_listing_id: Snowflake; + /** + * The name of the tier the user is subscribed to + */ + tier_name: string; + /** + * The number of months the user has been subscribed for + */ + total_months_subscribed: number; + /** + * Whether this notification is for a renewal + */ + is_renewal: boolean; +} + +/** + * 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 { + /** + * Total number of times this emoji has been used to react (including super reacts) + */ + count: number; + /** + * An object detailing the individual reaction counts for different types of reactions + */ + count_details: APIReactionCountDetails; + /** + * Whether the current user reacted using this emoji + */ + me: boolean; + /** + * Whether the current user super-reacted using this emoji + */ + me_burst: boolean; + /** + * Emoji information + * + * See https://discord.com/developers/docs/resources/emoji#emoji-object + */ + emoji: APIPartialEmoji; + /** + * Hexadecimal colors used for this super reaction + */ + burst_colors: string[]; +} + +/** + * https://discord.com/developers/docs/resources/channel#reaction-count-details-object-reaction-count-details-structure + */ +export interface APIReactionCountDetails { + /** + * Count of super reactions + */ + burst: number; + /** + * Count of normal reactions + */ + normal: number; +} + +/** + * 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; +} + +/** + * 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 = 1_440, + ThreeDays = 4_320, + OneWeek = 10_080, +} + +/** + * 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; + /** + * Additional information about the user + * + * **This field is omitted on the member sent within each thread in the `GUILD_CREATE` event** + * + * **This field is only present when `with_member` is set to true when calling `List Thread Members` or `Get Thread Member`** + */ + member?: APIGuildMember; +} + +export enum ThreadMemberFlags { + /** + * @unstable This thread member flag is currently not documented by Discord but has a known value which we will try to keep up to date. + */ + HasInteracted = 1 << 0, + /** + * @unstable This thread member flag is currently not documented by Discord but has a known value which we will try to keep up to date. + */ + AllMessages = 1 << 1, + /** + * @unstable This thread member flag is currently not documented by Discord but has a known value which we will try to keep up to date. + */ + OnlyMentions = 1 << 2, + /** + * @unstable This thread member flag is currently not documented by Discord but has a known value which we will try to keep up to date. + */ + NoMessages = 1 << 3, +} + +export interface APIThreadList { + /** + * The threads that were fetched + */ + threads: APIChannel[]; + /** + * The members for the client user in each of the fetched threads + */ + members: APIThreadMember[]; +} + +/** + * 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', + /** + * Auto moderation alert embed + * + * @unstable This embed type is currently not documented by Discord, but it is returned in the auto moderation system messages. + */ + AutoModerationMessage = 'auto_moderation_message', +} + +/** + * 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; + /** + * A proxied url of the video + */ + proxy_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; + /** + * The title of the file + */ + title?: 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; + /** + * The duration of the audio file (currently for voice messages) + */ + duration_secs?: number; + /** + * Base64 encoded bytearray representing a sampled waveform (currently for voice messages) + */ + waveform?: string; + /** + * Attachment flags combined as a bitfield + */ + flags?: AttachmentFlags; +} + +/** + * https://discord.com/developers/docs/resources/channel#attachment-object-attachment-structure-attachment-flags + */ +export enum AttachmentFlags { + /** + * This attachment has been edited using the remix feature on mobile + */ + IsRemix = 1 << 2, +} + +/** + * 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-object-component-types + */ +export enum ComponentType { + /** + * Action Row component + */ + ActionRow = 1, + /** + * Button component + */ + Button, + /** + * Select menu for picking from defined text options + */ + StringSelect, + /** + * Text Input component + */ + TextInput, + /** + * Select menu for users + */ + UserSelect, + /** + * Select menu for roles + */ + RoleSelect, + /** + * Select menu for users and roles + */ + MentionableSelect, + /** + * Select menu for channels + */ + ChannelSelect, + + // EVERYTHING BELOW THIS LINE SHOULD BE OLD NAMES FOR RENAMED ENUM MEMBERS // + + /** + * Select menu for picking from defined text options + * + * @deprecated This is the old name for {@apilink ComponentType#StringSelect} + */ + SelectMenu = 3, +} + +/** + * 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 + */ +export interface APIButtonComponentBase