From 6464fe993253266968e19568e6a7b8c39045cee1 Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Fri, 1 Jan 2021 23:33:43 +0200 Subject: [PATCH] chore(chores): All the chores! And release 0.12.0 (#62) Co-authored-by: Vlad Frangu Co-authored-by: cherryblossom000 <31467609+cherryblossom000@users.noreply.github.com> --- .deno/LICENSE | 21 + .deno/README.md | 102 ++ .deno/common/mod.ts | 149 +++ .deno/mod.ts | 4 + .deno/v6/gateway/mod.ts | 819 +++++++++++++++ .deno/v6/mod.ts | 4 + .deno/v6/payloads/auditLog.ts | 547 ++++++++++ .deno/v6/payloads/channel.ts | 343 +++++++ .deno/v6/payloads/emoji.ts | 27 + .deno/v6/payloads/gateway.ts | 154 +++ .deno/v6/payloads/guild.ts | 315 ++++++ .deno/v6/payloads/invite.ts | 42 + .deno/v6/payloads/mod.ts | 12 + .deno/v6/payloads/oauth2.ts | 28 + .deno/v6/payloads/permissions.ts | 81 ++ .deno/v6/payloads/teams.ts | 36 + .deno/v6/payloads/user.ts | 80 ++ .deno/v6/payloads/voice.ts | 37 + .deno/v6/payloads/webhook.ts | 33 + .deno/v6/rest/auditLog.ts | 17 + .deno/v6/rest/channel.ts | 310 ++++++ .deno/v6/rest/emoji.ts | 51 + .deno/v6/rest/gateway.ts | 13 + .deno/v6/rest/guild.ts | 516 ++++++++++ .deno/v6/rest/invite.ts | 20 + .deno/v6/rest/mod.ts | 519 ++++++++++ .deno/v6/rest/oauth2.ts | 181 ++++ .deno/v6/rest/user.ts | 83 ++ .deno/v6/rest/voice.ts | 7 + .deno/v6/rest/webhook.ts | 146 +++ .deno/v8/gateway/mod.ts | 1543 +++++++++++++++++++++++++++++ .deno/v8/mod.ts | 4 + .deno/v8/payloads/auditLog.ts | 531 ++++++++++ .deno/v8/payloads/channel.ts | 911 +++++++++++++++++ .deno/v8/payloads/emoji.ts | 49 + .deno/v8/payloads/gateway.ts | 304 ++++++ .deno/v8/payloads/guild.ts | 855 ++++++++++++++++ .deno/v8/payloads/interactions.ts | 180 ++++ .deno/v8/payloads/invite.ts | 88 ++ .deno/v8/payloads/mod.ts | 14 + .deno/v8/payloads/oauth2.ts | 192 ++++ .deno/v8/payloads/permissions.ts | 113 +++ .deno/v8/payloads/teams.ts | 61 ++ .deno/v8/payloads/template.ts | 64 ++ .deno/v8/payloads/user.ts | 157 +++ .deno/v8/payloads/voice.ts | 91 ++ .deno/v8/payloads/webhook.ts | 64 ++ .deno/v8/rest/auditLog.ts | 27 + .deno/v8/rest/channel.ts | 443 +++++++++ .deno/v8/rest/emoji.ts | 60 ++ .deno/v8/rest/gateway.ts | 11 + .deno/v8/rest/guild.ts | 771 ++++++++++++++ .deno/v8/rest/interactions.ts | 77 ++ .deno/v8/rest/invite.ts | 18 + .deno/v8/rest/mod.ts | 632 ++++++++++++ .deno/v8/rest/oauth2.ts | 179 ++++ .deno/v8/rest/template.ts | 70 ++ .deno/v8/rest/user.ts | 89 ++ .deno/v8/rest/voice.ts | 6 + .deno/v8/rest/webhook.ts | 222 +++++ .github/workflows/codequality.yml | 44 +- .github/workflows/deno.yml | 40 + .gitignore | 3 + README.md | 36 +- common/index.ts | 5 +- default/index.ts | 2 +- package-lock.json | 433 +++++++- package.json | 218 ++-- scripts/deno.mjs | 92 ++ tsconfig.eslint.json | 8 + tsconfig.json | 12 +- v6/gateway/index.ts | 2 +- v6/index.ts | 8 +- v6/rest/channel.ts | 2 +- v6/rest/emoji.ts | 2 +- v6/rest/gateway.ts | 2 +- v6/rest/guild.ts | 2 +- v6/rest/invite.ts | 2 +- v6/rest/oauth2.ts | 2 +- v6/rest/user.ts | 2 +- v6/rest/voice.ts | 2 +- v6/rest/webhook.ts | 2 +- v8/gateway/index.ts | 640 +++++++++++- v8/index.ts | 8 +- v8/payloads/auditLog.ts | 94 +- v8/payloads/channel.ts | 595 ++++++++++- v8/payloads/emoji.ts | 24 + v8/payloads/gateway.ts | 170 +++- v8/payloads/guild.ts | 699 +++++++++++-- v8/payloads/interactions.ts | 14 +- v8/payloads/invite.ts | 49 + v8/payloads/oauth2.ts | 164 +++ v8/payloads/permissions.ts | 107 +- v8/payloads/teams.ts | 32 +- v8/payloads/template.ts | 37 +- v8/payloads/user.ts | 84 ++ v8/payloads/voice.ts | 56 ++ v8/payloads/webhook.ts | 43 +- v8/rest/auditLog.ts | 14 + v8/rest/channel.ts | 368 +++++-- v8/rest/emoji.ts | 24 +- v8/rest/gateway.ts | 2 +- v8/rest/guild.ts | 418 +++++++- v8/rest/index.ts | 32 +- v8/rest/interactions.ts | 2 +- v8/rest/invite.ts | 5 +- v8/rest/oauth2.ts | 44 +- v8/rest/template.ts | 39 +- v8/rest/user.ts | 31 +- v8/rest/voice.ts | 2 +- v8/rest/webhook.ts | 110 +- 111 files changed, 16906 insertions(+), 445 deletions(-) create mode 100644 .deno/LICENSE create mode 100644 .deno/README.md create mode 100644 .deno/common/mod.ts create mode 100644 .deno/mod.ts create mode 100644 .deno/v6/gateway/mod.ts create mode 100644 .deno/v6/mod.ts create mode 100644 .deno/v6/payloads/auditLog.ts create mode 100644 .deno/v6/payloads/channel.ts create mode 100644 .deno/v6/payloads/emoji.ts create mode 100644 .deno/v6/payloads/gateway.ts create mode 100644 .deno/v6/payloads/guild.ts create mode 100644 .deno/v6/payloads/invite.ts create mode 100644 .deno/v6/payloads/mod.ts create mode 100644 .deno/v6/payloads/oauth2.ts create mode 100644 .deno/v6/payloads/permissions.ts create mode 100644 .deno/v6/payloads/teams.ts create mode 100644 .deno/v6/payloads/user.ts create mode 100644 .deno/v6/payloads/voice.ts create mode 100644 .deno/v6/payloads/webhook.ts create mode 100644 .deno/v6/rest/auditLog.ts create mode 100644 .deno/v6/rest/channel.ts create mode 100644 .deno/v6/rest/emoji.ts create mode 100644 .deno/v6/rest/gateway.ts create mode 100644 .deno/v6/rest/guild.ts create mode 100644 .deno/v6/rest/invite.ts create mode 100644 .deno/v6/rest/mod.ts create mode 100644 .deno/v6/rest/oauth2.ts create mode 100644 .deno/v6/rest/user.ts create mode 100644 .deno/v6/rest/voice.ts create mode 100644 .deno/v6/rest/webhook.ts create mode 100644 .deno/v8/gateway/mod.ts create mode 100644 .deno/v8/mod.ts create mode 100644 .deno/v8/payloads/auditLog.ts create mode 100644 .deno/v8/payloads/channel.ts create mode 100644 .deno/v8/payloads/emoji.ts create mode 100644 .deno/v8/payloads/gateway.ts create mode 100644 .deno/v8/payloads/guild.ts create mode 100644 .deno/v8/payloads/interactions.ts create mode 100644 .deno/v8/payloads/invite.ts create mode 100644 .deno/v8/payloads/mod.ts create mode 100644 .deno/v8/payloads/oauth2.ts create mode 100644 .deno/v8/payloads/permissions.ts create mode 100644 .deno/v8/payloads/teams.ts create mode 100644 .deno/v8/payloads/template.ts create mode 100644 .deno/v8/payloads/user.ts create mode 100644 .deno/v8/payloads/voice.ts create mode 100644 .deno/v8/payloads/webhook.ts create mode 100644 .deno/v8/rest/auditLog.ts create mode 100644 .deno/v8/rest/channel.ts create mode 100644 .deno/v8/rest/emoji.ts create mode 100644 .deno/v8/rest/gateway.ts create mode 100644 .deno/v8/rest/guild.ts create mode 100644 .deno/v8/rest/interactions.ts create mode 100644 .deno/v8/rest/invite.ts create mode 100644 .deno/v8/rest/mod.ts create mode 100644 .deno/v8/rest/oauth2.ts create mode 100644 .deno/v8/rest/template.ts create mode 100644 .deno/v8/rest/user.ts create mode 100644 .deno/v8/rest/voice.ts create mode 100644 .deno/v8/rest/webhook.ts create mode 100644 .github/workflows/deno.yml create mode 100644 scripts/deno.mjs create mode 100644 tsconfig.eslint.json diff --git a/.deno/LICENSE b/.deno/LICENSE new file mode 100644 index 00000000..a8b16946 --- /dev/null +++ b/.deno/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 vladfrangu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/.deno/README.md b/.deno/README.md new file mode 100644 index 00000000..e54094ef --- /dev/null +++ b/.deno/README.md @@ -0,0 +1,102 @@ +

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) +[![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) + +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 +``` + +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 the default API version +import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/.deno/mod.ts'; + +// Importing a specific API version +import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/.deno/v8/mod.ts'; +``` + +2. From [deno.land/x](https://deno.land/x) + +```ts +// Importing the default API version +import { APIUser } from 'https://deno.land/x/discord_api_types@0.12.0/mod.ts'; + +// Importing a specific API version +import { APIUser } from 'https://deno.land/x/discord_api_types@0.12.0/v8/mod.ts'; +``` + +3. From [skypack.dev](https://www.skypack.dev/) + +```ts +// Importing the default API version +import { APIUser } from 'https://cdn.skypack.dev/discord-api-types?dts'; + +// Importing a specific API version +import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v8?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 `common` directory. They will still be prefixed accordingly as described above. + +**Warning**: This package documents just KNOWN (and documented) properties. Anything that isn't documented will NOT be added to this package (unless said properties are in an open Pull Request to Discord's [API Documentation repository](https://github.com/discord/discord-api-docs) or known through other means _and have received the green light to be used_). For clarification's sake, this means that properties that are only known through the process of data mining and have not yet been confirmed in a way as described will NOT be included. + +## Usage + +You can `require` / `import` the module directly, which will give you the latest types as of the current API version. This is considered the `default` version and will be updated according to Discord's default API version; this means it may break at any point in time. + +> We **strongly recommend** you use a version when importing this module! This will prevent breaking changes when updating the module. + +```js +const { APIUser } = require('discord-api-types'); +``` + +```ts +// TypeScript/ES Module support +import { APIUser } from 'discord-api-types'; +``` + +You should instead consider adding the API version you want to target by appending `/v*`, where the `*` represents the API version. + +```js +const { APIUser } = require('discord-api-types/v8'); +``` + +```ts +// TypeScript/ES Module support +import { APIUser } from 'discord-api-types/v8'; +``` diff --git a/.deno/common/mod.ts b/.deno/common/mod.ts new file mode 100644 index 00000000..2d1815b3 --- /dev/null +++ b/.deno/common/mod.ts @@ -0,0 +1,149 @@ +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#json-json-error-codes + */ +export const enum RESTJSONErrorCodes { + GeneralError, + + UnknownAccount = 10001, + UnknownApplication, + UnknownChannel, + UnknownGuild, + UnknownIntegration, + UnknownInvite, + UnknownMember, + UnknownMessage, + UnknownPermissionOverwrite, + UnknownProvider, + UnknownRole, + UnknownToken, + UnknownUser, + UnknownEmoji, + UnknownWebhook, + + UnknownBan = 10026, + UnknownSKU, + UnknownStoreListing, + UnknownEntitlement, + UnknownBuild, + UnknownLobby, + UnknownBranch, + + UnknownRedistributable = 10036, + + BotsCannotUseThisEndpoint = 20001, + OnlyBotsCanUseThisEndpoint, + + AnnouncementEditLimitExceeded = 20022, + + ChannelSendRateLimit = 20028, + + MaximumNumberOfGuildsReached = 30001, + MaximumNumberOfFriendsReached, + MaximumNumberOfPinsReachedForTheChannel, + + MaximumNumberOfGuildRolesReached = 30005, + + MaximumNumberOfWebhooksReached = 30007, + + MaximumNumberOfReactionsReached = 30010, + + MaximumNumberOfGuildChannelsReached = 30013, + + MaximumNumberOfAttachmentsInAMessageReached = 30015, + MaximumNumberOfInvitesReached, + + GuildAlreadyHasTemplate = 30031, + + Unauthorized = 40001, + VerifyYourAccount, + + RequestEntityTooLarge = 40005, + FeatureTemporarilyDisabledServerSide, + UserBannedFromThisGuild, + + ThisMessageWasAlreadyCrossposted = 40033, + + MissingAccess = 50001, + InvalidAccountType, + CannotExecuteActionOnDMChannel, + GuildWidgetDisabled, + CannotEditMessageAuthoredByAnotherUser, + CannotSendAnEmptyMessage, + CannotSendMessagesToThisUser, + CannotSendMessagesInVoiceChannel, + ChannelVerificationLevelTooHighForYouToGainAccess, + Oauth2ApplicationDoesNotHaveBot, + Oauth2ApplicationLimitReached, + InvalidOauth2State, + MissingPermissions, + InvalidToken, + NoteWasTooLong, + ProvidedTooFewOrTooManyMessagesToDelete, + + MessageCanOnlyBePinnedInTheChannelItWasSentIn = 50019, + InviteCodeInvalidOrTaken, + CannotExecuteActionOnSystemMessage, + + CannotExecuteActionOnThisChannelType = 50024, + InvalidOauth2AccessToken, + + InvalidRecipients = 50033, + OneOfTheMessagesProvidedWasTooOldForBulkDelete, + InvalidFormBodyOrContentType, + InviteAcceptedToGuildWithoutTheBotBeingIn, + + InvalidAPIVersion = 50041, + + CannotDeleteChannelRequiredForCommunityGuilds = 50074, + + InvalidStickerSent = 50081, + + TwoFactorAuthenticationIsRequired = 60003, + + ReactionWasBlocked = 90001, + + APIResourceOverloaded = 130000, +} + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc-rpc-error-codes + */ +export const enum RPCErrorCodes { + UnknownError = 1000, + InvalidPayload = 4000, + InvalidCommand = 4002, + InvalidGuild, + InvalidEvent, + InvalidChannel, + InvalidPermissions, + InvalidClientID, + InvalidOrigin, + InvalidToken, + InvalidUser, + OAuth2Error = 5000, + SelectChannelTimedOut, + GetGuildTimedOut, + SelectVoiceForceRequired, + CaptureShortcutAlreadyListening, +} + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc-rpc-close-event-codes + */ +export const enum RPCCloseEventCodes { + InvalidClientID = 4000, + InvalidOrigin, + RateLimited, + TokenRevoked, + InvalidVersion, + InvalidEncoding, +} + +/** + * https://discord.com/developers/docs/topics/gateway#connecting-gateway-url-params + */ +export interface GatewayConnectQuery { + v: string; + encoding: 'json' | 'etf'; + compress?: 'zlib-stream'; +} diff --git a/.deno/mod.ts b/.deno/mod.ts new file mode 100644 index 00000000..8933584a --- /dev/null +++ b/.deno/mod.ts @@ -0,0 +1,4 @@ +// This file exports all the types available in the default API version +// Thereby, things MAY break in the future + +export * from './v8/mod.ts'; diff --git a/.deno/v6/gateway/mod.ts b/.deno/v6/gateway/mod.ts new file mode 100644 index 00000000..7c8f88c8 --- /dev/null +++ b/.deno/v6/gateway/mod.ts @@ -0,0 +1,819 @@ +/** + * Types extracted from https://discord.com/developers/docs/topics/gateway + */ + +import type { + APIChannel, + APIEmoji, + APIGuild, + APIGuildMember, + APIMessage, + APIRole, + APIUnavailableGuild, + APIUser, + GatewayActivity, + GatewayPresenceUpdate as RawGatewayPresenceUpdate, + GatewayVoiceState, + InviteTargetUserType, + PresenceUpdateStatus, +} from '../payloads/mod.ts'; + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export const GatewayVersion = '6'; + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export enum GatewayOPCodes { + Dispatch, + Heartbeat, + Identify, + PresenceUpdate, + VoiceStateUpdate, + + Resume = 6, + Reconnect, + RequestGuildMembers, + InvalidSession, + Hello, + HeartbeatAck, +} + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export enum GatewayCloseCodes { + UnknownError = 4000, + UnknownOpCode, + DecodeError, + NotAuthenticated, + AuthenticationFailed, + AlreadyAuthenticated, + + InvalidSeq = 4007, + RateLimited, + SessionTimedOut, + InvalidShard, + ShardingRequired, + InvalidAPIVersion, + InvalidIntents, + DisallowedIntents, +} + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-opcodes + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export enum VoiceOPCodes { + Identify, + SelectProtocol, + Ready, + Heartbeat, + SessionDescription, + Speaking, + HeartbeatAck, + Resume, + Hello, + Resumed, + + ClientDisconnect = 13, +} + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export enum VoiceCloseCodes { + UnknownOpCode = 4001, + + NotAuthenticated = 4003, + AuthenticationFailed, + AlreadyAuthenticated, + SessionNoLongerValid, + + SessionTimeout = 4009, + + ServerNotFound = 4011, + UnknownProtocol, + + Disconnected = 4014, + VoiceServerCrashed, + UnknownEncryptionMode, +} + +/** + * https://discord.com/developers/docs/topics/gateway#list-of-intents + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export enum GatewayIntentBits { + GUILDS = 1 << 0, + GUILD_MEMBERS = 1 << 1, + GUILD_BANS = 1 << 2, + GUILD_EMOJIS = 1 << 3, + GUILD_INTEGRATIONS = 1 << 4, + GUILD_WEBHOOKS = 1 << 5, + GUILD_INVITES = 1 << 6, + GUILD_VOICE_STATES = 1 << 7, + GUILD_PRESENCES = 1 << 8, + GUILD_MESSAGES = 1 << 9, + GUILD_MESSAGE_REACTIONS = 1 << 10, + GUILD_MESSAGE_TYPING = 1 << 11, + DIRECT_MESSAGES = 1 << 12, + DIRECT_MESSAGE_REACTIONS = 1 << 13, + DIRECT_MESSAGE_TYPING = 1 << 14, +} + +/** + * https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export enum GatewayDispatchEvents { + Ready = 'READY', + Resumed = 'RESUMED', + ChannelCreate = 'CHANNEL_CREATE', + ChannelUpdate = 'CHANNEL_UPDATE', + ChannelDelete = 'CHANNEL_DELETE', + ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE', + GuildCreate = 'GUILD_CREATE', + GuildUpdate = 'GUILD_UPDATE', + GuildDelete = 'GUILD_DELETE', + GuildBanAdd = 'GUILD_BAN_ADD', + GuildBanRemove = 'GUILD_BAN_REMOVE', + GuildEmojisUpdate = 'GUILD_EMOJIS_UPDATE', + GuildIntegrationsUpdate = 'GUILD_INTEGRATIONS_UPDATE', + GuildMemberAdd = 'GUILD_MEMBER_ADD', + GuildMemberRemove = 'GUILD_MEMBER_REMOVE', + GuildMemberUpdate = 'GUILD_MEMBER_UPDATE', + GuildMembersChunk = 'GUILD_MEMBERS_CHUNK', + GuildRoleCreate = 'GUILD_ROLE_CREATE', + GuildRoleUpdate = 'GUILD_ROLE_UPDATE', + GuildRoleDelete = 'GUILD_ROLE_DELETE', + InviteCreate = 'INVITE_CREATE', + InviteDelete = 'INVITE_DELETE', + MessageCreate = 'MESSAGE_CREATE', + MessageUpdate = 'MESSAGE_UPDATE', + MessageDelete = 'MESSAGE_DELETE', + MessageDeleteBulk = 'MESSAGE_DELETE_BULK', + MessageReactionAdd = 'MESSAGE_REACTION_ADD', + MessageReactionRemove = 'MESSAGE_REACTION_REMOVE', + MessageReactionRemoveAll = 'MESSAGE_REACTION_REMOVE_ALL', + MessageReactionRemoveEmoji = 'MESSAGE_REACTION_REMOVE_EMOJI', + PresenceUpdate = 'PRESENCE_UPDATE', + TypingStart = 'TYPING_START', + UserUpdate = 'USER_UPDATE', + VoiceStateUpdate = 'VOICE_STATE_UPDATE', + VoiceServerUpdate = 'VOICE_SERVER_UPDATE', + WebhooksUpdate = 'WEBHOOKS_UPDATE', +} + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewaySendPayload = + | GatewayHeartbeat + | GatewayIdentify + | GatewayUpdatePresence + | GatewayVoiceStateUpdate + | GatewayResume + | GatewayRequestGuildMembers; + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayReceivePayload = + | GatewayHello + | GatewayHeartbeatRequest + | GatewayHeartbeatAck + | GatewayInvalidSession + | GatewayReconnect + | GatewayDispatchPayload; + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayDispatchPayload = + | GatewayReadyDispatch + | GatewayResumedDispatch + | GatewayChannelModifyDispatch + | GatewayChannelPinsUpdateDispatch + | GatewayGuildModifyDispatch + | GatewayGuildDeleteDispatch + | GatewayGuildBanModifyDispatch + | GatewayGuildEmojisUpdateDispatch + | GatewayGuildIntegrationsUpdateDispatch + | GatewayGuildMemberAddDispatch + | GatewayGuildMemberRemoveDispatch + | GatewayGuildMemberUpdateDispatch + | GatewayGuildMembersChunkDispatch + | GatewayGuildRoleModifyDispatch + | GatewayGuildRoleDeleteDispatch + | GatewayInviteCreateDispatch + | GatewayInviteDeleteDispatch + | GatewayMessageCreateDispatch + | GatewayMessageUpdateDispatch + | GatewayMessageDeleteDispatch + | GatewayMessageDeleteBulkDispatch + | GatewayMessageReactionAddDispatch + | GatewayMessageReactionRemoveDispatch + | GatewayMessageReactionRemoveAllDispatch + | GatewayMessageReactionRemoveEmojiDispatch + | GatewayPresenceUpdateDispatch + | GatewayTypingStartDispatch + | GatewayUserUpdateDispatch + | GatewayVoiceStateUpdateDispatch + | GatewayVoiceServerUpdateDispatch + | GatewayWebhooksUpdateDispatch; + +// #region Dispatch Payloads +/** + * https://discord.com/developers/docs/topics/gateway#hello + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayHello extends NonDispatchPayload { + op: GatewayOPCodes.Hello; + d: { + heartbeat_interval: number; + }; +} + +/** + * https://discord.com/developers/docs/topics/gateway#heartbeating + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayHeartbeatRequest extends NonDispatchPayload { + op: GatewayOPCodes.Heartbeat; + d: never; +} + +/** + * https://discord.com/developers/docs/topics/gateway#heartbeating-example-gateway-heartbeat-ack + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayHeartbeatAck extends NonDispatchPayload { + op: GatewayOPCodes.HeartbeatAck; + d: never; +} + +/** + * https://discord.com/developers/docs/topics/gateway#invalid-session + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayInvalidSession extends NonDispatchPayload { + op: GatewayOPCodes.InvalidSession; + d: boolean; +} + +/** + * https://discord.com/developers/docs/topics/gateway#reconnect + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayReconnect extends NonDispatchPayload { + op: GatewayOPCodes.Reconnect; + d: never; +} + +/** + * https://discord.com/developers/docs/topics/gateway#ready + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayReadyDispatch = DataPayload< + GatewayDispatchEvents.Ready, + { + v: number; + user: APIUser; + session_id: string; + private_channels: []; + guilds: APIUnavailableGuild[]; + shard?: [number, number]; + } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#resumed + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayResumedDispatch = DataPayload; + +/* eslint-disable @typescript-eslint/indent */ +/** + * https://discord.com/developers/docs/topics/gateway#channel-create + * https://discord.com/developers/docs/topics/gateway#channel-update + * https://discord.com/developers/docs/topics/gateway#channel-delete + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayChannelModifyDispatch = DataPayload< + GatewayDispatchEvents.ChannelCreate | GatewayDispatchEvents.ChannelDelete | GatewayDispatchEvents.ChannelUpdate, + APIChannel +>; +/* eslint-enable @typescript-eslint/indent */ + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayChannelCreateDispatch = GatewayChannelModifyDispatch; + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayChannelUpdateDispatch = GatewayChannelModifyDispatch; + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayChannelDeleteDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-pins-update + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayChannelPinsUpdateDispatch = DataPayload< + GatewayDispatchEvents.ChannelPinsUpdate, + { + guild_id?: string; + channel_id: string; + last_pin_timestamp?: string; + } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-create + * https://discord.com/developers/docs/topics/gateway#guild-update + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildModifyDispatch = DataPayload< + GatewayDispatchEvents.GuildCreate | GatewayDispatchEvents.GuildUpdate, + APIGuild +>; + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildCreateDispatch = GatewayGuildModifyDispatch; + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildUpdateDispatch = GatewayGuildModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-delete + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildDeleteDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-add + * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildBanModifyDispatch = DataPayload< + GatewayDispatchEvents.GuildBanAdd | GatewayDispatchEvents.GuildBanRemove, + { + guild_id: string; + user: APIUser; + } +>; + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildBanAddDispatch = GatewayGuildBanModifyDispatch; + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildBanRemoveDispatch = GatewayGuildBanModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-emojis-update + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildEmojisUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildEmojisUpdate, + { + guild_id: string; + emojis: APIEmoji[]; + } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-integrations-update + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildIntegrationsUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildIntegrationsUpdate, + { guild_id: string } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-add + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildMemberAddDispatch = DataPayload< + GatewayDispatchEvents.GuildMemberAdd, + APIGuildMember & { guild_id: string } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-remove + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildMemberRemoveDispatch = DataPayload< + GatewayDispatchEvents.GuildMemberRemove, + { + guild_id: string; + user: APIUser; + } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-update + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildMemberUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildMemberUpdate, + Omit & { + guild_id: string; + } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-members-chunk + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildMembersChunkDispatch = DataPayload< + GatewayDispatchEvents.GuildMembersChunk, + { + guild_id: string; + members: APIGuildMember[]; + chunk_index?: number; + chunk_count?: number; + not_found?: unknown[]; + presences?: RawGatewayPresenceUpdate[]; + nonce?: string; + } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-create + * https://discord.com/developers/docs/topics/gateway#guild-role-update + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildRoleModifyDispatch = DataPayload< + GatewayDispatchEvents.GuildRoleCreate | GatewayDispatchEvents.GuildRoleUpdate, + { + guild_id: string; + role: APIRole; + } +>; + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildRoleCreateDispatch = GatewayGuildRoleModifyDispatch; + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildRoleUpdateDispatch = GatewayGuildRoleModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-delete + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayGuildRoleDeleteDispatch = DataPayload< + GatewayDispatchEvents.GuildRoleDelete, + { + guild_id: string; + role_id: string; + } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#invite-create + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayInviteCreateDispatch = DataPayload< + GatewayDispatchEvents.InviteCreate, + { + channel_id: string; + code: string; + created_at: number; + guild_id?: string; + inviter?: APIUser; + max_age: number; + max_uses: number; + target_user?: APIUser; + target_user_type?: InviteTargetUserType; + temporary: boolean; + uses: 0; + } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#invite-delete + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayInviteDeleteDispatch = DataPayload< + GatewayDispatchEvents.InviteDelete, + { + channel_id: string; + guild_id?: string; + code: string; + } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-create + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayMessageCreateDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#message-update + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayMessageUpdateDispatch = DataPayload< + GatewayDispatchEvents.MessageUpdate, + { id: string; channel_id: string } & Partial +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-delete + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayMessageDeleteDispatch = DataPayload< + GatewayDispatchEvents.MessageDelete, + { + id: string; + channel_id: string; + guild_id?: string; + } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-delete-bulk + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayMessageDeleteBulkDispatch = DataPayload< + GatewayDispatchEvents.MessageDeleteBulk, + { + ids: string[]; + channel_id: string; + guild_id?: string; + } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-add + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayMessageReactionAddDispatch = ReactionData; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayMessageReactionRemoveDispatch = ReactionData; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-all + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayMessageReactionRemoveAllDispatch = DataPayload< + GatewayDispatchEvents.MessageReactionRemoveAll, + MessageReactionRemoveData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayMessageReactionRemoveEmojiDispatch = DataPayload< + GatewayDispatchEvents.MessageReactionRemoveEmoji, + MessageReactionRemoveData & { + emoji: APIEmoji; + } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#presence-update + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayPresenceUpdateDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#typing-start + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayTypingStartDispatch = DataPayload< + GatewayDispatchEvents.TypingStart, + { + channel_id: string; + guild_id?: string; + user_id: string; + timestamp: number; + member?: APIGuildMember; + } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#user-update + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayUserUpdateDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#voice-state-update + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayVoiceStateUpdateDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#voice-server-update + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayVoiceServerUpdateDispatch = DataPayload< + GatewayDispatchEvents.VoiceServerUpdate, + { + token: string; + guild_id: string; + endpoint: string; + } +>; + +/** + * https://discord.com/developers/docs/topics/gateway#webhooks-update + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayWebhooksUpdateDispatch = DataPayload< + GatewayDispatchEvents.WebhooksUpdate, + { + guild_id: string; + channel_id: string; + } +>; + +// #endregion Dispatch Payloads + +// #region Sendable Payloads + +/** + * https://discord.com/developers/docs/topics/gateway#heartbeating + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayHeartbeat { + op: GatewayOPCodes.Heartbeat; + d: number; +} + +/** + * https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayIdentifyProperties { + $os: string; + $browser: string; + $device: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#identify + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayIdentify { + op: GatewayOPCodes.Identify; + d: { + token: string; + properties: GatewayIdentifyProperties; + compress?: boolean; + large_threshold?: number; + // eslint-disable-next-line prettier/prettier + shard?: [shard_id: number, shard_count: number]; + presence?: RawGatewayPresenceUpdate; + guild_subscriptions?: boolean; + intents?: number; + }; +} + +/** + * https://discord.com/developers/docs/topics/gateway#resume + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayResume { + op: GatewayOPCodes.Resume; + d: { + token: string; + session_id: string; + seq: number; + }; +} + +/** + * https://discord.com/developers/docs/topics/gateway#request-guild-members + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayRequestGuildMembers { + op: GatewayOPCodes.RequestGuildMembers; + d: { + guild_id: string | string[]; + query?: string; + limit: number; + presences?: boolean; + user_ids?: string | string[]; + nonce?: string; + }; +} + +/** + * https://discord.com/developers/docs/topics/gateway#update-voice-state + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayVoiceStateUpdate { + op: GatewayOPCodes.VoiceStateUpdate; + d: { + guild_id: string; + channel_id: string | null; + self_mute: boolean; + self_deaf: boolean; + }; +} + +/** + * https://discord.com/developers/docs/topics/gateway#update-status + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayUpdatePresence { + op: GatewayOPCodes.PresenceUpdate; + d: GatewayPresenceUpdateData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#update-status-gateway-status-update-structure + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayPresenceUpdateData { + since: number | null; + game: GatewayActivity | null; + status: PresenceUpdateStatus; + afk: boolean; +} + +// #endregion Sendable Payloads + +// #region Shared +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +interface BasePayload { + op: GatewayOPCodes; + s: number; + d?: unknown; + t?: string; +} + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +type NonDispatchPayload = Omit; + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +interface DataPayload extends BasePayload { + op: GatewayOPCodes.Dispatch; + t: Event; + d: D; +} + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +type ReactionData = DataPayload< + E, + Omit< + { + user_id: string; + channel_id: string; + message_id: string; + guild_id?: string; + member?: APIGuildMember; + emoji: APIEmoji; + }, + O + > +>; + +/** + * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. + */ +interface MessageReactionRemoveData { + channel_id: string; + message_id: string; + guild_id?: string; +} +// #endregion Shared diff --git a/.deno/v6/mod.ts b/.deno/v6/mod.ts new file mode 100644 index 00000000..d00f5b1f --- /dev/null +++ b/.deno/v6/mod.ts @@ -0,0 +1,4 @@ +export * from '../common/mod.ts'; +export * from './gateway/mod.ts'; +export * from './payloads/mod.ts'; +export * from './rest/mod.ts'; diff --git a/.deno/v6/payloads/auditLog.ts b/.deno/v6/payloads/auditLog.ts new file mode 100644 index 00000000..4ed584fd --- /dev/null +++ b/.deno/v6/payloads/auditLog.ts @@ -0,0 +1,547 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/audit-log + */ + +import type { APIOverwrite, ChannelType } from './channel.ts'; +import type { + APIGuildIntegration, + GuildDefaultMessageNotifications, + GuildExplicitContentFilter, + GuildMFALevel, + GuildVerificationLevel, + IntegrationExpireBehavior, +} from './guild.ts'; +import type { APIRole } from './permissions.ts'; +import type { APIUser } from './user.ts'; +import type { APIWebhook } from './webhook.ts'; + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIAuditLog { + webhooks: APIWebhook[]; + users: APIUser[]; + audit_log_entries: APIAuditLogEntry[]; + integrations: APIGuildIntegration[]; +} + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIAuditLogEntry { + target_id: string | null; + changes?: APIAuditLogChange[]; + user_id: string | null; + id: string; + action_type: AuditLogEvent; + options?: APIAuditLogOptions; + reason?: string; +} + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum AuditLogEvent { + GUILD_UPDATE = 1, + + CHANNEL_CREATE = 10, + CHANNEL_UPDATE, + CHANNEL_DELETE, + CHANNEL_OVERWRITE_CREATE, + CHANNEL_OVERWRITE_UPDATE, + CHANNEL_OVERWRITE_DELETE, + + MEMBER_KICK = 20, + MEMBER_PRUNE, + MEMBER_BAN_ADD, + MEMBER_BAN_REMOVE, + MEMBER_UPDATE, + MEMBER_ROLE_UPDATE, + MEMBER_MOVE, + MEMBER_DISCONNECT, + BOT_ADD, + + ROLE_CREATE = 30, + ROLE_UPDATE, + ROLE_DELETE, + + INVITE_CREATE = 40, + INVITE_UPDATE, + INVITE_DELETE, + + WEBHOOK_CREATE = 50, + WEBHOOK_UPDATE, + WEBHOOK_DELETE, + + EMOJI_CREATE = 60, + EMOJI_UPDATE, + EMOJI_DELETE, + + MESSAGE_DELETE = 72, + MESSAGE_BULK_DELETE, + MESSAGE_PIN, + MESSAGE_UNPIN, + + INTEGRATION_CREATE = 80, + INTEGRATION_UPDATE, + INTEGRATION_DELETE, +} + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIAuditLogOptions { + /** + * Present from: + * - MEMBER_PRUNE + */ + delete_member_days?: string; + /** + * Present from: + * - MEMBER_PRUNE + */ + members_removed?: string; + + /** + * Present from: + * - MEMBER_MOVE + * - MESSAGE_PIN + * - MESSAGE_UNPIN + * - MESSAGE_DELETE + */ + channel_id?: string; + + /** + * Present from: + * - MESSAGE_PIN + * - MESSAGE_UNPIN + */ + message_id?: string; + + /** + * Present from: + * - MESSAGE_DELETE + * - MESSAGE_BULK_DELETE + * - MEMBER_DISCONNECT + * - MEMBER_MOVE + */ + count?: string; + + /** + * Present from: + * - CHANNEL_OVERWRITE_CREATE + * - CHANNEL_OVERWRITE_UPDATE + * - CHANNEL_OVERWRITE_DELETE + */ + id?: string; + + /** + * Present from: + * - CHANNEL_OVERWRITE_CREATE + * - CHANNEL_OVERWRITE_UPDATE + * - CHANNEL_OVERWRITE_DELETE + */ + type: AuditLogOptionsType; + + /** + * Present from: + * - CHANNEL_OVERWRITE_CREATE + * - CHANNEL_OVERWRITE_UPDATE + * - CHANNEL_OVERWRITE_DELETE + * + * **Present only if the {@link APIAuditLogOptions#type entry type} is "role"** + */ + role_name?: string; +} + +/** + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum AuditLogOptionsType { + Member = 'member', + Role = 'role', +} + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChange = + | APIAuditLogChangeKeyName + | APIAuditLogChangeKeyIconHash + | APIAuditLogChangeKeySplashHash + | APIAuditLogChangeKeyOwnerID + | APIAuditLogChangeKeyRegion + | APIAuditLogChangeKeyAFKChannelID + | APIAuditLogChangeKeyAFKTimeout + | APIAuditLogChangeKeyMFALevel + | APIAuditLogChangeKeyVerificationLevel + | APIAuditLogChangeKeyExplicitContentFilter + | APIAuditLogChangeKeyDefaultMessageNotifications + | APIAuditLogChangeKeyVanityURLCode + | APIAuditLogChangeKey$Add + | APIAuditLogChangeKey$Remove + | APIAuditLogChangeKeyPruneDeleteDays + | APIAuditLogChangeKeyWidgetEnabled + | APIAuditLogChangeKeyWidgetChannelID + | APIAuditLogChangeKeySystemChannelID + | APIAuditLogChangeKeyPosition + | APIAuditLogChangeKeyTopic + | APIAuditLogChangeKeyBitrate + | APIAuditLogChangeKeyPermissionOverwrites + | APIAuditLogChangeKeyNSFW + | APIAuditLogChangeKeyApplicationID + | APIAuditLogChangeKeyRateLimitPerUser + | APIAuditLogChangeKeyPermissions + | APIAuditLogChangeKeyPermissionsNew + | APIAuditLogChangeKeyColor + | APIAuditLogChangeKeyHoist + | APIAuditLogChangeKeyMentionable + | APIAuditLogChangeKeyAllow + | APIAuditLogChangeKeyAllowNew + | APIAuditLogChangeKeyDeny + | APIAuditLogChangeKeyDenyNew + | APIAuditLogChangeKeyCode + | APIAuditLogChangeKeyChannelID + | APIAuditLogChangeKeyInviterID + | APIAuditLogChangeKeyMaxUses + | APIAuditLogChangeKeyUses + | APIAuditLogChangeKeyMaxAge + | APIAuditLogChangeKeyTemporary + | APIAuditLogChangeKeyDeaf + | APIAuditLogChangeKeyMute + | APIAuditLogChangeKeyNick + | APIAuditLogChangeKeyAvatarHash + | APIAuditLogChangeKeyID + | APIAuditLogChangeKeyType + | APIAuditLogChangeKeyEnableEmoticons + | APIAuditLogChangeKeyExpireBehavior + | APIAuditLogChangeKeyExpireGracePeriod; + +/** + * Returned when a guild's name is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyName = AuditLogChangeData<'name', string>; + +/** + * Returned when a guild's icon is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyIconHash = AuditLogChangeData<'icon_hash', string>; + +/** + * Returned when a guild's splash is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeySplashHash = AuditLogChangeData<'splash_hash', string>; + +/** + * Returned when a guild's owner ID is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyOwnerID = AuditLogChangeData<'owner_id', string>; + +/** + * Returned when a guild's region is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyRegion = AuditLogChangeData<'region', string>; + +/** + * Returned when a guild's afk_channel_id is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyAFKChannelID = AuditLogChangeData<'afk_channel_id', string>; + +/** + * Returned when a guild's afk_timeout is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyAFKTimeout = AuditLogChangeData<'afk_timeout', number>; + +/** + * Returned when a guild's mfa_level is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyMFALevel = AuditLogChangeData<'mfa_level', GuildMFALevel>; + +/** + * Returned when a guild's verification_level is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyVerificationLevel = AuditLogChangeData<'verification_level', GuildVerificationLevel>; + +/** + * Returned when a guild's explicit_content_filter is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyExplicitContentFilter = AuditLogChangeData< + 'explicit_content_filter', + GuildExplicitContentFilter +>; + +/** + * Returned when a guild's default_message_notifications is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyDefaultMessageNotifications = AuditLogChangeData< + 'default_message_notifications', + GuildDefaultMessageNotifications +>; + +/** + * Returned when a guild's vanity_url_code is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyVanityURLCode = AuditLogChangeData<'vanity_url_code', string>; + +/** + * Returned when new role(s) are added + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKey$Add = AuditLogChangeData<'$add', APIRole[]>; + +/** + * Returned when role(s) are removed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKey$Remove = AuditLogChangeData<'$remove', APIRole[]>; + +/** + * Returned when there is a change in number of days after which inactive and role-unassigned members are kicked + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyPruneDeleteDays = AuditLogChangeData<'prune_delete_days', number>; + +/** + * Returned when a guild's widget is enabled + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyWidgetEnabled = AuditLogChangeData<'widget_enabled', boolean>; + +/** + * Returned when a guild's widget_channel_id is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyWidgetChannelID = AuditLogChangeData<'widget_channel_id', string>; + +/** + * Returned when a guild's system_channel_id is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeySystemChannelID = AuditLogChangeData<'system_channel_id', string>; + +/** + * Returned when a channel's position is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyPosition = AuditLogChangeData<'position', number>; + +/** + * Returned when a channel's topic is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyTopic = AuditLogChangeData<'topic', string>; + +/** + * Returned when a voice channel's bitrate is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyBitrate = AuditLogChangeData<'bitrate', number>; + +/** + * Returned when a channel's permission overwrites is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyPermissionOverwrites = AuditLogChangeData<'permission_overwrites', APIOverwrite[]>; + +/** + * Returned when a channel's NSFW restriction is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyNSFW = AuditLogChangeData<'nsfw', boolean>; + +/** + * The application ID of the added or removed Webhook or Bot + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyApplicationID = AuditLogChangeData<'application_id', string>; + +/** + * Returned when a channel's amount of seconds a user has to wait before sending another message + * is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyRateLimitPerUser = AuditLogChangeData<'rate_limit_per_user', number>; + +/** + * Returned when a permission bitfield is changed + * @deprecated Use `permissions_new` instead + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyPermissions = AuditLogChangeData<'permissions', number>; + +/** + * Returned when a permission bitfield is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyPermissionsNew = AuditLogChangeData<'permissions_new', string>; + +/** + * Returned when a role's color is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyColor = AuditLogChangeData<'color', number>; + +/** + * Returned when a role's hoist status is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyHoist = AuditLogChangeData<'hoist', boolean>; + +/** + * Returned when a role's mentionable status is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyMentionable = AuditLogChangeData<'mentionable', boolean>; + +/** + * Returned when an overwrite's allowed permissions bitfield is changed + * @deprecated Use `allow_new` instead + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyAllow = AuditLogChangeData<'allow', number>; + +/** + * Returned when an overwrite's allowed permissions bitfield is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyAllowNew = AuditLogChangeData<'allow_new', string>; + +/** + * Returned when an overwrite's denied permissions bitfield is changed + * @deprecated Use `deny_new` instead + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyDeny = AuditLogChangeData<'deny', number>; + +/** + * Returned when an overwrite's denied permissions bitfield is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyDenyNew = AuditLogChangeData<'deny_new', string>; + +/** + * Returned when an invite's code is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyCode = AuditLogChangeData<'code', string>; + +/** + * Returned when an invite's channel_id is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyChannelID = AuditLogChangeData<'channel_id', string>; + +/** + * Returned when an invite's inviter_id is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyInviterID = AuditLogChangeData<'inviter_id', string>; + +/** + * Returned when an invite's max_uses is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyMaxUses = AuditLogChangeData<'max_uses', number>; + +/** + * Returned when an invite's uses is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyUses = AuditLogChangeData<'uses', number>; + +/** + * Returned when an invite's max_age is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyMaxAge = AuditLogChangeData<'max_age', number>; + +/** + * Returned when an invite's temporary status is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyTemporary = AuditLogChangeData<'temporary', boolean>; + +/** + * Returned when a user's deaf status is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyDeaf = AuditLogChangeData<'deaf', boolean>; + +/** + * Returned when a user's mute status is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyMute = AuditLogChangeData<'mute', boolean>; + +/** + * Returned when a user's nick is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyNick = AuditLogChangeData<'mute', boolean>; + +/** + * Returned when a user's avatar_hash is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyAvatarHash = AuditLogChangeData<'avatar_hash', string>; + +/** + * The ID of the changed entity - sometimes used in conjunction with other keys + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIAuditLogChangeKeyID { + key: 'id'; + new_value: string; + old_value?: string; +} + +/** + * The type of entity created + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', ChannelType | string>; + +/** + * Returned when an integration's enable_emoticons is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyEnableEmoticons = AuditLogChangeData<'enable_emoticons', boolean>; + +/** + * Returned when an integration's expire_behavior is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyExpireBehavior = AuditLogChangeData<'expire_behavior', IntegrationExpireBehavior>; + +/** + * Returned when an integration's expire_grace_period is changed + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIAuditLogChangeKeyExpireGracePeriod = AuditLogChangeData<'expire_grace_period', number>; + +/** + * @internal + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +interface AuditLogChangeData { + key: K; + new_value?: D; + old_value?: D; +} diff --git a/.deno/v6/payloads/channel.ts b/.deno/v6/payloads/channel.ts new file mode 100644 index 00000000..ecc02054 --- /dev/null +++ b/.deno/v6/payloads/channel.ts @@ -0,0 +1,343 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/channel + */ + +import type { APIPartialEmoji } from './emoji.ts'; +import type { APIGuildMember } from './guild.ts'; +import type { APIUser } from './user.ts'; + +/** + * Not documented, but partial only includes id, name, and type + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIPartialChannel { + id: string; + type: ChannelType; + name?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#channel-object-channel-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIChannel extends APIPartialChannel { + guild_id?: string; + position?: number; + permission_overwrites?: APIOverwrite[]; + name?: string; + topic?: string | null; + nsfw?: boolean; + last_message_id?: string | null; + bitrate?: number; + user_limit?: number; + rate_limit_per_user?: number; + recipients?: APIUser[]; + icon?: string | null; + owner_id?: string; + application_id?: string; + parent_id?: string | null; + last_pin_timestamp?: string | null; +} + +/** + * https://discord.com/developers/docs/resources/channel#channel-object-channel-types + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum ChannelType { + GUILD_TEXT = 0, + DM, + GUILD_VOICE, + GROUP_DM, + GUILD_CATEGORY, + GUILD_NEWS, + GUILD_STORE, +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIMessage { + id: string; + channel_id: string; + guild_id?: string; + author: APIUser; + member?: APIGuildMember; + content: string; + timestamp: string; + edited_timestamp: string | null; + tts: boolean; + mention_everyone: boolean; + mentions: (APIUser & { member?: Omit })[]; + mention_roles: string[]; + mention_channels?: APIChannelMention[]; + attachments: APIAttachment[]; + embeds: APIEmbed[]; + reactions?: APIReaction[]; + nonce?: string | number; + pinned: boolean; + webhook_id?: string; + type: MessageType; + activity?: APIMessageActivity; + application?: APIMessageApplication; + message_reference?: APIMessageReference; + flags?: MessageFlags; + referenced_message?: APIMessage | null; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-types + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum MessageType { + DEFAULT, + RECIPIENT_ADD, + RECIPIENT_REMOVE, + CALL, + CHANNEL_NAME_CHANGE, + CHANNEL_ICON_CHANGE, + CHANNEL_PINNED_MESSAGE, + GUILD_MEMBER_JOIN, + USER_PREMIUM_GUILD_SUBSCRIPTION, + USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1, + USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2, + USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3, + CHANNEL_FOLLOW_ADD, + GUILD_DISCOVERY_DISQUALIFIED = 14, + GUILD_DISCOVERY_REQUALIFIED, + GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING, + GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING, +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIMessageActivity { + type: MessageActivityType; + party_id?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-application-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIMessageApplication { + id: string; + cover_image?: string; + description: string; + icon: string | null; + name: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIMessageReference { + message_id?: string; + channel_id: string; + guild_id?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-activity-types + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum MessageActivityType { + JOIN = 1, + SPECTATE, + LISTEN, + JOIN_REQUEST = 5, +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-flags + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum MessageFlags { + CROSSPOSTED = 1 << 0, + IS_CROSSPOST = 1 << 1, + SUPPRESS_EMBEDS = 1 << 2, + SOURCE_MESSAGE_DELETED = 1 << 3, + URGENT = 1 << 4, +} + +/** + * https://discord.com/developers/docs/resources/channel#reaction-object-reaction-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIReaction { + count: number; + me: boolean; + emoji: APIPartialEmoji; +} + +/** + * https://discord.com/developers/docs/resources/channel#overwrite-object-overwrite-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIOverwrite { + id: string; + type: OverwriteType; + /** + * @deprecated Use `allow_new` instead + */ + allow: number; + allow_new: string; + /** + * @deprecated Use `deny_new` instead + */ + deny: number; + deny_new: string; +} + +/** + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum OverwriteType { + Member = 'member', + Role = 'role', +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIEmbed { + title?: string; + /** + * @deprecated *Embed types should be considered deprecated and might be removed in a future API version* + */ + type?: EmbedType; + description?: string; + url?: string; + timestamp?: string; + color?: number; + footer?: APIEmbedFooter; + image?: APIEmbedImage; + thumbnail?: APIEmbedThumbnail; + video?: APIEmbedVideo; + provider?: APIEmbedProvider; + author?: APIEmbedAuthor; + 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* + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum EmbedType { + Rich = 'rich', + Image = 'image', + Video = 'video', + GifV = 'gifv', + Article = 'article', + Link = 'link', +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIEmbedThumbnail { + url?: string; + proxy_url?: string; + height?: number; + width?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIEmbedVideo { + url?: string; + height?: number; + width?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIEmbedImage { + url?: string; + proxy_url?: string; + height?: number; + width?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIEmbedProvider { + name?: string; + url?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIEmbedAuthor { + name?: string; + url?: string; + icon_url?: string; + proxy_icon_url?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIEmbedFooter { + text: string; + icon_url?: string; + proxy_icon_url?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIEmbedField { + name: string; + value: string; + inline?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/channel#attachment-object-attachment-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIAttachment { + id: string; + filename: string; + size: number; + url: string; + proxy_url: string; + height: number | null; + width: number | null; +} + +/** + * https://discord.com/developers/docs/resources/channel#channel-mention-object-channel-mention-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIChannelMention { + id: string; + guild_id: string; + type: ChannelType; + name: string; +} + +/** + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIFollowedChannel { + channel_id: string; + webhook_id: string; +} diff --git a/.deno/v6/payloads/emoji.ts b/.deno/v6/payloads/emoji.ts new file mode 100644 index 00000000..080ad01e --- /dev/null +++ b/.deno/v6/payloads/emoji.ts @@ -0,0 +1,27 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/emoji + */ + +import type { APIUser } from './user.ts'; + +/** + * Not documented but mentioned + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIPartialEmoji { + id: string | null; + name: string | null; + animated?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIEmoji extends APIPartialEmoji { + roles?: string[]; + user?: APIUser; + require_colons?: boolean; + managed?: boolean; + available?: boolean; +} diff --git a/.deno/v6/payloads/gateway.ts b/.deno/v6/payloads/gateway.ts new file mode 100644 index 00000000..51619ef9 --- /dev/null +++ b/.deno/v6/payloads/gateway.ts @@ -0,0 +1,154 @@ +/** + * Types extracted from https://discord.com/developers/docs/topics/gateway + */ + +import type { APIEmoji } from './emoji.ts'; +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/topics/gateway#get-gateway + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIGatewayInfo { + url: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#get-gateway-bot + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIGatewayBotInfo extends APIGatewayInfo { + shards: number; + session_start_limit: APIGatewaySessionStartLimit; +} + +/** + * https://discord.com/developers/docs/topics/gateway#session-start-limit-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIGatewaySessionStartLimit { + total: number; + remaining: number; + reset_after: number; +} + +/** + * https://discord.com/developers/docs/topics/gateway#presence-update-presence-update-event-fields + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayPresenceUpdate { + user: Partial & { + id: string; + }; + roles?: string[]; + game?: GatewayActivity | null; + guild_id?: string; + status?: PresenceUpdateStatus; + activities?: GatewayActivity[]; + client_status?: GatewayPresenceClientStatus; + premium_since?: string | null; + nick?: string | null; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export enum PresenceUpdateStatus { + DoNotDisturb = 'dnd', + Idle = 'idle', + Invisible = 'invisible', + Offline = 'offline', + Online = 'online', +} + +/** + * https://discord.com/developers/docs/topics/gateway#client-status-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayPresenceClientStatus = Partial>; + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayActivity { + name: string; + type: ActivityType; + url?: string | null; + created_at: number; + timestamps?: GatewayActivityTimestamps; + application_id?: string; + details?: string | null; + state?: string | null; + emoji?: GatewayActivityEmoji; + party?: GatewayActivityParty; + assets?: GatewayActivityAssets; + secrets?: GatewayActivitySecrets; + instance?: boolean; + flags?: ActivityFlags; +} + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-types + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum ActivityType { + Game, + Streaming, + Listening, + + Custom = 4, + Competing, +} + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-timestamps + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayActivityTimestamps { + start?: number; + end?: number; +} + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayActivityEmoji = Partial> & Pick; + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-party + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayActivityParty { + id?: string; + // eslint-disable-next-line prettier/prettier + size?: [currentSize: number, maxSize: number]; +} + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-assets + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayActivityAssets = Partial< + Record<'large_image' | 'large_text' | 'small_image' | 'small_text', string> +>; + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-secrets + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type GatewayActivitySecrets = Partial>; + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum ActivityFlags { + INSTANCE = 1 << 0, + JOIN = 1 << 1, + SPECTATE = 1 << 2, + JOIN_REQUEST = 1 << 3, + SYNC = 1 << 4, + PLAY = 1 << 5, +} diff --git a/.deno/v6/payloads/guild.ts b/.deno/v6/payloads/guild.ts new file mode 100644 index 00000000..0d04242a --- /dev/null +++ b/.deno/v6/payloads/guild.ts @@ -0,0 +1,315 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/guild + */ + +import type { APIChannel } from './channel.ts'; +import type { APIEmoji } from './emoji.ts'; +import type { GatewayPresenceUpdate } from './gateway.ts'; +import type { APIRole } from './permissions.ts'; +import type { APIUser } from './user.ts'; +import type { GatewayVoiceState } from './voice.ts'; + +/** + * https://discord.com/developers/docs/resources/guild#unavailable-guild-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIUnavailableGuild { + id: string; + unavailable: boolean; +} + +/** + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIPartialGuild extends Omit, Pick { + name: string; + icon: string | null; + splash: string | null; + banner?: string | null; + description?: string | null; + features?: GuildFeature[]; + verification_level?: GuildVerificationLevel; + vanity_url_code?: string | null; + unavailable?: boolean; +} + +/** + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIGuild extends APIPartialGuild { + discovery_splash: string | null; + owner?: boolean; + owner_id: string; + /** + * @deprecated Use `permissions_new` instead + */ + permissions?: number; + permissions_new?: string; + region: string; + afk_channel_id: string | null; + afk_timeout: number; + /** + * @deprecated Use `widget_enabled` instead + */ + embed_enabled?: boolean; + /** + * @deprecated Use `widget_channel_id` instead + */ + embed_channel_id?: string | null; + verification_level: GuildVerificationLevel; + default_message_notifications: GuildDefaultMessageNotifications; + explicit_content_filter: GuildExplicitContentFilter; + roles: APIRole[]; + emojis: APIEmoji[]; + features: GuildFeature[]; + mfa_level: GuildMFALevel; + application_id: string | null; + widget_enabled?: boolean; + widget_channel_id?: string | null; + system_channel_id: string | null; + system_channel_flags: GuildSystemChannelFlags; + rules_channel_id: string | null; + joined_at?: string; + large?: boolean; + member_count?: number; + voice_states?: Omit[]; + members?: APIGuildMember[]; + channels?: APIChannel[]; + presences?: GatewayPresenceUpdate[]; + max_presences?: number | null; + max_members?: number; + vanity_url_code: string | null; + description: string | null; + banner: string | null; + premium_tier: GuildPremiumTier; + premium_subscription_count?: number; + preferred_locale: string; + public_updates_channel_id: string | null; + max_video_channel_users?: number; + /** + * Returned by calling GET `/guilds/{guild.id}` with the query `with_counts` set to `true` + */ + approximate_member_count?: number; + /** + * Returned by calling GET `/guilds/{guild.id}` with the query `with_counts` set to `true` + */ + approximate_presence_count?: number; + welcome_screen?: APIGuildWelcomeScreen; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum GuildDefaultMessageNotifications { + ALL_MESSAGES, + ONLY_MENTIONS, +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum GuildExplicitContentFilter { + DISABLED, + MEMBERS_WITHOUT_ROLES, + ALL_MEMBERS, +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-mfa-level + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum GuildMFALevel { + NONE, + ELEVATED, +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-verification-level + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum GuildVerificationLevel { + NONE, + LOW, + MEDIUM, + HIGH, + VERY_HIGH, +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-premium-tier + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum GuildPremiumTier { + NONE, + TIER_1, + TIER_2, + TIER_3, +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum GuildSystemChannelFlags { + SUPPRESS_JOIN_NOTIFICATIONS = 1 << 0, + SUPPRESS_PREMIUM_SUBSCRIPTIONS = 1 << 1, +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-guild-features + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum GuildFeature { + ANIMATED_ICON = 'ANIMATED_ICON', + BANNER = 'BANNER', + COMMERCE = 'COMMERCE', + COMMUNITY = 'COMMUNITY', + DISCOVERABLE = 'DISCOVERABLE', + FEATURABLE = 'FEATURABLE', + INVITE_SPLASH = 'INVITE_SPLASH', + NEWS = 'NEWS', + PARTNERED = 'PARTNERED', + RELAY_ENABLED = 'RELAY_ENABLED', + VANITY_URL = 'VANITY_URL', + VERIFIED = 'VERIFIED', + VIP_REGIONS = 'VIP_REGIONS', + WELCOME_SCREEN_ENABLED = 'WELCOME_SCREEN_ENABLED', +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-preview-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIGuildPreview { + id: string; + name: string; + icon: string | null; + splash: string | null; + discovery_splash: string | null; + emojis: APIEmoji[]; + features: GuildFeature[]; + approximate_member_count: number; + approximate_presence_count: number; +} + +/** + * @deprecated Use `APIGuildWidgetSettings` instead + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export type APIGuildWidget = APIGuildWidgetSettings; + +/** + * https://discord.com/developers/docs/resources/guild#guild-widget-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIGuildWidgetSettings { + enabled: boolean; + channel_id: string | null; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-member-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIGuildMember { + user?: APIUser; + nick: string | null; + roles: string[]; + joined_at: string; + premium_since?: string | null; + deaf: boolean; + mute: boolean; +} + +/** + * https://discord.com/developers/docs/resources/guild#integration-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIGuildIntegration { + id: string; + name: string; + type: string; + enabled: boolean; + syncing: boolean; + role_id: string; + enable_emoticons?: boolean; + expire_behavior: IntegrationExpireBehavior; + expire_grace_period: number; + user?: APIUser; + account: APIIntegrationAccount; + synced_at: string; + subscriber_count: number; + revoked: boolean; + application?: APIGuildIntegrationApplication; +} + +/** + * https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum IntegrationExpireBehavior { + RemoveRole, + Kick, +} + +/** + * https://discord.com/developers/docs/resources/guild#integration-account-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIIntegrationAccount { + id: string; + name: string; +} + +/** + * https://discord.com/developers/docs/resources/guild#integration-application-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIGuildIntegrationApplication { + id: string; + name: string; + icon: string | null; + description: string; + summary: string; + bot?: APIUser; +} + +/** + * https://discord.com/developers/docs/resources/guild#ban-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIBan { + reason: string | null; + user: APIUser; +} + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-widget-image-widget-style-options + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum GuildWidgetStyle { + Banner1 = 'banner1', + Banner2 = 'banner2', + Banner3 = 'banner3', + Banner4 = 'banner4', + Shield = 'shield', +} + +/** + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIGuildWelcomeScreen { + description: string | null; + welcome_channels: APIGuildWelcomeScreenChannel[]; +} + +/** + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIGuildWelcomeScreenChannel { + channel_id: string; + emoji_id: string | null; + emoji_name: string | null; +} diff --git a/.deno/v6/payloads/invite.ts b/.deno/v6/payloads/invite.ts new file mode 100644 index 00000000..70b00433 --- /dev/null +++ b/.deno/v6/payloads/invite.ts @@ -0,0 +1,42 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/invite + */ + +import type { APIPartialChannel } from './channel.ts'; +import type { APIPartialGuild } from './guild.ts'; +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/resources/invite#invite-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIInvite { + code: string; + guild?: APIPartialGuild; + channel?: Required; + inviter?: APIUser; + target_user?: APIUser; + target_user_type?: InviteTargetUserType; + approximate_presence_count?: number; + approximate_member_count?: number; +} + +/** + * https://discord.com/developers/docs/resources/invite#invite-object-target-user-types + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum InviteTargetUserType { + STREAM = 1, +} + +/** + * https://discord.com/developers/docs/resources/invite#invite-metadata-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIExtendedInvite extends APIInvite { + uses: number; + max_uses: number; + max_age: number; + temporary: boolean; + created_at: string; +} diff --git a/.deno/v6/payloads/mod.ts b/.deno/v6/payloads/mod.ts new file mode 100644 index 00000000..6abce8f7 --- /dev/null +++ b/.deno/v6/payloads/mod.ts @@ -0,0 +1,12 @@ +export * from './auditLog.ts'; +export * from './channel.ts'; +export * from './emoji.ts'; +export * from './gateway.ts'; +export * from './guild.ts'; +export * from './invite.ts'; +export * from './oauth2.ts'; +export * from './permissions.ts'; +export * from './teams.ts'; +export * from './user.ts'; +export * from './voice.ts'; +export * from './webhook.ts'; diff --git a/.deno/v6/payloads/oauth2.ts b/.deno/v6/payloads/oauth2.ts new file mode 100644 index 00000000..8df49335 --- /dev/null +++ b/.deno/v6/payloads/oauth2.ts @@ -0,0 +1,28 @@ +/** + * Types extracted from https://discord.com/developers/docs/topics/oauth2 + */ + +import type { APITeam } from './teams.ts'; +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/topics/oauth2#get-current-application-information-response-structure + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIApplication { + id: string; + name: string; + icon: string | null; + description: string; + rpc_origins?: string[]; + bot_public: boolean; + bot_require_code_grant: boolean; + owner: APIUser; + summary: string; + verify_key: string; + team: APITeam | null; + guild_id?: string; + primary_sku_id?: string; + slug?: string; + cover_image?: string; +} diff --git a/.deno/v6/payloads/permissions.ts b/.deno/v6/payloads/permissions.ts new file mode 100644 index 00000000..34998f84 --- /dev/null +++ b/.deno/v6/payloads/permissions.ts @@ -0,0 +1,81 @@ +/** + * Types extracted from https://discord.com/developers/docs/topics/permissions + */ + +/** + * https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags + * + * These flags are exported as `BigInt`s and NOT numbers. For most of them, you can + * convert them in a number by wrapping it in `Number()`, however be careful as any + * further bits added may cause issues if done so. Try to use BigInts as much as possible + * or modules that can replicate them in some way. + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export const PermissionFlagsBits = { + CREATE_INSTANT_INVITE: 1n, + KICK_MEMBERS: 2n, + BAN_MEMBERS: 4n, + ADMINISTRATOR: 8n, + MANAGE_CHANNELS: 16n, + MANAGE_GUILD: 32n, + ADD_REACTIONS: 64n, + VIEW_AUDIT_LOG: 128n, + PRIORITY_SPEAKER: 256n, + STREAM: 512n, + VIEW_CHANNEL: 1024n, + SEND_MESSAGES: 2048n, + SEND_TTS_MESSAGES: 4096n, + MANAGE_MESSAGES: 8192n, + EMBED_LINKS: 16384n, + ATTACH_FILES: 32768n, + READ_MESSAGE_HISTORY: 65536n, + MENTION_EVERYONE: 131072n, + USE_EXTERNAL_EMOJIS: 262144n, + VIEW_GUILD_INSIGHTS: 524288n, + CONNECT: 1048576n, + SPEAK: 2097152n, + MUTE_MEMBERS: 4194304n, + DEAFEN_MEMBERS: 8388608n, + MOVE_MEMBERS: 16777216n, + USE_VAD: 33554432n, + CHANGE_NICKNAME: 67108864n, + MANAGE_NICKNAMES: 134217728n, + MANAGE_ROLES: 268435456n, + MANAGE_WEBHOOKS: 536870912n, + MANAGE_EMOJIS: 1073741824n, +} as const; + +/** + * Freeze the object of bits, preventing any modifications to it. + * @internal + */ +Object.freeze(PermissionFlagsBits); + +/** + * https://discord.com/developers/docs/topics/permissions#role-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIRole { + id: string; + name: string; + color: number; + hoist: boolean; + position: number; + /** + * @deprecated Use `permissions_new` instead + */ + permissions: number; + permissions_new: string; + managed: boolean; + mentionable: boolean; + tags?: APIRoleTags; +} + +/** + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIRoleTags { + bot_id?: string; + premium_subscriber?: null; + integration_id?: string; +} diff --git a/.deno/v6/payloads/teams.ts b/.deno/v6/payloads/teams.ts new file mode 100644 index 00000000..d4968381 --- /dev/null +++ b/.deno/v6/payloads/teams.ts @@ -0,0 +1,36 @@ +/** + * Types extracted from https://discord.com/developers/docs/topics/teams + */ + +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/topics/teams#data-models-team-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APITeam { + id: string; + icon: string | null; + members: APITeamMember[]; + owner_user_id: string; +} + +/** + * https://discord.com/developers/docs/topics/teams#data-models-team-members-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APITeamMember { + membership_state: TeamMemberMembershipState; + permissions: string[]; + team_id: string; + user: APIUser; +} + +/** + * https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum TeamMemberMembershipState { + INVITED = 1, + ACCEPTED, +} diff --git a/.deno/v6/payloads/user.ts b/.deno/v6/payloads/user.ts new file mode 100644 index 00000000..58a0fa4f --- /dev/null +++ b/.deno/v6/payloads/user.ts @@ -0,0 +1,80 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/user + */ + +import type { APIGuildIntegration } from './guild.ts'; + +/** + * https://discord.com/developers/docs/resources/user#user-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIUser { + id: string; + username: string; + discriminator: string; + avatar: string | null; + bot?: boolean; + system?: boolean; + mfa_enabled?: boolean; + locale?: string; + verified?: boolean; + email?: string | null; + flags?: UserFlags; + premium_type?: UserPremiumType; + public_flags?: UserFlags; +} + +/** + * https://discord.com/developers/docs/resources/user#user-object-user-flags + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum UserFlags { + None = 0, + DiscordEmployee = 1 << 0, + PartneredServerOwner = 1 << 1, + DiscordHypeSquadEvents = 1 << 2, + BugHunterLevel1 = 1 << 3, + HypeSquadHouseBravery = 1 << 6, + HypeSquadHouseBrilliance = 1 << 7, + HypeSquadHouseBalance = 1 << 8, + EarlySupporter = 1 << 9, + TeamUser = 1 << 10, + System = 1 << 12, + BugHunterLevel2 = 1 << 14, + VerifiedBot = 1 << 16, + EarlyVerifiedBotDeveloper = 1 << 17, +} + +/** + * https://discord.com/developers/docs/resources/user#user-object-premium-types + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum UserPremiumType { + None, + NitroClassic, + Nitro, +} + +/** + * https://discord.com/developers/docs/resources/user#connection-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIConnection { + id: string; + name: string; + type: string; + revoked?: boolean; + integrations?: Partial[]; + verified: boolean; + friend_sync: boolean; + show_activity: boolean; + visibility: ConnectionVisibility; +} + +/** + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum ConnectionVisibility { + None, + Everyone, +} diff --git a/.deno/v6/payloads/voice.ts b/.deno/v6/payloads/voice.ts new file mode 100644 index 00000000..a8a57384 --- /dev/null +++ b/.deno/v6/payloads/voice.ts @@ -0,0 +1,37 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/voice + */ + +import type { APIGuildMember } from './guild.ts'; + +/** + * https://discord.com/developers/docs/resources/voice#voice-state-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface GatewayVoiceState { + guild_id?: string; + channel_id: string | null; + user_id: string; + member?: APIGuildMember; + session_id: string; + deaf: boolean; + mute: boolean; + self_deaf: boolean; + self_mute: boolean; + self_stream?: boolean; + self_video: boolean; + suppress: boolean; +} + +/** + * https://discord.com/developers/docs/resources/voice#voice-region-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIVoiceRegion { + id: string; + name: string; + vip: boolean; + optimal: boolean; + deprecated: boolean; + custom: boolean; +} diff --git a/.deno/v6/payloads/webhook.ts b/.deno/v6/payloads/webhook.ts new file mode 100644 index 00000000..21b9b75e --- /dev/null +++ b/.deno/v6/payloads/webhook.ts @@ -0,0 +1,33 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/webhook + */ + +import type { APIPartialChannel } from './channel.ts'; +import type { APIPartialGuild } from './guild.ts'; +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/resources/webhook#webhook-object + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIWebhook { + id: string; + type: WebhookType; + guild_id?: string; + channel_id: string; + user?: APIUser; + name: string | null; + avatar: string | null; + token?: string; + source_guild?: APIPartialGuild; + source_channel?: APIPartialChannel; + application_id: string | null; +} + +/** + * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8. + */ +export enum WebhookType { + Incoming = 1, + ChannelFollower, +} diff --git a/.deno/v6/rest/auditLog.ts b/.deno/v6/rest/auditLog.ts new file mode 100644 index 00000000..61dde45a --- /dev/null +++ b/.deno/v6/rest/auditLog.ts @@ -0,0 +1,17 @@ +import type { APIAuditLog, AuditLogEvent } from '../payloads/auditLog.ts'; + +/** + * https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTGetAPIAuditLogQuery { + user_id?: string; + action_type?: AuditLogEvent; + before?: string; + limit?: number; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIAuditLogResult = APIAuditLog; diff --git a/.deno/v6/rest/channel.ts b/.deno/v6/rest/channel.ts new file mode 100644 index 00000000..59c11edb --- /dev/null +++ b/.deno/v6/rest/channel.ts @@ -0,0 +1,310 @@ +import type { + APIChannel, + APIEmbed, + APIFollowedChannel, + APIInvite, + APIMessage, + APIMessageReference, + APIOverwrite, + APIUser, + ChannelType, + InviteTargetUserType, + MessageFlags, + OverwriteType, +} from '../payloads/mod.ts'; + +// #region TypeDefs + +/** + * https://discord.com/developers/docs/resources/channel#overwrite-object-overwrite-structure + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIOverwriteSend { + id: string; + type: OverwriteType; + allow: number | string; + deny: number | string; +} + +/** + * https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export enum AllowedMentionsTypes { + Everyone = 'everyone', + Role = 'roles', + User = 'users', +} + +/** + * https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mentions-structure + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIAllowedMentionsSend { + parse?: AllowedMentionsTypes[]; + roles?: string[]; + users?: string[]; +} + +// #endregion TypeDefs + +/** + * https://discord.com/developers/docs/resources/channel#modify-channel + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPatchAPIChannelJSONBody { + name?: string; + type?: ChannelType.GUILD_NEWS | ChannelType.GUILD_TEXT; + position?: number | null; + topic?: string | null; + nsfw?: boolean | null; + rate_limit_per_user?: number | null; + user_limit?: number | null; + permission_overwrites?: APIOverwrite[] | null; + parent_id?: string | null; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIChannelResult = APIChannel; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIChannelResult = APIChannel; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIChannelResult = APIChannel; + +/** + * https://discord.com/developers/docs/resources/channel#get-channel-messages + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTGetAPIChannelMessagesQuery { + around?: string; + before?: string; + after?: string; + limit?: number; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIChannelMessagesResult = APIMessage[]; + +/** + * https://discord.com/developers/docs/resources/channel#create-message + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostAPIChannelMessageJSONBody { + content?: string; + nonce?: number | string; + tts?: boolean; + embed?: APIEmbed; + allowed_mentions?: APIAllowedMentionsSend; + message_reference?: APIMessageReference; +} + +/** + * https://discord.com/developers/docs/resources/channel#create-message + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIChannelMessageFormDataBody = + | { + /** + * JSON stringified message body + */ + payload_json?: string; + /** + * The file contents + */ + file: unknown; + } + | { + content?: string; + nonce?: number | string; + tts?: boolean; + embed?: APIEmbed; + allowed_mentions?: APIAllowedMentionsSend; + message_reference?: APIMessageReference; + /** + * The file contents + */ + file: unknown; + }; + +/** + * https://discord.com/developers/docs/resources/channel#edit-message + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPatchAPIChannelMessageJSONBody { + content?: string | null; + embed?: APIEmbed | null; + allowed_mentions?: APIAllowedMentionsSend | null; + flags?: MessageFlags | null; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIChannelMessageResult = APIMessage; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIChannelMessageResult = APIMessage; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIChannelMessageResult = APIMessage; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIChannelMessageResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#get-reactions + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTGetAPIChannelMessageReactionsQuery { + before?: string; + after?: string; + limit?: number; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIChannelMessageReactionsResult = APIUser[]; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPutAPIChannelMessageReactionResult = never; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIChannelMessageReactionResult = never; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIChannelAllMessageReactionsResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#bulk-delete-messages + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostAPIChannelMessagesBulkDeleteJSONBody { + messages: string[]; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIChannelMessagesBulkDeleteResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#edit-channel-permissions + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPutAPIChannelPermissionsJSONBody { + allow: number | string; + deny: number | string; + type: OverwriteType; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPutAPIChannelPermissionsResult = never; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIChannelPermissionsResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#get-channel-invites + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIChannelInvitesResult = APIInvite[]; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostAPIChannelInviteJSONBody { + max_age?: number; + max_uses?: number; + temporary?: boolean; + unique?: boolean; + target_user_id?: string; + target_user_type?: InviteTargetUserType; +} + +/** + * https://discord.com/developers/docs/resources/channel#trigger-typing-indicator + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIChannelTypingResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#get-pinned-messages + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIChannelPinsResult = APIMessage[]; + +/** + * https://discord.com/developers/docs/resources/channel#add-pinned-channel-message + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPutAPIChannelPinResult = never; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIChannelPinResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#group-dm-add-recipient + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPutAPIChannelRecipientJSONBody { + access_token: string; + nick?: string; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPutAPIChannelRecipientResult = unknown; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIChannelRecipientResult = unknown; + +// TODO: Docs updated once https://github.com/discord/discord-api-docs/pull/1692/files is merged + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIChannelMessageCrosspostResult = APIMessage; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostAPIChannelFollowersJSONBody { + webhook_channel_id: string; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIChannelFollowersResult = APIFollowedChannel; diff --git a/.deno/v6/rest/emoji.ts b/.deno/v6/rest/emoji.ts new file mode 100644 index 00000000..91abcb76 --- /dev/null +++ b/.deno/v6/rest/emoji.ts @@ -0,0 +1,51 @@ +import type { APIEmoji } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/emoji#list-guild-emojis + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildEmojisResult = APIEmoji[]; + +/** + * https://discord.com/developers/docs/resources/emoji#get-guild-emoji + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildEmojiResult = APIEmoji; + +/** + * https://discord.com/developers/docs/resources/emoji#create-guild-emoji-json-params + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostAPIGuildEmojiJSONBody { + name: string; + /** + * The image data, read more [here](https://discord.com/developers/docs/reference#image-data) + */ + image: string; + roles?: string[]; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIGuildEmojiResult = APIEmoji; + +/** + * https://discord.com/developers/docs/resources/emoji#modify-guild-emoji + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPatchAPIGuildEmojiJSONBody { + name?: string; + roles?: string[] | null; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIGuildEmojiResult = APIEmoji; + +/** + * https://discord.com/developers/docs/resources/emoji#delete-guild-emoji + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIGuildEmojiResult = never; diff --git a/.deno/v6/rest/gateway.ts b/.deno/v6/rest/gateway.ts new file mode 100644 index 00000000..b395eeae --- /dev/null +++ b/.deno/v6/rest/gateway.ts @@ -0,0 +1,13 @@ +import type { APIGatewayBotInfo, APIGatewayInfo } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/topics/gateway#get-gateway + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGatewayResult = APIGatewayInfo; + +/** + * https://discord.com/developers/docs/topics/gateway#get-gateway-bot + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGatewayBotResult = APIGatewayBotInfo; diff --git a/.deno/v6/rest/guild.ts b/.deno/v6/rest/guild.ts new file mode 100644 index 00000000..a0a46c29 --- /dev/null +++ b/.deno/v6/rest/guild.ts @@ -0,0 +1,516 @@ +import type { + APIBan, + APIChannel, + APIGuild, + APIGuildIntegration, + APIGuildMember, + APIGuildPreview, + APIGuildWidgetSettings, + APIInvite, + APIRole, + APIVoiceRegion, + GuildDefaultMessageNotifications, + GuildExplicitContentFilter, + GuildFeature, + GuildVerificationLevel, + GuildWidgetStyle, + IntegrationExpireBehavior, +} from '../payloads/mod.ts'; +import type { RESTPutAPIChannelPermissionsJSONBody } from './channel.ts'; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionsJSONBody { + id: number | string; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type APIGuildCreatePartialChannel = Partial< + Pick +> & { + name: string; + id?: number | string; + parent_id?: number | string; + permission_overwrites?: APIGuildCreateOverwrite[]; +}; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface APIGuildCreateRole extends RESTPostAPIGuildRoleJSONBody { + id: number | string; +} + +/** + * https://discord.com/developers/docs/resources/guild#create-guild + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostAPIGuildsJSONBody { + name: string; + region?: string; + icon?: string; + verification_level?: GuildVerificationLevel; + default_message_notifications?: GuildDefaultMessageNotifications; + explicit_content_filter?: GuildExplicitContentFilter; + roles?: APIGuildCreateRole[]; + channels?: APIGuildCreatePartialChannel[]; + afk_channel_id?: number | string; + afk_timeout?: number; + system_channel_id?: number | string; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIGuildsResult = APIGuild; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTGetAPIGuildQuery { + with_counts?: boolean; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildResult = APIGuild; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-preview + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildPreviewResult = APIGuildPreview; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPatchAPIGuildJSONBody { + name?: string; + region?: string; + verification_level?: GuildVerificationLevel; + default_message_notifications?: GuildDefaultMessageNotifications; + explicit_content_filter?: GuildExplicitContentFilter; + afk_channel_id?: string | null; + afk_timeout?: number; + icon?: string | null; + owner_id?: string; + splash?: string | null; + discovery_splash?: string | null; + banner?: string | null; + system_channel_id?: string | null; + rules_channel_id?: string | null; + public_updates_channel_id?: string | null; + preferred_locale?: string; + features?: GuildFeature[]; + description?: string | null; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIGuildResult = APIGuild; + +/** + * https://discord.com/developers/docs/resources/guild#delete-guild + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIGuildResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-channels + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildChannelsResult = APIChannel[]; + +/** + * https://discord.com/developers/docs/resources/guild#create-guild-channel + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIGuildChannelJSONBody = Partial< + Pick< + APIChannel, + 'type' | 'permission_overwrites' | 'topic' | 'nsfw' | 'bitrate' | 'user_limit' | 'rate_limit_per_user' | 'parent_id' + > +> & + Required>; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIGuildChannelResult = APIChannel; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{ + id: string; + position: number; + lock_permissions?: boolean; + parent_id?: string | null; +}>; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIGuildChannelPositionsResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-member + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildMemberResult = APIGuildMember; + +/** + * https://discord.com/developers/docs/resources/guild#list-guild-members + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTGetAPIGuildMembersQuery { + limit?: number; + after?: string; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildMembersResult = APIGuildMember[]; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTGetAPIGuildMembersSearchQuery { + query: string; + limit?: number; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildMembersSearchResult = APIGuildMember[]; + +/** + * https://discord.com/developers/docs/resources/guild#add-guild-member + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPutAPIGuildMemberJSONBody { + access_token: string; + nick?: string; + roles?: string[]; + mute?: boolean; + deaf?: boolean; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPutAPIGuildMemberResult = APIGuildMember | undefined; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-member + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPatchAPIGuildMemberJSONBody { + nick?: string | null; + roles?: string[] | null; + mute?: boolean | null; + deaf?: boolean | null; + channel_id?: string | null; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIGuildMemberResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#modify-current-user-nick + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPatchAPICurrentGuildMemberNicknameJSONBody { + nick?: string | null; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPICurrentGuildMemberNicknameResult = Required; + +/** + * https://discord.com/developers/docs/resources/guild#add-guild-member-role + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPutAPIGuildMemberRoleResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#remove-guild-member-role + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIGuildMemberRoleResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#remove-guild-member + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIGuildMemberResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-bans + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildBansResult = APIBan[]; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-ban + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildBanResult = APIBan; + +/** + * https://discord.com/developers/docs/resources/guild#create-guild-ban + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPutAPIGuildBanJSONBody { + delete_message_days?: number; + reason?: string; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPutAPIGuildBanResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#remove-guild-ban + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIGuildBanResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-roles + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildRolesResult = APIRole[]; + +/** + * https://discord.com/developers/docs/resources/guild#create-guild-role + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostAPIGuildRoleJSONBody { + name?: string | null; + permissions?: number | string | null; + color?: number | null; + hoist?: boolean | null; + mentionable?: boolean | null; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIGuildRoleResult = APIRole; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-role-positions + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIGuildRolePositionsJSONBody = Array<{ + id: string; + position?: number; +}>; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIGuildRolePositionsResult = APIRole[]; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-role + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPatchAPIGuildRoleJSONBody { + name?: string; + permissions?: number | string; + color?: number; + hoist?: boolean; + mentionable?: boolean; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIGuildRoleResult = APIRole; + +/** + * https://discord.com/developers/docs/resources/guild#delete-guild-role + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIGuildRoleResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-prune-count + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTGetAPIGuildPruneCountQuery { + days?: number; + /** + * While this is typed as a string, it represents an array of + * role IDs delimited by commas. + * + * @see https://discord.com/developers/docs/resources/guild#get-guild-prune-count-query-string-params + */ + include_roles?: string; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTGetAPIGuildPruneCountResult { + pruned: number; +} + +/** + * https://discord.com/developers/docs/resources/guild#begin-guild-prune + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostAPIGuildPruneJSONBody { + days?: number; + compute_prune_count?: boolean; + include_roles?: string[]; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostAPIGuildPruneResult { + pruned: number | null; +} + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-voice-regions + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildVoiceRegionsResult = APIVoiceRegion[]; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-invites + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildInvitesResult = APIInvite[]; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-integrations + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTGetAPIGuildIntegrationsQuery { + include_applications?: boolean; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildIntegrationsResult = APIGuildIntegration[]; + +/** + * https://discord.com/developers/docs/resources/guild#create-guild-integration + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostAPIGuildIntegrationJSONBody { + type: string; + id: string; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIGuildIntegrationResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-integration + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPatchAPIGuildIntegrationJSONBody { + expire_behavior?: IntegrationExpireBehavior | null; + expire_grace_period?: number | null; + enable_emoticons?: boolean | null; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIGuildIntegrationResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#delete-guild-integration + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIGuildIntegrationResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#sync-guild-integration + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIGuildIntegrationSyncResult = never; + +/** + * @deprecated Renamed to RESTGetAPIGuildWidgetSettingsResult + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildWidgetResult = APIGuildWidgetSettings; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-widget-settings + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildWidgetSettingsResult = APIGuildWidgetSettings; + +/** + * @deprecated Renamed to RESTPatchAPIGuildWidgetSettingsJSONBody + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIGuildWidgetJSONBody = Partial; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-widget + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIGuildWidgetSettingsJSONBody = Partial; + +/** + * @deprecated Use `RESTPatchAPIGuildWidgetSettingsResult` instead + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIGuildWidgetResult = APIGuildWidgetSettings; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIGuildWidgetSettingsResult = APIGuildWidgetSettings; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-vanity-url + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTGetAPIGuildVanityUrlResult { + code: string | null; + uses: number; +} + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-widget-image + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTGetAPIGuildWidgetImageQuery { + style?: GuildWidgetStyle; +} + +/** + * Note: while the return type is `ArrayBuffer`, the expected result is + * a buffer of sorts (depends if in browser or on node.js/deno). + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildWidgetImageResult = ArrayBuffer; diff --git a/.deno/v6/rest/invite.ts b/.deno/v6/rest/invite.ts new file mode 100644 index 00000000..4e90f0f0 --- /dev/null +++ b/.deno/v6/rest/invite.ts @@ -0,0 +1,20 @@ +import type { APIInvite } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/invite#get-invite + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTGetAPIInviteQuery { + with_counts?: boolean; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIInviteResult = APIInvite; + +/** + * https://discord.com/developers/docs/resources/invite#delete-invite + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIInviteResult = APIInvite; diff --git a/.deno/v6/rest/mod.ts b/.deno/v6/rest/mod.ts new file mode 100644 index 00000000..b2bdf620 --- /dev/null +++ b/.deno/v6/rest/mod.ts @@ -0,0 +1,519 @@ +export * from './auditLog.ts'; +export * from './channel.ts'; +export * from './emoji.ts'; +export * from './gateway.ts'; +export * from './guild.ts'; +export * from './invite.ts'; +export * from './oauth2.ts'; +export * from './user.ts'; +export * from './voice.ts'; +export * from './webhook.ts'; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export const APIVersion = '6'; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export const Routes = { + /** + * Route for: + * - GET `/guilds/{guild.id}/audit-logs` + */ + guildAuditLog(guildID: string) { + return `/guilds/${guildID}/audit-logs`; + }, + + /** + * Route for: + * - GET `/channels/{channel.id}` + * - PATCH `/channels/{channel.id}` + * - DELETE `/channels/{channel.id}` + */ + channel(channelID: string) { + return `/channels/${channelID}`; + }, + + /** + * Route for: + * - GET `/channels/{channel.id}/messages` + * - POST `/channels/{channel.id}/messages` + */ + channelMessages(channelID: string) { + return `/channels/${channelID}/messages`; + }, + + /** + * Route for: + * - GET `/channels/{channel.id}/messages/{message.id}` + * - PATCH `/channels/{channel.id}/messages/{message.id}` + * - DELETE `/channels/{channel.id}/messages/{message.id}` + */ + channelMessage(channelID: string, messageID: string) { + return `/channels/${channelID}/messages/${messageID}`; + }, + + /** + * Route for: + * - POST `/channels/{channel.id}/messages/{message.id}/crosspost` + */ + channelCrosspost(channelID: string, messageID: string) { + return `/channels/${channelID}/message/${messageID}/crosspost`; + }, + + /** + * Route for: + * - PUT `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me` + * - DELETE `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me` + * + * **Note**: You need to URL encode the emoji yourself. + */ + channelMessageOwnReaction(channelID: string, messageID: string, emoji: string) { + return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me`; + }, + + /** + * Route for: + * - DELETE `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/{user.id}` + * + * **Note**: You need to URL encode the emoji yourself. + */ + channelMessageUserReaction(channelID: string, messageID: string, emoji: string, userID: string) { + return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}`; + }, + + /** + * Route for: + * - GET `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}` + * - DELETE `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}` + * + * **Note**: You need to URL encode the emoji yourself. + */ + channelMessageSpecificReaction(channelID: string, messageID: string, emoji: string) { + return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}`; + }, + + /** + * Route for: + * - DELETE `/channels/{channel.id}/messages/{message.id}/reactions` + */ + channelMessageAllReactions(channelID: string, messageID: string) { + return `/channels/${channelID}/messages/${messageID}`; + }, + + /** + * Route for: + * - POST `/channels/{channel.id}/messages/bulk-delete` + */ + channelBulkDelete(channelID: string) { + return `/channels/${channelID}/bulk-delete`; + }, + + /** + * Route for: + * - PUT `/channels/{channel.id}/permissions/{overwrite.id}` + * - DELETE `/channels/{channel.id}/permissions/{overwrite.id}` + */ + channelPermissions(channelID: string, overwriteID: string) { + return `/channels/${channelID}/permissions/${overwriteID}`; + }, + + /** + * Route for: + * - GET `/channels/{channel.id}/invites` + * - POST `/channels/{channel.id}/invites` + */ + channelInvite(channelID: string) { + return `/channels/${channelID}`; + }, + + /** + * Route for: + * - POST `/channels/{channel.id}/followers` + */ + channelFollowers(channelID: string) { + return `/channels/${channelID}/followers`; + }, + + /** + * Route for: + * - POST `/channels/{channel.id}/typing` + */ + channelTyping(channelID: string) { + return `/channels/${channelID}/typing`; + }, + + /** + * Route for: + * - GET `/channels/{channel.id}/pins` + */ + channelPins(channelID: string) { + return `/channels/${channelID}/pins`; + }, + + /** + * Route for: + * - PUT `/channels/{channel.id}/pins/{message.id}` + * - DELETE `/channels/{channel.id}/pins/{message.id}` + */ + channelPin(channelID: string, messageID: string) { + return `/channels/${channelID}/pins/${messageID}`; + }, + + /** + * Route for: + * - PUT `/channels/{channel.id}/recipients/{user.id}` + * - DELETE `/channels/{channel.id}/recipients/{user.id}` + */ + channelRecipient(channelID: string, userID: string) { + return `/channels/${channelID}/recipients/${userID}`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/emojis` + * - POST `/guilds/{guild.id}/emojis` + */ + guildEmojis(guildID: string) { + return `/guilds/${guildID}/emojis`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/emojis/{emoji.id}` + * - PATCH `/guilds/{guild.id}/emojis/{emoji.id}` + * - DELETE `/guilds/{guild.id}/emojis/{emoji.id}` + */ + guildEmoji(guildID: string, emojiID: string) { + return `/guilds/${guildID}/emojis/${emojiID}`; + }, + + /** + * Route for: + * - POST `/guilds` + */ + guilds() { + return '/guilds'; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}` + * - PATCH `/guilds/{guild.id}` + * - DELETE `/guilds/{guild.id}` + */ + guild(guildID: string) { + return `/guilds/${guildID}`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/preview` + */ + guildPreview(guildID: string) { + return `/guilds/${guildID}/preview`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/channels` + * - POST `/guilds/{guild.id}/channels` + * - PATCH `/guilds/{guild.id}/channels` + */ + guildChannels(guildID: string) { + return `/guilds/${guildID}/channels`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/members/{user.id}` + * - PUT `/guilds/{guild.id}/members/{user.id}` + * - PATCH `/guilds/{guild.id}/members/{user.id}` + * - DELETE `/guilds/{guild.id}/members/{user.id}` + */ + guildMember(guildID: string, userID: string) { + return `/guilds/${guildID}/members/${userID}`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/members` + */ + guildMembers(guildID: string) { + return `/guilds/${guildID}/members`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/members/search` + */ + guildMembersSearch(guildID: string) { + return `/guilds/${guildID}/members/search`; + }, + + /** + * Route for: + * - PATCH `/guilds/{guild.id}/members/@me/nick` + */ + guildCurrentMemberNickname(guildID: string) { + return `/guilds/${guildID}/members/@me/nick`; + }, + + /** + * Route for: + * - PUT `/guilds/{guild.id}/members/{user.id}/roles/{role.id}` + * - DELETE `/guilds/{guild.id}/members/{user.id}/roles/{role.id}` + */ + guildMemberRole(guildID: string, memberID: string, roleID: string) { + return `/guilds/${guildID}/members/${memberID}/roles/${roleID}`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/bans` + */ + guildBans(guildID: string) { + return `/guilds/${guildID}/bans`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/bans/{user.id}` + * - PUT `/guilds/{guild.id}/bans/{user.id}` + * - DELETE `/guilds/{guild.id}/bans/{user.id}` + */ + guildBan(guildID: string, userID: string) { + return `/guilds/${guildID}/bans/${userID}`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/roles` + * - POST `/guilds/{guild.id}/roles` + * - PATCH `/guilds/{guild.id}/roles` + */ + guildRoles(guildID: string) { + return `/guilds/${guildID}/roles`; + }, + + /** + * Route for: + * - PATCH `/guilds/{guild.id}/roles/{role.id}` + * - DELETE `/guilds/{guild.id}/roles/{role.id}` + */ + guildRole(guildID: string, roleID: string) { + return `/guilds/${guildID}/roles/${roleID}`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/prune` + * - POST `/guilds/{guild.id}/prune` + */ + guildPrune(guildID: string) { + return `/guilds/${guildID}/prune`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/regions` + */ + guildVoiceRegions(guildID: string) { + return `/guilds/${guildID}/regions`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/invites` + */ + guildInvites(guildID: string) { + return `/guilds/${guildID}/invites`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/integrations` + * - POST `/guilds/{guild.id}/integrations` + */ + guildIntegrations(guildID: string) { + return `/guilds/${guildID}/integrations`; + }, + + /** + * Route for: + * - PATCH `/guilds/{guild.id}/integrations/{integration.id}` + * - DELETE `/guilds/{guild.id}/integrations/{integration.id}` + */ + guildIntegration(guildID: string, integrationID: string) { + return `/guilds/${guildID}/integrations/${integrationID}`; + }, + + /** + * Route for: + * - POST `/guilds/{guild.id}/integrations/{integration.id}/sync` + */ + guildIntegrationSync(guildID: string, integrationID: string) { + return `/guilds/${guildID}/integrations/${integrationID}/sync`; + }, + + /** + * @deprecated Use `guildWidgetSettings` instead + */ + guildWidget(guildID: string) { + return `/guilds/${guildID}/widget`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/widget` + * - PATCH `/guilds/{guild.id}/widget` + */ + guildWidgetSettings(guildID: string) { + return `/guilds/${guildID}/widget`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/vanity-url` + */ + guildVanityUrl(guildID: string) { + return `/guilds/${guildID}/vanity-url`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/widget.png` + */ + guildWidgetImage(guildID: string) { + return `/guilds/${guildID}/widget.png`; + }, + + /** + * Route for: + * - GET `/invites/{invite.code}` + * - DELETE `/invites/{invite.code}` + */ + invite(code: string) { + return `/invites/${code}`; + }, + + /** + * Route for: + * - GET `/users/@me` + * - GET `/users/{user.id}` + * - PATCH `/users/@me` + */ + user(userID = '@me') { + return `/users/${userID}`; + }, + + /** + * Route for: + * - GET `/users/@me/guilds` + */ + userGuilds() { + return `/users/@me/guilds`; + }, + + /** + * Route for: + * - DELETE `/users/@me/guilds/{guild.id}` + */ + userGuild(guildID: string) { + return `/users/@me/guilds/${guildID}`; + }, + + /** + * Route for: + * - POST `/users/@me/channels` + */ + userChannels() { + return `/users/@me/channels`; + }, + + /** + * Route for: + * - GET `/users/@me/connections` + */ + userConnections() { + return `/users/@me/connections`; + }, + + /** + * Route for: + * - GET `/voice/regions` + */ + voiceRegions() { + return `/voice/regions`; + }, + + /** + * Route for: + * - POST `/channels/{channel.id}/webhooks` + * - GET `/channels/{channel.id}/webhooks` + */ + channelWebhook(channelID: string) { + return `/channels/${channelID}/webhooks`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/webhooks` + */ + guildWebhooks(guildID: string) { + return `/guilds/${guildID}/webhooks`; + }, + + /** + * Route for: + * - GET `/webhooks/{webhook.id}` + * - GET `/webhooks/{webhook.id}/{webhook.token}` + * - PATCH `/webhooks/{webhook.id}` + * - PATCH `/webhooks/{webhook.id}/{webhook.token}` + * - DELETE `/webhooks/{webhook.id}` + * - DELETE `/webhooks/{webhook.id}/{webhook.token}` + * - POST `/webhooks/{webhook.id}/{webhook.token}` + */ + webhook(webhookID: string, webhookToken?: string) { + const parts = ['', 'webhooks', webhookID]; + + if (webhookToken) parts.push(webhookToken); + + return parts.join('/'); + }, + + /** + * Route for: + * - POST `/webhooks/{webhook.id}/{webhook.token}/slack` + * - POST `/webhooks/{webhook.id}/{webhook.token}/github` + */ + webhookPlatform(webhookID: string, webhookToken: string, platform: 'github' | 'slack') { + return `/${webhookID}/${webhookToken}/${platform}`; + }, + + /** + * Route for: + * - GET `/gateway` + */ + gateway() { + return `/gateway`; + }, + + /** + * Route for: + * - GET `/gateway/bot` + */ + gatewayBot() { + return `/gateway/bot`; + }, + + /** + * Route for: + * - GET `/oauth2/applications/@me` + */ + oauth2CurrentApplication() { + return `/oauth2/applications/@me`; + }, +}; diff --git a/.deno/v6/rest/oauth2.ts b/.deno/v6/rest/oauth2.ts new file mode 100644 index 00000000..a535190f --- /dev/null +++ b/.deno/v6/rest/oauth2.ts @@ -0,0 +1,181 @@ +import type { APIApplication, APIGuild, APIWebhook } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/topics/oauth2#get-current-application-information + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIOauth2CurrentApplicationResult = APIApplication; + +/** + * https://discord.com/developers/docs/topics/oauth2#authorization-code-grant + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTOAuth2AuthorizationQuery { + response_type: 'code'; + client_id: string; + scope: string; + redirect_uri?: string; + state?: string; + prompt?: 'consent' | 'none'; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-redirect-url-example + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTOAuth2AuthorizationQueryResult { + code: string; + state?: string; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-redirect-url-example + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostOAuth2AccessTokenURIEncodedData { + client_id: string; + client_secret: string; + grant_type: 'authorization_code'; + code: string; + redirect_uri?: string; + scope: string; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-access-token-response + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostOAuth2AccessTokenResult { + access_token: string; + token_type: string; + expires_in: number; + refresh_token: string; + scope: string; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-refresh-token-exchange-example + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostOAuth2RefreshTokenURIEncodedData { + client_id: string; + client_secret: string; + grant_type: 'refresh_token'; + refresh_token: string; + redirect_uri?: string; + scope: string; +} + +export type RESTPostOAuth2RefreshTokenResult = RESTPostOAuth2AccessTokenResult; + +/** + * https://discord.com/developers/docs/topics/oauth2#implicit-grant + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTOAuth2ImplicitAuthorizationQuery { + response_type: 'token'; + client_id: string; + scope: string; + redirect_uri?: string; + state?: string; + prompt?: 'consent' | 'none'; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#implicit-grant-redirect-url-example + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTOAuth2ImplicitAuthorizationURIFragmentResult = Omit; + +/** + * https://discord.com/developers/docs/topics/oauth2#client-credentials-grant + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostOAuth2ClientCredentialsURIEncodedData { + client_id: string; + client_secret: string; + grant_type: 'client_credentials'; + scope: string; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostOAuth2ClientCredentialsResult = RESTOAuth2ImplicitAuthorizationURIFragmentResult; + +/** + * https://discord.com/developers/docs/topics/oauth2#bot-authorization-flow-bot-auth-parameters + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTOAuth2BotAuthorizationQuery { + client_id: string; + scope: string; + /** + * The required permissions bitfield, stringified + */ + permissions?: string; + guild_id?: string; + disable_guild_select?: boolean; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTOAuth2AdvancedBotAuthorizationQuery { + client_id: string; + /** + * This assumes you include the `bot` scope alongside others (like `identify` for example) + */ + scope: string; + /** + * The required permissions bitfield, stringified + */ + permissions?: string; + guild_id?: string; + disable_guild_select?: boolean; + response_type: string; + redirect_uri?: string; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTOAuth2AdvancedBotAuthorizationQueryResult { + code: string; + state?: string; + guild_id: string; + permissions: string; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization-extended-bot-authorization-access-token-example + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostOAuth2AccessTokenWithBotAndGuildsScopeResult { + access_token: string; + token_type: string; + expires_in: number; + refresh_token: string; + scope: string; + guild: APIGuild; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#webhooks-webhook-token-response-example + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostOAuth2AccessTokenWithBotAndWebhookIncomingScopeResult { + access_token: string; + token_type: string; + expires_in: number; + refresh_token: string; + scope: string; + webhook: APIWebhook; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostOAuth2AccessTokenWithBotAndGuildsAndWebhookIncomingScopeResult = RESTPostOAuth2AccessTokenWithBotAndGuildsScopeResult & + RESTPostOAuth2AccessTokenWithBotAndWebhookIncomingScopeResult; diff --git a/.deno/v6/rest/user.ts b/.deno/v6/rest/user.ts new file mode 100644 index 00000000..caa5c4d6 --- /dev/null +++ b/.deno/v6/rest/user.ts @@ -0,0 +1,83 @@ +import type { APIChannel, APIConnection, APIUser, GuildFeature } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/user#get-current-user + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPICurrentUserResult = APIUser; + +/** + * https://discord.com/developers/docs/resources/user#get-user + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIUserResult = APIUser; + +/** + * https://discord.com/developers/docs/resources/user#modify-current-user + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPatchAPICurrentUserJSONBody { + username?: string; + avatar?: string | null; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPICurrentUserResult = APIUser; + +/** + * https://discord.com/developers/docs/resources/user#get-current-user-guilds + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTGetAPICurrentUserGuildsQuery { + before?: string; + after?: string; + limit?: number; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTAPIPartialCurrentUserGuild { + id: string; + name: string; + icon: string | null; + owner: boolean; + features: GuildFeature[]; + /** + * @deprecated Use `permissions_new` instead + */ + permissions: number; + permissions_new: string; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPICurrentUserGuildsResult = RESTAPIPartialCurrentUserGuild[]; + +/** + * https://discord.com/developers/docs/resources/user#leave-guild + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPICurrentUserGuildResult = never; + +/** + * https://discord.com/developers/docs/resources/user#create-dm + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostAPICurrentUserCreateDMChannelJSONBody { + recipient_id: string; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPICurrentUserCreateDMChannelResult = APIChannel; + +/** + * https://discord.com/developers/docs/resources/user#get-user-connections + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPICurrentUserConnectionsResult = APIConnection[]; diff --git a/.deno/v6/rest/voice.ts b/.deno/v6/rest/voice.ts new file mode 100644 index 00000000..a6390189 --- /dev/null +++ b/.deno/v6/rest/voice.ts @@ -0,0 +1,7 @@ +import type { APIVoiceRegion } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/voice#list-voice-regions + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type GetAPIVoiceRegionsResult = APIVoiceRegion[]; diff --git a/.deno/v6/rest/webhook.ts b/.deno/v6/rest/webhook.ts new file mode 100644 index 00000000..1b53e3e6 --- /dev/null +++ b/.deno/v6/rest/webhook.ts @@ -0,0 +1,146 @@ +import type { APIAllowedMentionsSend } from './channel.ts'; +import type { APIEmbed, APIMessage, APIWebhook } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/webhook#create-webhook + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostAPIChannelWebhookJSONBody { + name: string; + avatar?: string | null; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIChannelWebhookResult = APIWebhook; + +/** + * https://discord.com/developers/docs/resources/webhook#get-channel-webhooks + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIChannelWebhooksResult = APIWebhook[]; + +/** + * https://discord.com/developers/docs/resources/webhook#get-guild-webhooks + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIGuildWebhooksResult = APIWebhook[]; + +/** + * https://discord.com/developers/docs/resources/webhook#get-webhook + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIWebhookResult = APIWebhook; + +/** + * https://discord.com/developers/docs/resources/webhook#get-webhook-with-token + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTGetAPIWebhookWithTokenResult = Omit; + +/** + * https://discord.com/developers/docs/resources/webhook#modify-webhook + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPatchAPIWebhookJSONBody { + name?: string; + avatar?: string | null; + channel_id?: string; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIWebhookResult = APIWebhook; + +/** + * https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIWebhookWithTokenJSONBody = Omit; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPatchAPIWebhookWithTokenResult = Omit; + +/** + * https://discord.com/developers/docs/resources/webhook#delete-webhook + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIWebhookResult = never; + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTDeleteAPIWebhookWithTokenResult = never; + +/** + * https://discord.com/developers/docs/resources/webhook#execute-webhook + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostAPIWebhookWithTokenJSONBody { + content?: string; + username?: string; + avatar_url?: string; + tts?: boolean; + embeds?: APIEmbed[]; + allowed_mentions?: APIAllowedMentionsSend; +} + +/** + * https://discord.com/developers/docs/resources/webhook#execute-webhook + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIWebhookWithTokenFormDataBody = + | { + /** + * JSON stringified message body + */ + payload_json?: string; + /** + * The file contents + */ + file: unknown; + } + | (RESTPostAPIWebhookWithTokenJSONBody & { + /** + * The file contents + */ + file: unknown; + }); + +/** + * https://discord.com/developers/docs/resources/webhook#execute-webhook-querystring-params + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export interface RESTPostAPIWebhookWithTokenQuery { + wait?: boolean; +} + +/** + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIWebhookWithTokenResult = never; + +/** + * Received when a call to POST `/webhooks/{webhook.id}/{webhook.token}` receives + * the `wait` query parameter set to `true` + * + * @see https://discord.com/developers/docs/resources/webhook#execute-webhook-querystring-params + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIWebhookWithTokenWaitResult = APIMessage; + +/** + * https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook-querystring-params + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIWebhookWithTokenSlackQuery = RESTPostAPIWebhookWithTokenQuery; + +/** + * https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook-querystring-params + * @deprecated API v6 is deprecated and the types will not receive further updates, please update to v8. + */ +export type RESTPostAPIWebhookWithTokenGitHubQuery = RESTPostAPIWebhookWithTokenQuery; diff --git a/.deno/v8/gateway/mod.ts b/.deno/v8/gateway/mod.ts new file mode 100644 index 00000000..e382ff21 --- /dev/null +++ b/.deno/v8/gateway/mod.ts @@ -0,0 +1,1543 @@ +/** + * Types extracted from https://discord.com/developers/docs/topics/gateway + */ + +import type { + APIChannel, + APIEmoji, + APIGuild, + APIGuildMember, + APIMessage, + APIRole, + APIUnavailableGuild, + APIUser, + GatewayActivity, + GatewayPresenceUpdate as RawGatewayPresenceUpdate, + GatewayVoiceState, + InviteTargetUserType, + PresenceUpdateStatus, + APIApplicationCommandInteraction, + APIApplication, +} from '../payloads/mod.ts'; + +export const GatewayVersion = '8'; + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes + */ +export const enum GatewayOPCodes { + /** + * An event was dispatched + */ + Dispatch, + /** + * Fired periodically by the client to keep the connection alive + */ + Heartbeat, + /** + * Starts a new session during the initial handshake + */ + Identify, + /** + * Update the client's presence + */ + PresenceUpdate, + /** + * Used to join/leave or move between voice channels + */ + VoiceStateUpdate, + /** + * Resume a previous session that was disconnected + */ + Resume = 6, + /** + * You should attempt to reconnect and resume immediately + */ + Reconnect, + /** + * Request information about offline guild members in a large guild + */ + RequestGuildMembers, + /** + * The session has been invalidated. You should reconnect and identify/resume accordingly + */ + InvalidSession, + /** + * Sent immediately after connecting, contains the `heartbeat_interval` to use + */ + Hello, + /** + * Sent in response to receiving a heartbeat to acknowledge that it has been received + */ + HeartbeatAck, +} + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes + */ +export const enum GatewayCloseCodes { + /** + * We're not sure what went wrong. Try reconnecting? + */ + UnknownError = 4000, + /** + * You sent an invalid Gateway opcode or an invalid payload for an opcode. Don't do that! + * + * See https://discord.com/developers/docs/topics/gateway#payloads-and-opcodes + */ + UnknownOpCode, + /** + * You sent an invalid payload to us. Don't do that! + * + * See https://discord.com/developers/docs/topics/gateway#sending-payloads + */ + DecodeError, + /** + * You sent us a payload prior to identifying + * + * See https://discord.com/developers/docs/topics/gateway#identify + */ + NotAuthenticated, + /** + * The account token sent with your identify payload is incorrect + * + * See https://discord.com/developers/docs/topics/gateway#identify + */ + AuthenticationFailed, + /** + * You sent more than one identify payload. Don't do that! + */ + AlreadyAuthenticated, + /** + * The sequence sent when resuming the session was invalid. Reconnect and start a new session + * + * See https://discord.com/developers/docs/topics/gateway#resume + */ + InvalidSeq = 4007, + /** + * Woah nelly! You're sending payloads to us too quickly. Slow it down! You will be disconnected on receiving this + */ + RateLimited, + /** + * Your session timed out. Reconnect and start a new one + */ + SessionTimedOut, + /** + * You sent us an invalid shard when identifying + * + * See https://discord.com/developers/docs/topics/gateway#sharding + */ + InvalidShard, + /** + * The session would have handled too many guilds - you are required to shard your connection in order to connect + * + * See https://discord.com/developers/docs/topics/gateway#sharding + */ + ShardingRequired, + /** + * You sent an invalid version for the gateway + */ + InvalidAPIVersion, + /** + * You sent an invalid intent for a Gateway Intent. You may have incorrectly calculated the bitwise value + * + * See https://discord.com/developers/docs/topics/gateway#gateway-intents + */ + InvalidIntents, + /** + * You sent a disallowed intent for a Gateway Intent. You may have tried to specify an intent that you have not + * enabled or are not whitelisted for + * + * See https://discord.com/developers/docs/topics/gateway#gateway-intents + * + * See https://discord.com/developers/docs/topics/gateway#privileged-intents + */ + DisallowedIntents, +} + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-opcodes + */ +export const enum VoiceOPCodes { + /** + * Begin a voice websocket connection + */ + Identify, + /** + * Select the voice protocol + */ + SelectProtocol, + /** + * Complete the websocket handshake + */ + Ready, + /** + * Keep the websocket connection alive + */ + Heartbeat, + /** + * Describe the session + */ + SessionDescription, + /** + * Indicate which users are speaking + */ + Speaking, + /** + * Sent to acknowledge a received client heartbeat + */ + HeartbeatAck, + /** + * Resume a connection + */ + Resume, + /** + * Time to wait between sending heartbeats in milliseconds + */ + Hello, + /** + * Acknowledge a successful session resume + */ + Resumed, + /** + * A client has connected to the voice channel + */ + ClientConnect = 12, + /** + * A client has disconnected from the voice channel + */ + ClientDisconnect, +} + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes + */ +export const enum VoiceCloseCodes { + /** + * You sent an invalid opcode + */ + UnknownOpCode = 4001, + /** + * You sent a invalid payload in your identifying to the Gateway + */ + FailedToDecode, + /** + * You sent a payload before identifying with the Gateway + */ + NotAuthenticated, + /** + * The token you sent in your identify payload is incorrect + */ + AuthenticationFailed, + /** + * You sent more than one identify payload. Stahp + */ + AlreadyAuthenticated, + /** + * Your session is no longer valid + */ + SessionNoLongerValid, + /** + * Your session has timed out + */ + SessionTimeout = 4009, + /** + * We can't find the server you're trying to connect to + */ + ServerNotFound = 4011, + /** + * We didn't recognize the protocol you sent + */ + UnknownProtocol, + /** + * Either the channel was deleted or you were kicked. Should not reconnect + */ + Disconnected = 4014, + /** + * The server crashed. Our bad! Try resuming + */ + VoiceServerCrashed, + /** + * We didn't recognize your encryption + */ + UnknownEncryptionMode, +} + +/** + * https://discord.com/developers/docs/topics/gateway#list-of-intents + */ +export const enum GatewayIntentBits { + GUILDS = 1 << 0, + GUILD_MEMBERS = 1 << 1, + GUILD_BANS = 1 << 2, + GUILD_EMOJIS = 1 << 3, + GUILD_INTEGRATIONS = 1 << 4, + GUILD_WEBHOOKS = 1 << 5, + GUILD_INVITES = 1 << 6, + GUILD_VOICE_STATES = 1 << 7, + GUILD_PRESENCES = 1 << 8, + GUILD_MESSAGES = 1 << 9, + GUILD_MESSAGE_REACTIONS = 1 << 10, + GUILD_MESSAGE_TYPING = 1 << 11, + DIRECT_MESSAGES = 1 << 12, + DIRECT_MESSAGE_REACTIONS = 1 << 13, + DIRECT_MESSAGE_TYPING = 1 << 14, +} + +/** + * https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events + */ +export const enum GatewayDispatchEvents { + Ready = 'READY', + Resumed = 'RESUMED', + ChannelCreate = 'CHANNEL_CREATE', + ChannelUpdate = 'CHANNEL_UPDATE', + ChannelDelete = 'CHANNEL_DELETE', + ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE', + GuildCreate = 'GUILD_CREATE', + GuildUpdate = 'GUILD_UPDATE', + GuildDelete = 'GUILD_DELETE', + GuildBanAdd = 'GUILD_BAN_ADD', + GuildBanRemove = 'GUILD_BAN_REMOVE', + GuildEmojisUpdate = 'GUILD_EMOJIS_UPDATE', + GuildIntegrationsUpdate = 'GUILD_INTEGRATIONS_UPDATE', + GuildMemberAdd = 'GUILD_MEMBER_ADD', + GuildMemberRemove = 'GUILD_MEMBER_REMOVE', + GuildMemberUpdate = 'GUILD_MEMBER_UPDATE', + GuildMembersChunk = 'GUILD_MEMBERS_CHUNK', + GuildRoleCreate = 'GUILD_ROLE_CREATE', + GuildRoleUpdate = 'GUILD_ROLE_UPDATE', + GuildRoleDelete = 'GUILD_ROLE_DELETE', + InteractionCreate = 'INTERACTION_CREATE', + InviteCreate = 'INVITE_CREATE', + InviteDelete = 'INVITE_DELETE', + MessageCreate = 'MESSAGE_CREATE', + MessageUpdate = 'MESSAGE_UPDATE', + MessageDelete = 'MESSAGE_DELETE', + MessageDeleteBulk = 'MESSAGE_DELETE_BULK', + MessageReactionAdd = 'MESSAGE_REACTION_ADD', + MessageReactionRemove = 'MESSAGE_REACTION_REMOVE', + MessageReactionRemoveAll = 'MESSAGE_REACTION_REMOVE_ALL', + MessageReactionRemoveEmoji = 'MESSAGE_REACTION_REMOVE_EMOJI', + PresenceUpdate = 'PRESENCE_UPDATE', + TypingStart = 'TYPING_START', + UserUpdate = 'USER_UPDATE', + VoiceStateUpdate = 'VOICE_STATE_UPDATE', + VoiceServerUpdate = 'VOICE_SERVER_UPDATE', + WebhooksUpdate = 'WEBHOOKS_UPDATE', +} + +export type GatewaySendPayload = + | GatewayHeartbeat + | GatewayIdentify + | GatewayUpdatePresence + | GatewayVoiceStateUpdate + | GatewayResume + | GatewayRequestGuildMembers; + +export type GatewayReceivePayload = + | GatewayHello + | GatewayHeartbeatRequest + | GatewayHeartbeatAck + | GatewayInvalidSession + | GatewayReconnect + | GatewayDispatchPayload; + +export type GatewayDispatchPayload = + | GatewayReadyDispatch + | GatewayResumedDispatch + | GatewayChannelModifyDispatch + | GatewayChannelPinsUpdateDispatch + | GatewayGuildModifyDispatch + | GatewayGuildDeleteDispatch + | GatewayGuildBanModifyDispatch + | GatewayGuildEmojisUpdateDispatch + | GatewayGuildIntegrationsUpdateDispatch + | GatewayGuildMemberAddDispatch + | GatewayGuildMemberRemoveDispatch + | GatewayGuildMemberUpdateDispatch + | GatewayGuildMembersChunkDispatch + | GatewayGuildRoleModifyDispatch + | GatewayGuildRoleDeleteDispatch + | GatewayInteractionCreateDispatch + | GatewayInviteCreateDispatch + | GatewayInviteDeleteDispatch + | GatewayMessageCreateDispatch + | GatewayMessageUpdateDispatch + | GatewayMessageDeleteDispatch + | GatewayMessageDeleteBulkDispatch + | GatewayMessageReactionAddDispatch + | GatewayMessageReactionRemoveDispatch + | GatewayMessageReactionRemoveAllDispatch + | GatewayMessageReactionRemoveEmojiDispatch + | GatewayPresenceUpdateDispatch + | GatewayTypingStartDispatch + | GatewayUserUpdateDispatch + | GatewayVoiceStateUpdateDispatch + | GatewayVoiceServerUpdateDispatch + | GatewayWebhooksUpdateDispatch; + +// #region Dispatch Payloads + +/** + * https://discord.com/developers/docs/topics/gateway#hello + */ +export interface GatewayHello extends NonDispatchPayload { + op: GatewayOPCodes.Hello; + d: GatewayHelloData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#hello + */ +export interface GatewayHelloData { + /** + * The interval (in milliseconds) the client should heartbeat with + */ + heartbeat_interval: number; +} + +/** + * https://discord.com/developers/docs/topics/gateway#heartbeating + */ +export interface GatewayHeartbeatRequest extends NonDispatchPayload { + op: GatewayOPCodes.Heartbeat; + d: never; +} + +/** + * https://discord.com/developers/docs/topics/gateway#heartbeating-example-gateway-heartbeat-ack + */ +export interface GatewayHeartbeatAck extends NonDispatchPayload { + op: GatewayOPCodes.HeartbeatAck; + d: never; +} + +/** + * https://discord.com/developers/docs/topics/gateway#invalid-session + */ +export interface GatewayInvalidSession extends NonDispatchPayload { + op: GatewayOPCodes.InvalidSession; + d: GatewayInvalidSessionData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#invalid-session + */ +export type GatewayInvalidSessionData = boolean; + +/** + * https://discord.com/developers/docs/topics/gateway#reconnect + */ +export interface GatewayReconnect extends NonDispatchPayload { + op: GatewayOPCodes.Reconnect; + d: never; +} + +/** + * https://discord.com/developers/docs/topics/gateway#ready + */ +export type GatewayReadyDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#ready + */ +export interface GatewayReadyDispatchData { + /** + * Gateway version + * + * See https://discord.com/developers/docs/topics/gateway#gateways-gateway-versions + */ + v: number; + /** + * Information about the user including email + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + user: APIUser; + /** + * Empty array + */ + private_channels: []; + /** + * The guilds the user is in + * + * See https://discord.com/developers/docs/resources/guild#unavailable-guild-object + */ + guilds: APIUnavailableGuild[]; + /** + * Used for resuming connections + */ + session_id: string; + /** + * The shard information associated with this session, if sent when identifying + * + * See https://discord.com/developers/docs/topics/gateway#sharding + */ + shard?: [shard_id: number, shard_count: number]; + /** + * Contains `id` and `flags` + * + * See https://discord.com/developers/docs/topics/oauth2#application-object + */ + application: Pick; +} + +/** + * https://discord.com/developers/docs/topics/gateway#resumed + */ +export type GatewayResumedDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-create + * https://discord.com/developers/docs/topics/gateway#channel-update + * https://discord.com/developers/docs/topics/gateway#channel-delete + */ +export type GatewayChannelModifyDispatch = DataPayload< + GatewayDispatchEvents.ChannelCreate | GatewayDispatchEvents.ChannelDelete | GatewayDispatchEvents.ChannelUpdate, + GatewayChannelModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-create + * https://discord.com/developers/docs/topics/gateway#channel-update + * https://discord.com/developers/docs/topics/gateway#channel-delete + */ +export type GatewayChannelModifyDispatchData = APIChannel; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-create + */ +export type GatewayChannelCreateDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-create + */ +export type GatewayChannelCreateDispatchData = GatewayChannelModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-update + */ +export type GatewayChannelUpdateDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-update + */ +export type GatewayChannelUpdateDispatchData = GatewayChannelModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-delete + */ +export type GatewayChannelDeleteDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-delete + */ +export type GatewayChannelDeleteDispatchData = GatewayChannelModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-pins-update + */ +export type GatewayChannelPinsUpdateDispatch = DataPayload< + GatewayDispatchEvents.ChannelPinsUpdate, + GatewayChannelPinsUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-pins-update + */ +export interface GatewayChannelPinsUpdateDispatchData { + /** + * The id of the guild + */ + guild_id?: string; + /** + * The id of the channel + */ + channel_id: string; + /** + * The time at which the most recent pinned message was pinned + */ + last_pin_timestamp?: string | null; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-create + * https://discord.com/developers/docs/topics/gateway#guild-update + */ +export type GatewayGuildModifyDispatch = DataPayload< + GatewayDispatchEvents.GuildCreate | GatewayDispatchEvents.GuildUpdate, + GatewayGuildModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-create + * https://discord.com/developers/docs/topics/gateway#guild-update + */ +export type GatewayGuildModifyDispatchData = APIGuild; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-create + */ +export type GatewayGuildCreateDispatch = GatewayGuildModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-create + */ +export type GatewayGuildCreateDispatchData = GatewayGuildModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-update + */ +export type GatewayGuildUpdateDispatch = GatewayGuildModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-update + */ +export type GatewayGuildUpdateDispatchData = GatewayGuildModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-delete + */ +export type GatewayGuildDeleteDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-delete + */ +export type GatewayGuildDeleteDispatchData = APIUnavailableGuild; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-add + * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + */ +export type GatewayGuildBanModifyDispatch = DataPayload< + GatewayDispatchEvents.GuildBanAdd | GatewayDispatchEvents.GuildBanRemove, + GatewayGuildBanModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-add + * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + */ +export interface GatewayGuildBanModifyDispatchData { + /** + * ID of the guild + */ + guild_id: string; + /** + * The banned user + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + user: APIUser; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-add + */ +export type GatewayGuildBanAddDispatch = GatewayGuildBanModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-add + */ +export type GatewayGuildBanAddDispatchData = GatewayGuildBanModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + */ +export type GatewayGuildBanRemoveDispatch = GatewayGuildBanModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + */ +export type GatewayGuildBanRemoveDispatchData = GatewayGuildBanModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-emojis-update + */ +export type GatewayGuildEmojisUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildEmojisUpdate, + GatewayGuildEmojisUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-emojis-update + */ +export interface GatewayGuildEmojisUpdateDispatchData { + /** + * ID of the guild + */ + guild_id: string; + /** + * Array of emojis + * + * See https://discord.com/developers/docs/resources/emoji#emoji-object + */ + emojis: APIEmoji[]; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-integrations-update + */ +export type GatewayGuildIntegrationsUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildIntegrationsUpdate, + GatewayGuildIntegrationsUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-integrations-update + */ +export interface GatewayGuildIntegrationsUpdateDispatchData { + /** + * ID of the guild whose integrations were updated + */ + guild_id: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-add + */ +export type GatewayGuildMemberAddDispatch = DataPayload< + GatewayDispatchEvents.GuildMemberAdd, + GatewayGuildMemberAddDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-add + */ +export interface GatewayGuildMemberAddDispatchData extends APIGuildMember { + /** + * The id of the guild + */ + guild_id: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-remove + */ +export type GatewayGuildMemberRemoveDispatch = DataPayload< + GatewayDispatchEvents.GuildMemberRemove, + GatewayGuildMemberRemoveDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-remove + */ +export interface GatewayGuildMemberRemoveDispatchData { + /** + * The id of the guild + */ + guild_id: string; + /** + * The user who was removed + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + user: APIUser; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-update + */ +export type GatewayGuildMemberUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildMemberUpdate, + GatewayGuildMemberUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-member-update + */ +export type GatewayGuildMemberUpdateDispatchData = Omit & { + /** + * The id of the guild + */ + guild_id: string; +}; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-members-chunk + */ +export type GatewayGuildMembersChunkDispatch = DataPayload< + GatewayDispatchEvents.GuildMembersChunk, + GatewayGuildMembersChunkDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-members-chunk + */ +export interface GatewayGuildMembersChunkDispatchData { + /** + * The id of the guild + */ + guild_id: string; + /** + * Set of guild members + * + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ + members: APIGuildMember[]; + /** + * The chunk index in the expected chunks for this response (`0 <= chunk_index < chunk_count`) + */ + chunk_index?: number; + /** + * The total number of expected chunks for this response + */ + chunk_count?: number; + /** + * If passing an invalid id to `REQUEST_GUILD_MEMBERS`, it will be returned here + */ + not_found?: unknown[]; + /** + * If passing true to `REQUEST_GUILD_MEMBERS`, presences of the returned members will be here + * + * See https://discord.com/developers/docs/topics/gateway#presence + */ + presences?: RawGatewayPresenceUpdate[]; + /** + * The nonce used in the Guild Members Request + * + * See https://discord.com/developers/docs/topics/gateway#request-guild-members + */ + nonce?: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-create + * https://discord.com/developers/docs/topics/gateway#guild-role-update + */ +export type GatewayGuildRoleModifyDispatch = DataPayload< + GatewayDispatchEvents.GuildRoleCreate | GatewayDispatchEvents.GuildRoleUpdate, + GatewayGuildRoleModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-create + * https://discord.com/developers/docs/topics/gateway#guild-role-update + */ +export interface GatewayGuildRoleModifyDispatchData { + /** + * The id of the guild + */ + guild_id: string; + /** + * The role created or updated + * + * See https://discord.com/developers/docs/topics/permissions#role-object + */ + role: APIRole; +} + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-create + */ +export type GatewayGuildRoleCreateDispatch = GatewayGuildRoleModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-create + */ +export type GatewayGuildRoleCreateDispatchData = GatewayGuildRoleModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-update + */ +export type GatewayGuildRoleUpdateDispatch = GatewayGuildRoleModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-update + */ +export type GatewayGuildRoleUpdateDispatchData = GatewayGuildRoleModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-delete + */ +export type GatewayGuildRoleDeleteDispatch = DataPayload< + GatewayDispatchEvents.GuildRoleDelete, + GatewayGuildRoleDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-delete + */ +export interface GatewayGuildRoleDeleteDispatchData { + /** + * The id of the guild + */ + guild_id: string; + /** + * The id of the role + */ + role_id: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#interaction-create + */ +export type GatewayInteractionCreateDispatch = DataPayload< + GatewayDispatchEvents.InteractionCreate, + GatewayInteractionCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#interaction-create + */ +export type GatewayInteractionCreateDispatchData = APIApplicationCommandInteraction; + +/** + * https://discord.com/developers/docs/topics/gateway#invite-create + */ +export type GatewayInviteCreateDispatch = DataPayload< + GatewayDispatchEvents.InviteCreate, + GatewayInviteCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#invite-create + */ +export interface GatewayInviteCreateDispatchData { + /** + * The channel the invite is for + */ + channel_id: string; + /** + * 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?: string; + /** + * 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 target user for this invite + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + target_user?: APIUser; + /** + * The type of user target for this invite + * + * See https://discord.com/developers/docs/resources/invite#invite-object-target-user-types + */ + target_user_type?: InviteTargetUserType; + /** + * Whether or not the invite is temporary (invited users will be kicked on disconnect unless they're assigned a role) + */ + temporary: boolean; + /** + * How many times the invite has been used (always will be `0`) + */ + uses: 0; +} + +/** + * https://discord.com/developers/docs/topics/gateway#invite-delete + */ +export type GatewayInviteDeleteDispatch = DataPayload< + GatewayDispatchEvents.InviteDelete, + GatewayInviteDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#invite-delete + */ +export interface GatewayInviteDeleteDispatchData { + /** + * The channel of the invite + */ + channel_id: string; + /** + * The guild of the invite + */ + guild_id?: string; + /** + * The unique invite code + * + * See https://discord.com/developers/docs/resources/invite#invite-object + */ + code: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#message-create + */ +export type GatewayMessageCreateDispatch = DataPayload< + GatewayDispatchEvents.MessageCreate, + GatewayMessageCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-create + */ +export type GatewayMessageCreateDispatchData = APIMessage; + +/** + * https://discord.com/developers/docs/topics/gateway#message-update + */ +export type GatewayMessageUpdateDispatch = DataPayload< + GatewayDispatchEvents.MessageUpdate, + GatewayMessageUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-update + */ +export type GatewayMessageUpdateDispatchData = { + id: string; + channel_id: string; +} & Partial; + +/** + * https://discord.com/developers/docs/topics/gateway#message-delete + */ +export type GatewayMessageDeleteDispatch = DataPayload< + GatewayDispatchEvents.MessageDelete, + GatewayMessageDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-delete + */ +export interface GatewayMessageDeleteDispatchData { + /** + * The id of the message + */ + id: string; + /** + * The id of the channel + */ + channel_id: string; + /** + * The id of the guild + */ + guild_id?: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#message-delete-bulk + */ +export type GatewayMessageDeleteBulkDispatch = DataPayload< + GatewayDispatchEvents.MessageDeleteBulk, + GatewayMessageDeleteBulkDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-delete-bulk + */ +export interface GatewayMessageDeleteBulkDispatchData { + /** + * The ids of the messages + */ + ids: string[]; + /** + * The id of the channel + */ + channel_id: string; + /** + * The id of the guild + */ + guild_id?: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-add + */ +export type GatewayMessageReactionAddDispatch = ReactionData; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-add + */ +export type GatewayMessageReactionAddDispatchData = GatewayMessageReactionAddDispatch['d']; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove + */ +export type GatewayMessageReactionRemoveDispatch = ReactionData; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove + */ +export type GatewayMessageReactionRemoveDispatchData = GatewayMessageReactionRemoveDispatch['d']; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-all + */ +export type GatewayMessageReactionRemoveAllDispatch = DataPayload< + GatewayDispatchEvents.MessageReactionRemoveAll, + GatewayMessageReactionRemoveAllDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-all + */ +export type GatewayMessageReactionRemoveAllDispatchData = MessageReactionRemoveData; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji + */ +export type GatewayMessageReactionRemoveEmojiDispatch = DataPayload< + GatewayDispatchEvents.MessageReactionRemoveEmoji, + GatewayMessageReactionRemoveEmojiDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji + */ +export interface GatewayMessageReactionRemoveEmojiDispatchData extends MessageReactionRemoveData { + /** + * The emoji that was removed + */ + emoji: APIEmoji; +} + +/** + * https://discord.com/developers/docs/topics/gateway#presence-update + */ +export type GatewayPresenceUpdateDispatch = DataPayload< + GatewayDispatchEvents.PresenceUpdate, + GatewayPresenceUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#presence-update + */ +export type GatewayPresenceUpdateDispatchData = RawGatewayPresenceUpdate; + +/** + * https://discord.com/developers/docs/topics/gateway#typing-start + */ +export type GatewayTypingStartDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#typing-start + */ +export interface GatewayTypingStartDispatchData { + /** + * The id of the channel + */ + channel_id: string; + /** + * The id of the guild + */ + guild_id?: string; + /** + * The id of the user + */ + user_id: string; + /** + * Unix time (in seconds) of when the user started typing + */ + timestamp: number; + /** + * The member who started typing if this happened in a guild + * + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ + member?: APIGuildMember; +} + +/** + * https://discord.com/developers/docs/topics/gateway#user-update + */ +export type GatewayUserUpdateDispatch = DataPayload; + +/** + * https://discord.com/developers/docs/topics/gateway#user-update + */ +export type GatewayUserUpdateDispatchData = APIUser; + +/** + * https://discord.com/developers/docs/topics/gateway#voice-state-update + */ +export type GatewayVoiceStateUpdateDispatch = DataPayload< + GatewayDispatchEvents.VoiceStateUpdate, + GatewayVoiceStateUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#voice-state-update + */ +export type GatewayVoiceStateUpdateDispatchData = GatewayVoiceState; + +/** + * https://discord.com/developers/docs/topics/gateway#voice-server-update + */ +export type GatewayVoiceServerUpdateDispatch = DataPayload< + GatewayDispatchEvents.VoiceServerUpdate, + GatewayVoiceServerUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#voice-server-update + */ +export interface GatewayVoiceServerUpdateDispatchData { + /** + * Voice connection token + */ + token: string; + /** + * The guild this voice server update is for + */ + guild_id: string; + /** + * The voice server host + */ + endpoint: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#webhooks-update + */ +export type GatewayWebhooksUpdateDispatch = DataPayload< + GatewayDispatchEvents.WebhooksUpdate, + GatewayWebhooksUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#webhooks-update + */ +export interface GatewayWebhooksUpdateDispatchData { + /** + * The id of the guild + */ + guild_id: string; + /** + * The id of the channel + */ + channel_id: string; +} + +// #endregion Dispatch Payloads + +// #region Sendable Payloads + +/** + * https://discord.com/developers/docs/topics/gateway#heartbeating + */ +export interface GatewayHeartbeat { + op: GatewayOPCodes.Heartbeat; + d: GatewayHeartbeatData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#heartbeating + */ +export type GatewayHeartbeatData = number | null; + +/** + * https://discord.com/developers/docs/topics/gateway#identify + */ +export interface GatewayIdentify { + op: GatewayOPCodes.Identify; + d: GatewayIdentifyData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#identify + */ +export interface GatewayIdentifyData { + /** + * Authentication token + */ + token: string; + /** + * Connection properties + * + * See https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties + */ + properties: GatewayIdentifyProperties; + /** + * Whether this connection supports compression of packets + * + * @default false + */ + compress?: boolean; + /** + * Value between 50 and 250, total number of members where the gateway will stop sending + * offline members in the guild member list + * + * @default 50 + */ + large_threshold?: number; + /** + * Used for Guild Sharding + * + * See https://discord.com/developers/docs/topics/gateway#sharding + */ + shard?: [shard_id: number, shard_count: number]; + /** + * Presence structure for initial presence information + * + * See https://discord.com/developers/docs/topics/gateway#update-status + */ + presence?: GatewayPresenceUpdateData; + /** + * Enables dispatching of guild subscription events (presence and typing events) + * + * @default true + * @deprecated Use `intents` instead + */ + guild_subscriptions?: boolean; + /** + * The Gateway Intents you wish to receive + * + * See https://discord.com/developers/docs/topics/gateway#gateway-intents + */ + intents: number; +} + +/** + * https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties + */ +export interface GatewayIdentifyProperties { + /** + * Your operating system + */ + $os: string; + /** + * Your library name + */ + $browser: string; + /** + * Your library name + */ + $device: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#resume + */ +export interface GatewayResume { + op: GatewayOPCodes.Resume; + d: GatewayResumeData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#resume + */ +export interface GatewayResumeData { + /** + * Session token + */ + token: string; + /** + * Session id + */ + session_id: string; + /** + * Last sequence number received + */ + seq: number; +} + +/** + * https://discord.com/developers/docs/topics/gateway#request-guild-members + */ +export interface GatewayRequestGuildMembers { + op: GatewayOPCodes.RequestGuildMembers; + d: GatewayRequestGuildMembersData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#request-guild-members + */ +export interface GatewayRequestGuildMembersData { + /** + * ID of the guild to get members for + */ + guild_id: string | string[]; + /** + * String that username starts with, or an empty string to return all members + */ + query?: string; + /** + * Maximum number of members to send matching the `query`; + * a limit of `0` can be used with an empty string `query` to return all members + */ + limit: number; + /** + * Used to specify if we want the presences of the matched members + */ + presences?: boolean; + /** + * Used to specify which users you wish to fetch + */ + user_ids?: string | string[]; + /** + * Nonce to identify the Guild Members Chunk response + * + * See https://discord.com/developers/docs/topics/gateway#guild-members-chunk + */ + nonce?: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#update-voice-state + */ +export interface GatewayVoiceStateUpdate { + op: GatewayOPCodes.VoiceStateUpdate; + d: GatewayVoiceStateUpdateData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#update-voice-state + */ +export interface GatewayVoiceStateUpdateData { + /** + * ID of the guild + */ + guild_id: string; + /** + * ID of the voice channel client wants to join (`null` if disconnecting) + */ + channel_id: string | null; + /** + * Is the client muted + */ + self_mute: boolean; + /** + * Is the client deafened + */ + self_deaf: boolean; +} + +/** + * https://discord.com/developers/docs/topics/gateway#update-status + */ +export interface GatewayUpdatePresence { + op: GatewayOPCodes.PresenceUpdate; + d: GatewayPresenceUpdateData; +} + +/** + * https://discord.com/developers/docs/topics/gateway#update-status-gateway-status-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; + /** + * `null`, or the user's activities + * + * See https://discord.com/developers/docs/topics/gateway#activity-object + */ + activities: GatewayActivityUpdateData[] | null; + /** + * The user's new status + * + * See https://discord.com/developers/docs/topics/gateway#update-status-status-types + */ + status: PresenceUpdateStatus; + /** + * Whether or not the client is afk + */ + afk: boolean; +} + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-structure + */ +export type GatewayActivityUpdateData = Pick; + +// #endregion Sendable Payloads + +// #region Shared +interface BasePayload { + /** + * Opcode for the payload + */ + op: GatewayOPCodes; + /** + * Event data + */ + d?: unknown; + /** + * Sequence number, used for resuming sessions and heartbeats + */ + s: number; + /** + * The event name for this payload + */ + t?: string; +} + +type NonDispatchPayload = Omit; + +interface DataPayload extends BasePayload { + op: GatewayOPCodes.Dispatch; + t: Event; + d: D; +} + +type ReactionData = DataPayload< + E, + Omit< + { + /** + * The id of the user + */ + user_id: string; + /** + * The id of the channel + */ + channel_id: string; + /** + * The id of the message + */ + message_id: string; + /** + * The id of the guild + */ + guild_id?: string; + /** + * The member who reacted if this happened in a guild + * + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ + member?: APIGuildMember; + /** + * The emoji used to react + * + * See https://discord.com/developers/docs/resources/emoji#emoji-object + */ + emoji: APIEmoji; + }, + O + > +>; + +interface MessageReactionRemoveData { + /** + * The id of the channel + */ + channel_id: string; + /** + * The id of the message + */ + message_id: string; + /** + * The id of the guild + */ + guild_id?: string; +} +// #endregion Shared diff --git a/.deno/v8/mod.ts b/.deno/v8/mod.ts new file mode 100644 index 00000000..d00f5b1f --- /dev/null +++ b/.deno/v8/mod.ts @@ -0,0 +1,4 @@ +export * from '../common/mod.ts'; +export * from './gateway/mod.ts'; +export * from './payloads/mod.ts'; +export * from './rest/mod.ts'; diff --git a/.deno/v8/payloads/auditLog.ts b/.deno/v8/payloads/auditLog.ts new file mode 100644 index 00000000..c2c3836e --- /dev/null +++ b/.deno/v8/payloads/auditLog.ts @@ -0,0 +1,531 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/audit-log + */ + +import type { APIOverwrite, ChannelType } from './channel.ts'; +import type { + APIGuildIntegration, + GuildDefaultMessageNotifications, + GuildExplicitContentFilter, + GuildMFALevel, + GuildVerificationLevel, + IntegrationExpireBehavior, +} from './guild.ts'; +import type { APIRole } from './permissions.ts'; +import type { APIUser } from './user.ts'; +import type { APIWebhook } from './webhook.ts'; + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure + */ +export interface APIAuditLog { + /** + * Webhooks found in the audit log + * + * See https://discord.com/developers/docs/resources/webhook#webhook-object + */ + webhooks: APIWebhook[]; + /** + * Users found in the audit log + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + users: APIUser[]; + /** + * Audit log entries + * + * See https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object + */ + audit_log_entries: APIAuditLogEntry[]; + /** + * Partial integration objects + * + * See https://discord.com/developers/docs/resources/guild#integration-object + */ + integrations: APIGuildIntegration[]; +} + +/** + * 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 + * + * *Against all odds, this can be `null` in some cases (webhooks deleting themselves + * by using their own token, for example)* + */ + user_id: string | null; + /** + * ID of the entry + */ + id: string; + /** + * 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 const enum AuditLogEvent { + GUILD_UPDATE = 1, + + CHANNEL_CREATE = 10, + CHANNEL_UPDATE, + CHANNEL_DELETE, + CHANNEL_OVERWRITE_CREATE, + CHANNEL_OVERWRITE_UPDATE, + CHANNEL_OVERWRITE_DELETE, + + MEMBER_KICK = 20, + MEMBER_PRUNE, + MEMBER_BAN_ADD, + MEMBER_BAN_REMOVE, + MEMBER_UPDATE, + MEMBER_ROLE_UPDATE, + MEMBER_MOVE, + MEMBER_DISCONNECT, + BOT_ADD, + + ROLE_CREATE = 30, + ROLE_UPDATE, + ROLE_DELETE, + + INVITE_CREATE = 40, + INVITE_UPDATE, + INVITE_DELETE, + + WEBHOOK_CREATE = 50, + WEBHOOK_UPDATE, + WEBHOOK_DELETE, + + EMOJI_CREATE = 60, + EMOJI_UPDATE, + EMOJI_DELETE, + + MESSAGE_DELETE = 72, + MESSAGE_BULK_DELETE, + MESSAGE_PIN, + MESSAGE_UNPIN, + + INTEGRATION_CREATE = 80, + INTEGRATION_UPDATE, + INTEGRATION_DELETE, +} + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info + */ +export interface APIAuditLogOptions { + /** + * Number of days after which inactive members were kicked + * + * Present from: + * - MEMBER_PRUNE + */ + delete_member_days?: string; + /** + * Number of members removed by the prune + * + * Present from: + * - MEMBER_PRUNE + */ + members_removed?: string; + + /** + * Channel in which the entities were targeted + * + * Present from: + * - MEMBER_MOVE + * - MESSAGE_PIN + * - MESSAGE_UNPIN + * - MESSAGE_DELETE + */ + channel_id?: string; + + /** + * ID of the message that was targeted + * + * Present from: + * - MESSAGE_PIN + * - MESSAGE_UNPIN + */ + message_id?: string; + + /** + * 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?: string; + + /** + * Type of overwritten entity - "0" for "role" or "1" for "member" + * + * Present from: + * - CHANNEL_OVERWRITE_CREATE + * - CHANNEL_OVERWRITE_UPDATE + * - CHANNEL_OVERWRITE_DELETE + * + * {@link AuditLogOptionsType} + */ + type?: AuditLogOptionsType; + + /** + * Name of the role + * + * Present from: + * - CHANNEL_OVERWRITE_CREATE + * - CHANNEL_OVERWRITE_UPDATE + * - CHANNEL_OVERWRITE_DELETE + * + * **Present only if the {@link APIAuditLogOptions#type entry type} is "0"** + */ + role_name?: string; +} + +export const enum AuditLogOptionsType { + Role = '0', + Member = '1', +} + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure + */ +export type APIAuditLogChange = + | APIAuditLogChangeKeyName + | APIAuditLogChangeKeyIconHash + | APIAuditLogChangeKeySplashHash + | APIAuditLogChangeKeyOwnerID + | APIAuditLogChangeKeyRegion + | APIAuditLogChangeKeyAFKChannelID + | APIAuditLogChangeKeyAFKTimeout + | APIAuditLogChangeKeyMFALevel + | APIAuditLogChangeKeyVerificationLevel + | APIAuditLogChangeKeyExplicitContentFilter + | APIAuditLogChangeKeyDefaultMessageNotifications + | APIAuditLogChangeKeyVanityURLCode + | APIAuditLogChangeKey$Add + | APIAuditLogChangeKey$Remove + | APIAuditLogChangeKeyPruneDeleteDays + | APIAuditLogChangeKeyWidgetEnabled + | APIAuditLogChangeKeyWidgetChannelID + | APIAuditLogChangeKeySystemChannelID + | APIAuditLogChangeKeyPosition + | APIAuditLogChangeKeyTopic + | APIAuditLogChangeKeyBitrate + | APIAuditLogChangeKeyPermissionOverwrites + | APIAuditLogChangeKeyNSFW + | APIAuditLogChangeKeyApplicationID + | APIAuditLogChangeKeyRateLimitPerUser + | APIAuditLogChangeKeyPermissions + | APIAuditLogChangeKeyColor + | APIAuditLogChangeKeyHoist + | APIAuditLogChangeKeyMentionable + | APIAuditLogChangeKeyAllow + | APIAuditLogChangeKeyDeny + | APIAuditLogChangeKeyCode + | APIAuditLogChangeKeyChannelID + | APIAuditLogChangeKeyInviterID + | APIAuditLogChangeKeyMaxUses + | APIAuditLogChangeKeyUses + | APIAuditLogChangeKeyMaxAge + | APIAuditLogChangeKeyTemporary + | APIAuditLogChangeKeyDeaf + | APIAuditLogChangeKeyMute + | APIAuditLogChangeKeyNick + | APIAuditLogChangeKeyAvatarHash + | APIAuditLogChangeKeyID + | APIAuditLogChangeKeyType + | APIAuditLogChangeKeyEnableEmoticons + | APIAuditLogChangeKeyExpireBehavior + | APIAuditLogChangeKeyExpireGracePeriod; + +/** + * Returned when a guild's name is changed + */ +export type APIAuditLogChangeKeyName = AuditLogChangeData<'name', string>; + +/** + * Returned when a guild's icon is changed + */ +export type APIAuditLogChangeKeyIconHash = AuditLogChangeData<'icon_hash', string>; + +/** + * Returned when a guild's splash is changed + */ +export type APIAuditLogChangeKeySplashHash = AuditLogChangeData<'splash_hash', string>; + +/** + * Returned when a guild's owner ID is changed + */ +export type APIAuditLogChangeKeyOwnerID = AuditLogChangeData<'owner_id', string>; + +/** + * Returned when a guild's region is changed + */ +export type APIAuditLogChangeKeyRegion = AuditLogChangeData<'region', string>; + +/** + * Returned when a guild's afk_channel_id is changed + */ +export type APIAuditLogChangeKeyAFKChannelID = AuditLogChangeData<'afk_channel_id', string>; + +/** + * Returned when a guild's afk_timeout is changed + */ +export type APIAuditLogChangeKeyAFKTimeout = AuditLogChangeData<'afk_timeout', number>; + +/** + * Returned when a guild's mfa_level is changed + */ +export type APIAuditLogChangeKeyMFALevel = AuditLogChangeData<'mfa_level', GuildMFALevel>; + +/** + * Returned when a guild's verification_level is changed + */ +export type APIAuditLogChangeKeyVerificationLevel = AuditLogChangeData<'verification_level', GuildVerificationLevel>; + +/** + * Returned when a guild's explicit_content_filter is changed + */ +export type APIAuditLogChangeKeyExplicitContentFilter = AuditLogChangeData< + 'explicit_content_filter', + GuildExplicitContentFilter +>; + +/** + * Returned when a guild's default_message_notifications is changed + */ +export type APIAuditLogChangeKeyDefaultMessageNotifications = AuditLogChangeData< + 'default_message_notifications', + GuildDefaultMessageNotifications +>; + +/** + * Returned when a guild's vanity_url_code is changed + */ +export type APIAuditLogChangeKeyVanityURLCode = AuditLogChangeData<'vanity_url_code', string>; + +/** + * Returned when new role(s) are added + */ +export type APIAuditLogChangeKey$Add = AuditLogChangeData<'$add', APIRole[]>; + +/** + * Returned when role(s) are removed + */ +export type APIAuditLogChangeKey$Remove = AuditLogChangeData<'$remove', APIRole[]>; + +/** + * Returned when there is a change in number of days after which inactive and role-unassigned members are kicked + */ +export type APIAuditLogChangeKeyPruneDeleteDays = AuditLogChangeData<'prune_delete_days', number>; + +/** + * Returned when a guild's widget is enabled + */ +export type APIAuditLogChangeKeyWidgetEnabled = AuditLogChangeData<'widget_enabled', boolean>; + +/** + * Returned when a guild's widget_channel_id is changed + */ +export type APIAuditLogChangeKeyWidgetChannelID = AuditLogChangeData<'widget_channel_id', string>; + +/** + * Returned when a guild's system_channel_id is changed + */ +export type APIAuditLogChangeKeySystemChannelID = AuditLogChangeData<'system_channel_id', string>; + +/** + * 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', string>; + +/** + * Returned when a channel's amount of seconds a user has to wait before sending another message + * is changed + */ +export type APIAuditLogChangeKeyRateLimitPerUser = AuditLogChangeData<'rate_limit_per_user', number>; + +/** + * Returned when a permission bitfield is changed + */ +export type APIAuditLogChangeKeyPermissions = AuditLogChangeData<'permissions', string>; + +/** + * Returned when a role's color is changed + */ +export type APIAuditLogChangeKeyColor = AuditLogChangeData<'color', number>; + +/** + * Returned when a role's hoist status is changed + */ +export type APIAuditLogChangeKeyHoist = AuditLogChangeData<'hoist', boolean>; + +/** + * Returned when a role's mentionable status is changed + */ +export type APIAuditLogChangeKeyMentionable = AuditLogChangeData<'mentionable', boolean>; + +/** + * Returned when an overwrite's allowed permissions bitfield is changed + */ +export type APIAuditLogChangeKeyAllow = AuditLogChangeData<'allow', string>; + +/** + * Returned when an overwrite's denied permissions bitfield is changed + */ +export type APIAuditLogChangeKeyDeny = AuditLogChangeData<'deny', string>; + +/** + * Returned when an invite's code is changed + */ +export type APIAuditLogChangeKeyCode = AuditLogChangeData<'code', string>; + +/** + * Returned when an invite's channel_id is changed + */ +export type APIAuditLogChangeKeyChannelID = AuditLogChangeData<'channel_id', string>; + +/** + * Returned when an invite's inviter_id is changed + */ +export type APIAuditLogChangeKeyInviterID = AuditLogChangeData<'inviter_id', string>; + +/** + * 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<'mute', boolean>; + +/** + * 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', string>; + +/** + * The type of entity created + */ +export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', ChannelType | 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>; + +/** + * @internal + */ +interface AuditLogChangeData { + key: K; + new_value?: D; + old_value?: D; +} diff --git a/.deno/v8/payloads/channel.ts b/.deno/v8/payloads/channel.ts new file mode 100644 index 00000000..8e7b5540 --- /dev/null +++ b/.deno/v8/payloads/channel.ts @@ -0,0 +1,911 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/channel + */ + +import type { APIPartialEmoji } from './emoji.ts'; +import type { APIGuildMember } from './guild.ts'; +import type { APIUser } from './user.ts'; + +/** + * Not documented, but partial only includes id, name, and type + */ +export interface APIPartialChannel { + /** + * The id of the channel + */ + id: string; + /** + * The type of the channel + * + * See https://discord.com/developers/docs/resources/channel#channel-object-channel-types + */ + type: ChannelType; + /** + * The name of the channel (2-100 characters) + */ + name?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#channel-object-channel-structure + */ +export interface APIChannel extends APIPartialChannel { + /** + * The id of the guild + */ + guild_id?: string; + /** + * Sorting position of the channel + */ + position?: number; + /** + * Explicit permission overwrites for members and roles + * + * See https://discord.com/developers/docs/resources/channel#overwrite-object + */ + permission_overwrites?: APIOverwrite[]; + /** + * The channel topic (0-1024 characters) + */ + topic?: string | null; + /** + * Whether the channel is nsfw + */ + nsfw?: boolean; + /** + * The id of the last message sent in this channel (may not point to an existing or valid message) + */ + last_message_id?: string | null; + /** + * The bitrate (in bits) of the voice channel + */ + bitrate?: number; + /** + * The user limit of the voice channel + */ + user_limit?: number; + /** + * Amount of seconds a user has to wait before sending another message (0-21600); + * bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected + */ + rate_limit_per_user?: number; + /** + * The recipients of the DM + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + recipients?: APIUser[]; + /** + * Icon hash + */ + icon?: string | null; + /** + * ID of the DM creator + */ + owner_id?: string; + /** + * Application id of the group DM creator if it is bot-created + */ + application_id?: string; + /** + * ID of the parent category for a channel (each parent category can contain up to 50 channels) + */ + parent_id?: string | null; + /** + * When the last pinned message was pinned. + * This may be `null` in events such as `GUILD_CREATE` when a message is not pinned + */ + last_pin_timestamp?: string | null; +} + +/** + * https://discord.com/developers/docs/resources/channel#channel-object-channel-types + */ +export const enum ChannelType { + /** + * A text channel within a guild + */ + GUILD_TEXT = 0, + /** + * A direct message between users + */ + DM, + /** + * A voice channel within a guild + */ + GUILD_VOICE, + /** + * A direct message between multiple users + */ + GROUP_DM, + /** + * An organizational category that contains up to 50 channels + * + * See https://support.discord.com/hc/en-us/articles/115001580171-Channel-Categories-101 + */ + GUILD_CATEGORY, + /** + * A channel that users can follow and crosspost into their own guild + * + * See https://support.discord.com/hc/en-us/articles/360032008192 + */ + GUILD_NEWS, + /** + * A channel in which game developers can sell their game on Discord + * + * See https://discord.com/developers/docs/game-and-server-management/special-channels + */ + GUILD_STORE, +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-structure + */ +export interface APIMessage { + /** + * ID of the message + */ + id: string; + /** + * ID of the channel the message was sent in + */ + channel_id: string; + /** + * ID of the guild the message was sent in + */ + guild_id?: string; + /** + * The author of this message (only a valid user in the case where the message is generated by a user or bot user) + * + * If the message is generated by a webhook, the author object corresponds to the webhook's id, + * username, and avatar. You can tell if a message is generated by a webhook by checking for the `webhook_id` property + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + author: APIUser; + /** + * Member properties for this message's author + * + * The member object exists in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events + * from text-based guild channels + * + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ + member?: APIGuildMember; + /** + * Contents of the message + */ + content: string; + /** + * When this message was sent + */ + timestamp: string; + /** + * When this message was edited (or null if never) + */ + edited_timestamp: string | null; + /** + * Whether this was a TTS message + */ + tts: boolean; + /** + * Whether this message mentions everyone + */ + mention_everyone: boolean; + /** + * Users specifically mentioned in the message + * + * The `member` field is only present in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events + * from text-based guild channels + * + * See https://discord.com/developers/docs/resources/user#user-object + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ + mentions: (APIUser & { member?: Omit })[]; + /** + * Roles specifically mentioned in this message + * + * See https://discord.com/developers/docs/topics/permissions#role-object + */ + mention_roles: string[]; + /** + * Channels specifically mentioned in this message + * + * Not all channel mentions in a message will appear in `mention_channels`. + * - Only textual channels that are visible to everyone in a lurkable guild will ever be included + * - Only crossposted messages (via Channel Following) currently include `mention_channels` at all + * + * If no mentions in the message meet these requirements, this field will not be sent + * + * See https://discord.com/developers/docs/resources/channel#channel-mention-object + */ + mention_channels?: APIChannelMention[]; + /** + * Any attached files + * + * See https://discord.com/developers/docs/resources/channel#attachment-object + */ + attachments: APIAttachment[]; + /** + * Any embedded content + * + * See https://discord.com/developers/docs/resources/channel#embed-object + */ + embeds: APIEmbed[]; + /** + * Reactions to the message + * + * See https://discord.com/developers/docs/resources/channel#reaction-object + */ + reactions?: APIReaction[]; + /** + * Used for validating a message was sent + * + * **You will not receive this from further fetches. This is received only once from a `MESSAGE_CREATE` + * event to ensure it got sent** + */ + nonce?: string | number; + /** + * Whether this message is pinned + */ + pinned: boolean; + /** + * If the message is generated by a webhook, this is the webhook's id + */ + webhook_id?: string; + /** + * Type of message + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-types + */ + type: MessageType; + /** + * Sent with Rich Presence-related chat embeds + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure + */ + activity?: APIMessageActivity; + /** + * Sent with Rich Presence-related chat embeds + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-application-structure + */ + application?: APIMessageApplication; + /** + * Reference data sent with crossposted messages and replies + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure + */ + message_reference?: APIMessageReference; + /** + * Message flags combined as a bitfield + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-flags + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + flags?: MessageFlags; + /** + * The stickers sent with the message (bots currently can only receive messages with stickers, not send) + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure + */ + stickers?: APISticker[]; + /** + * 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; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-types + */ +export const enum MessageType { + DEFAULT, + RECIPIENT_ADD, + RECIPIENT_REMOVE, + CALL, + CHANNEL_NAME_CHANGE, + CHANNEL_ICON_CHANGE, + CHANNEL_PINNED_MESSAGE, + GUILD_MEMBER_JOIN, + USER_PREMIUM_GUILD_SUBSCRIPTION, + USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1, + USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2, + USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3, + CHANNEL_FOLLOW_ADD, + GUILD_DISCOVERY_DISQUALIFIED = 14, + GUILD_DISCOVERY_REQUALIFIED, + GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING, + GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING, + REPLY = 19, + APPLICATION_COMMAND, +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure + */ +export interface APIMessageActivity { + /** + * Type of message activity + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-activity-types + */ + type: MessageActivityType; + /** + * `party_id` from a Rich Presence event + * + * See https://discord.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields + */ + party_id?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-application-structure + */ +export interface APIMessageApplication { + /** + * ID of the application + */ + id: string; + /** + * ID of the embed's image asset + */ + cover_image?: string; + /** + * Application's description + */ + description: string; + /** + * ID of the application's icon + */ + icon: string | null; + /** + * Name of the application + */ + name: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure + */ +export interface APIMessageReference { + /** + * ID of the originating message + */ + message_id?: string; + /** + * ID of the originating message's channel + */ + channel_id: string; + /** + * ID of the originating message's guild + */ + guild_id?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-activity-types + */ +export const enum MessageActivityType { + JOIN = 1, + SPECTATE, + LISTEN, + JOIN_REQUEST = 5, +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-flags + */ +export const 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) + */ + IS_CROSSPOST = 1 << 1, + /** + * Do not include any embeds when serializing this message + */ + SUPPRESS_EMBEDS = 1 << 2, + /** + * The source message for this crosspost has been deleted (via Channel Following) + */ + SOURCE_MESSAGE_DELETED = 1 << 3, + /** + * This message came from the urgent message system + */ + URGENT = 1 << 4, + EPHEMERAL = 1 << 6, +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure + */ +export interface APISticker { + /** + * ID of the sticker + */ + id: string; + /** + * ID of the pack the sticker is from + */ + pack_id: string; + /** + * Name of the sticker + */ + name: string; + /** + * Description of the sticker + */ + description: string; + /** + * A comma-separated list of tags for the sticker + */ + tags?: string; + /** + * Sticker asset hash + */ + asset: string; + /** + * Sticker preview asset hash + */ + preview_asset: string | null; + /** + * Type of sticker format + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types + */ + format_type: StickerFormatType; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types + */ +export const enum StickerFormatType { + PNG = 1, + APNG, + LOTTIE, +} + +/** + * https://discord.com/developers/docs/resources/channel#followed-channel-object + */ +export interface APIFollowedChannel { + /** + * Source channel id + */ + channel_id: string; + /** + * Created target webhook id + */ + webhook_id: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#reaction-object-reaction-structure + */ +export interface APIReaction { + /** + * Times this emoji has been used to react + */ + count: number; + /** + * Whether the current user reacted using this emoji + */ + me: boolean; + /** + * Emoji information + * + * See https://discord.com/developers/docs/resources/emoji#emoji-object + */ + emoji: APIPartialEmoji; +} + +/** + * https://discord.com/developers/docs/resources/channel#overwrite-object-overwrite-structure + */ +export interface APIOverwrite { + /** + * Role or user id + */ + id: string; + /** + * 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: string; + /** + * Permission bit set + * + * See https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + deny: string; +} + +export const enum OverwriteType { + Role, + Member, +} + +/** + * 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: 2048 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 const enum EmbedType { + /** + * Generic embed rendered from embed attributes + */ + Rich = 'rich', + /** + * Image embed + */ + Image = 'image', + /** + * Video embed + */ + Video = 'video', + /** + * Animated gif image embed rendered as a video embed + */ + GifV = 'gifv', + /** + * Article embed + */ + Article = 'article', + /** + * Link embed + */ + Link = 'link', +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure + */ +export interface APIEmbedThumbnail { + /** + * Source url of thumbnail (only supports http(s) and attachments) + */ + url?: string; + /** + * A proxied url of the thumbnail + */ + proxy_url?: string; + /** + * Height of thumbnail + */ + height?: number; + /** + * Width of thumbnail + */ + width?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure + */ +export interface APIEmbedVideo { + /** + * Source url of video + */ + url?: string; + /** + * Height of video + */ + height?: number; + /** + * Width of video + */ + width?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure + */ +export interface APIEmbedImage { + /** + * Source url of image (only supports http(s) and attachments) + */ + url?: string; + /** + * A proxied url of the image + */ + proxy_url?: string; + /** + * Height of image + */ + height?: number; + /** + * Width of image + */ + width?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure + */ +export interface APIEmbedProvider { + /** + * Name of provider + */ + name?: string; + /** + * URL of provider + */ + url?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure + */ +export interface APIEmbedAuthor { + /** + * Name of author + * + * Length limit: 256 characters + */ + name?: string; + /** + * URL of author + */ + url?: string; + /** + * URL of author icon (only supports http(s) and attachments) + */ + icon_url?: string; + /** + * A proxied url of author icon + */ + proxy_icon_url?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure + */ +export interface APIEmbedFooter { + /** + * Footer text + * + * Length limit: 2048 characters + */ + text: string; + /** + * URL of footer icon (only supports http(s) and attachments) + */ + icon_url?: string; + /** + * A proxied url of footer icon + */ + proxy_icon_url?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure + */ +export interface APIEmbedField { + /** + * Name of the field + * + * Length limit: 256 characters + */ + name: string; + /** + * Value of the field + * + * Length limit: 1024 characters + */ + value: string; + /** + * Whether or not this field should display inline + */ + inline?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/channel#attachment-object-attachment-structure + */ +export interface APIAttachment { + /** + * Attachment id + */ + id: string; + /** + * Name of file attached + */ + filename: 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; +} + +/** + * https://discord.com/developers/docs/resources/channel#channel-mention-object-channel-mention-structure + */ +export interface APIChannelMention { + /** + * ID of the channel + */ + id: string; + /** + * ID of the guild containing the channel + */ + guild_id: string; + /** + * 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 const 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?: string[]; + /** + * Array of user_ids to mention (Max size of 100) + */ + users?: string[]; + /** + * For replies, whether to mention the author of the message being replied to (default false) + * + * @default false + */ + replied_user?: boolean; +} diff --git a/.deno/v8/payloads/emoji.ts b/.deno/v8/payloads/emoji.ts new file mode 100644 index 00000000..cd751328 --- /dev/null +++ b/.deno/v8/payloads/emoji.ts @@ -0,0 +1,49 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/emoji + */ + +import type { APIUser } from './user.ts'; + +/** + * Not documented but mentioned + */ +export interface APIPartialEmoji { + /** + * Emoji id + */ + id: string | null; + /** + * Emoji name (can be null only in reaction emoji objects) + */ + name: string | null; + /** + * Whether this emoji is animated + */ + animated?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure + */ +export interface APIEmoji extends APIPartialEmoji { + /** + * Roles this emoji is whitelisted to + */ + roles?: string[]; + /** + * User that created this emoji + */ + user?: APIUser; + /** + * Whether this emoji must be wrapped in colons + */ + require_colons?: boolean; + /** + * Whether this emoji is managed + */ + managed?: boolean; + /** + * Whether this emoji can be used, may be false due to loss of Server Boosts + */ + available?: boolean; +} diff --git a/.deno/v8/payloads/gateway.ts b/.deno/v8/payloads/gateway.ts new file mode 100644 index 00000000..cc6e53e8 --- /dev/null +++ b/.deno/v8/payloads/gateway.ts @@ -0,0 +1,304 @@ +/** + * Types extracted from https://discord.com/developers/docs/topics/gateway + */ + +import type { APIEmoji } from './emoji.ts'; +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/topics/gateway#get-gateway + */ +export interface APIGatewayInfo { + /** + * The WSS URL that can be used for connecting to the gateway + */ + url: string; +} + +/** + * https://discord.com/developers/docs/topics/gateway#get-gateway-bot + */ +export interface APIGatewayBotInfo extends APIGatewayInfo { + /** + * The recommended number of shards to use when connecting + * + * See https://discord.com/developers/docs/topics/gateway#sharding + */ + shards: number; + /** + * Information on the current session start limit + * + * See https://discord.com/developers/docs/topics/gateway#session-start-limit-object + */ + session_start_limit: APIGatewaySessionStartLimit; +} + +/** + * https://discord.com/developers/docs/topics/gateway#session-start-limit-object + */ +export interface APIGatewaySessionStartLimit { + /** + * The total number of session starts the current user is allowed + */ + total: number; + /** + * The remaining number of session starts the current user is allowed + */ + remaining: number; + /** + * The number of milliseconds after which the limit resets + */ + reset_after: number; + /** + * The number of identify requests allowed per 5 seconds + */ + max_concurrency: number; +} + +/** + * https://discord.com/developers/docs/topics/gateway#presence-update-presence-update-event-fields + */ +export interface GatewayPresenceUpdate { + /** + * The user presence is being updated for + * + * **The user object within this event can be partial, the only field which must be sent is the `id` field, + * everything else is optional.** + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + user: Partial & { + id: string; + }; + /** + * ID of the guild + */ + guild_id: string; + /** + * Either "idle", "dnd", "online", or "offline" + */ + status?: PresenceUpdateStatus; + /** + * User's current activities + * + * See https://discord.com/developers/docs/topics/gateway#activity-object + */ + activities?: GatewayActivity[]; + /** + * User's platform-dependent status + * + * See https://discord.com/developers/docs/topics/gateway#client-status-object + */ + client_status?: GatewayPresenceClientStatus; +} + +export const enum PresenceUpdateStatus { + Online = 'online', + DoNotDisturb = 'dnd', + Idle = 'idle', + /** + * Invisible and shown as offline + */ + Invisible = 'invisible', + Offline = 'offline', +} + +/** + * https://discord.com/developers/docs/topics/gateway#client-status-object + */ +export interface GatewayPresenceClientStatus { + /** + * The user's status set for an active desktop (Windows, Linux, Mac) application session + */ + desktop?: PresenceUpdateStatus; + /** + * The user's status set for an active mobile (iOS, Android) application session + */ + mobile?: PresenceUpdateStatus; + /** + * The user's status set for an active web (browser, bot account) application session + */ + web?: PresenceUpdateStatus; +} + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-structure + */ +export interface GatewayActivity { + /** + * The activity's id + */ + id: string; + /** + * The activity's name + */ + name: string; + /** + * Activity type + * + * See https://discord.com/developers/docs/topics/gateway#activity-object-activity-types + */ + type: ActivityType; + /** + * Stream url, is validated when type is `1` + */ + url?: string | null; + /** + * Unix timestamp of when the activity was added to the user's session + */ + created_at: number; + /** + * Unix timestamps for start and/or end of the game + */ + timestamps?: GatewayActivityTimestamps; + sync_id?: string; + platform?: ActivityPlatform; + /** + * Application id for the game + */ + application_id?: string; + /** + * What the player is currently doing + */ + details?: string | null; + /** + * The user's current party status + */ + state?: string | null; + /** + * The emoji used for a custom status + * + * See https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji + */ + emoji?: GatewayActivityEmoji; + session_id?: string; + /** + * Information for the current party of the player + * + * See https://discord.com/developers/docs/topics/gateway#activity-object-activity-party + */ + party?: GatewayActivityParty; + /** + * Images for the presence and their hover texts + * + * See https://discord.com/developers/docs/topics/gateway#activity-object-activity-assets + */ + assets?: GatewayActivityAssets; + /** + * Secrets for Rich Presence joining and spectating + * + * See https://discord.com/developers/docs/topics/gateway#activity-object-activity-secrets + */ + secrets?: GatewayActivitySecrets; + /** + * Whether or not the activity is an instanced game session + */ + instance?: boolean; + /** + * Activity flags `OR`d together, describes what the payload includes + * + * See https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + flags?: ActivityFlags; + buttons?: string[] | GatewayActivityButton[]; +} + +export enum ActivityPlatform { + Desktop = 'desktop', + Samsung = 'samsung', + Xbox = 'xbox', +} + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-types + */ +export const enum ActivityType { + /** + * Playing {game} + */ + Game, + /** + * Streaming {details} + */ + Streaming, + /** + * Listening to {name} + */ + Listening, + /** + * Watching {details} + */ + Watching, + /** + * {emoji} {details} + */ + Custom, + /** + * Competing in {name} + */ + Competing, +} + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-timestamps + */ +export interface GatewayActivityTimestamps { + /** + * Unix time (in milliseconds) of when the activity started + */ + start?: number; + /** + * Unix time (in milliseconds) of when the activity ends + */ + end?: number; +} + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji + */ +export type GatewayActivityEmoji = Partial> & Pick; + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-party + */ +export interface GatewayActivityParty { + /** + * The id of the party + */ + id?: string; + /** + * Used to show the party's current and maximum size + */ + size?: [current_size: number, max_size: number]; +} + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-assets + */ +export type GatewayActivityAssets = Partial< + Record<'large_image' | 'large_text' | 'small_image' | 'small_text', string> +>; + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-secrets + */ +export type GatewayActivitySecrets = Partial>; + +/** + * https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags + */ +export const enum ActivityFlags { + INSTANCE = 1 << 0, + JOIN = 1 << 1, + SPECTATE = 1 << 2, + JOIN_REQUEST = 1 << 3, + SYNC = 1 << 4, + PLAY = 1 << 5, +} + +export interface GatewayActivityButton { + label: string; + url: string; +} diff --git a/.deno/v8/payloads/guild.ts b/.deno/v8/payloads/guild.ts new file mode 100644 index 00000000..ce4bdd3e --- /dev/null +++ b/.deno/v8/payloads/guild.ts @@ -0,0 +1,855 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/guild + */ + +import type { APIChannel } from './channel.ts'; +import type { APIEmoji } from './emoji.ts'; +import type { GatewayPresenceUpdate, PresenceUpdateStatus } from './gateway.ts'; +import type { APIRole } from './permissions.ts'; +import type { APIUser } from './user.ts'; +import type { GatewayVoiceState } from './voice.ts'; + +/** + * https://discord.com/developers/docs/resources/guild#unavailable-guild-object + */ +export interface APIUnavailableGuild { + /** + * Guild id + */ + id: string; + /** + * `true` if this guild is unavailable due to an outage + */ + unavailable: boolean; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-guild-structure + */ +export interface APIPartialGuild extends Omit, Pick { + /** + * Guild name (2-100 characters, excluding trailing and leading whitespace) + */ + name: string; + /** + * Icon hash + * + * See https://discord.com/developers/docs/reference#image-formatting + */ + icon: string | null; + /** + * Splash hash + * + * See https://discord.com/developers/docs/reference#image-formatting + */ + splash: string | null; + /** + * Banner hash + * + * See https://discord.com/developers/docs/reference#image-formatting + */ + banner?: string | null; + /** + * The description for the guild, if the guild is discoverable + */ + description?: string | null; + /** + * Enabled guild features + * + * See https://discord.com/developers/docs/resources/guild#guild-object-guild-features + */ + features?: GuildFeature[]; + /** + * Verification level required for the guild + * + * See https://discord.com/developers/docs/resources/guild#guild-object-verification-level + */ + verification_level?: GuildVerificationLevel; + /** + * The vanity url code for the guild + */ + vanity_url_code?: string | null; + /** + * `true` if this guild is unavailable due to an outage + */ + unavailable?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-guild-structure + */ +export interface APIGuild extends APIPartialGuild { + /** + * Icon hash, returned when in the template object + * + * See https://discord.com/developers/docs/reference#image-formatting + */ + icon_hash?: string | null; + /** + * Discovery splash hash; only present for guilds with the "DISCOVERABLE" feature + * + * See https://discord.com/developers/docs/reference#image-formatting + */ + discovery_splash: string | null; + /** + * `true` if the user is the owner of the guild + * + * **This field is only received from https://discord.com/developers/docs/resources/user#get-current-user-guilds** + */ + owner?: boolean; + /** + * ID of owner + */ + owner_id: string; + /** + * Total permissions for the user in the guild (excludes overrides) + * + * **This field is only received from https://discord.com/developers/docs/resources/user#get-current-user-guilds** + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + permissions?: string; + /** + * Voice region id for the guild + * + * See https://discord.com/developers/docs/resources/voice#voice-region-object + */ + region: string; + /** + * ID of afk channel + */ + afk_channel_id: string | null; + /** + * afk timeout in seconds + */ + afk_timeout: number; + /** + * `true` if the guild widget is enabled + */ + widget_enabled?: boolean; + /** + * The channel id that the widget will generate an invite to, or `null` if set to no invite + */ + widget_channel_id?: string | null; + /** + * Verification level required for the guild + * + * See https://discord.com/developers/docs/resources/guild#guild-object-verification-level + */ + verification_level: GuildVerificationLevel; + /** + * Default message notifications level + * + * See https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level + */ + default_message_notifications: GuildDefaultMessageNotifications; + /** + * Explicit content filter level + * + * See https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level + */ + explicit_content_filter: GuildExplicitContentFilter; + /** + * Roles in the guild + * + * See https://discord.com/developers/docs/topics/permissions#role-object + */ + roles: APIRole[]; + /** + * Custom guild emojis + * + * See https://discord.com/developers/docs/resources/emoji#emoji-object + */ + emojis: APIEmoji[]; + /** + * Enabled guild features + * + * See https://discord.com/developers/docs/resources/guild#guild-object-guild-features + */ + features: GuildFeature[]; + /** + * Required MFA level for the guild + * + * See https://discord.com/developers/docs/resources/guild#guild-object-mfa-level + */ + mfa_level: GuildMFALevel; + /** + * Application id of the guild creator if it is bot-created + */ + application_id: string | null; + /** + * The id of the channel where guild notices such as welcome messages and boost events are posted + */ + system_channel_id: string | null; + /** + * System channel flags + * + * See https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags + */ + system_channel_flags: GuildSystemChannelFlags; + /** + * The id of the channel where Community guilds can display rules and/or guidelines + */ + rules_channel_id: string | null; + /** + * When this guild was joined at + * + * **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#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#guild-create) event** + */ + large?: boolean; + /** + * Total number of members in this guild + * + * **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#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#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#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#guild-create) event** + * + * See https://discord.com/developers/docs/resources/channel#channel-object + */ + channels?: 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#guild-create) event** + * + * See https://discord.com/developers/docs/topics/gateway#presence-update + */ + presences?: GatewayPresenceUpdate[]; + /** + * The maximum number of presences for the guild (the default value, currently 25000, is in effect when `null` is returned) + */ + max_presences?: number | null; + /** + * The maximum number of members for the guild + */ + max_members?: number; + /** + * The vanity url code for the guild + */ + vanity_url_code: string | null; + /** + * The description for the guild, if the guild is discoverable + */ + description: string | null; + /** + * Banner hash + * + * See https://discord.com/developers/docs/reference#image-formatting + */ + banner: string | null; + /** + * Premium tier (Server Boost level) + * + * See https://discord.com/developers/docs/resources/guild#guild-object-premium-tier + */ + premium_tier: GuildPremiumTier; + /** + * The number of boosts this guild currently has + */ + premium_subscription_count?: number; + /** + * The preferred locale of a Community guild; used in guild discovery and notices from Discord; defaults to "en-US" + * + * @default "en-US" + */ + preferred_locale: string; + /** + * The id of the channel where admins and moderators of Community guilds receive notices from Discord + */ + public_updates_channel_id: string | null; + /** + * The maximum amount of users in a video channel + */ + max_video_channel_users?: number; + /** + * **This field is only received from https://discord.com/developers/docs/resources/guild#get-guild with the `with_counts` query parameter set to `true`** + */ + approximate_member_count?: number; + /** + * **This field is only received from https://discord.com/developers/docs/resources/guild#get-guild with the `with_counts` query parameter set to `true`** + */ + approximate_presence_count?: number; + welcome_screen?: APIGuildWelcomeScreen; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level + */ +export const enum GuildDefaultMessageNotifications { + ALL_MESSAGES, + ONLY_MENTIONS, +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level + */ +export const enum GuildExplicitContentFilter { + DISABLED, + MEMBERS_WITHOUT_ROLES, + ALL_MEMBERS, +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-mfa-level + */ +export const enum GuildMFALevel { + NONE, + ELEVATED, +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-verification-level + */ +export const enum GuildVerificationLevel { + /** + * Unrestricted + */ + NONE, + /** + * Must have verified email on account + */ + LOW, + /** + * Must be registered on Discord for longer than 5 minutes + */ + MEDIUM, + /** + * Must be a member of the guild for longer than 10 minutes + */ + HIGH, + /** + * Must have a verified phone number + */ + VERY_HIGH, +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-premium-tier + */ +export const enum GuildPremiumTier { + NONE, + TIER_1, + TIER_2, + TIER_3, +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags + */ +export const enum GuildSystemChannelFlags { + /** + * Suppress member join notifications + */ + SUPPRESS_JOIN_NOTIFICATIONS = 1 << 0, + /** + * Suppress server boost notifications + */ + SUPPRESS_PREMIUM_SUBSCRIPTIONS = 1 << 1, +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-object-guild-features + */ +export const enum GuildFeature { + /** + * Guild has access to set an animated guild icon + */ + ANIMATED_ICON = 'ANIMATED_ICON', + /** + * Guild has access to set a guild banner image + */ + BANNER = 'BANNER', + /** + * Guild has access to use commerce features (i.e. create store channels) + */ + COMMERCE = 'COMMERCE', + /** + * Guild can enable welcome screen, Membership Screening and discovery, and receives community updates + */ + COMMUNITY = 'COMMUNITY', + /** + * Guild is able to be discovered in the directory + */ + DISCOVERABLE = 'DISCOVERABLE', + /** + * Guild is able to be featured in the directory + */ + FEATURABLE = 'FEATURABLE', + /** + * Guild has access to set an invite splash background + */ + INVITE_SPLASH = 'INVITE_SPLASH', + /** + * Guild has access to create news channels + */ + NEWS = 'NEWS', + /** + * Guild is partnered + */ + PARTNERED = 'PARTNERED', + RELAY_ENABLED = 'RELAY_ENABLED', + /** + * Guild has access to set a vanity URL + */ + VANITY_URL = 'VANITY_URL', + /** + * Guild is verified + */ + VERIFIED = 'VERIFIED', + /** + * Guild has access to set 384kbps bitrate in voice (previously VIP voice servers) + */ + VIP_REGIONS = 'VIP_REGIONS', + /** + * Guild has enabled the welcome screen + */ + WELCOME_SCREEN_ENABLED = 'WELCOME_SCREEN_ENABLED', + /** + * Guild has enabled Membership Screening + */ + MEMBER_VERIFICATION_GATE_ENABLED = 'MEMBER_VERIFICATION_GATE_ENABLED', + /** + * Guild can be previewed before joining via Membership Screening or the directory + */ + PREVIEW_ENABLED = 'PREVIEW_ENABLED', +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-preview-object + */ +export interface APIGuildPreview { + /** + * Guild id + */ + id: string; + /** + * Guild name (2-100 characters) + */ + name: string; + /** + * Icon hash + * + * See https://discord.com/developers/docs/reference#image-formatting + */ + icon: string | null; + /** + * Splash hash + * + * See https://discord.com/developers/docs/reference#image-formatting + */ + splash: string | null; + /** + * Discovery splash hash; only present for guilds with the "DISCOVERABLE" feature + * + * See https://discord.com/developers/docs/reference#image-formatting + */ + discovery_splash: string | null; + /** + * Custom guild emojis + * + * See https://discord.com/developers/docs/resources/emoji#emoji-object + */ + emojis: APIEmoji[]; + /** + * Enabled guild features + * + * See https://discord.com/developers/docs/resources/guild#guild-object-guild-features + */ + features: GuildFeature[]; + /** + * Approximate number of members in this guild + */ + approximate_member_count: number; + /** + * Approximate number of online members in this guild + */ + approximate_presence_count: number; + /** + * The description for the guild + */ + description: string; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-widget-object + */ +export interface APIGuildWidgetSettings { + /** + * Whether the widget is enabled + */ + enabled: boolean; + /** + * The widget channel id + */ + channel_id: string | null; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-member-object + */ +export interface APIGuildMember { + /** + * The user this guild member represents + * + * **This field won't be included in the member object attached to `MESSAGE_CREATE` and `MESSAGE_UPDATE` gateway events.** + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + user?: APIUser; + /** + * This users guild nickname + */ + nick?: string | null; + /** + * Array of role object ids + * + * See https://discord.com/developers/docs/topics/permissions#role-object + */ + roles: string[]; + /** + * When the user joined the guild + */ + joined_at: string; + /** + * When the user started boosting the guild + * + * See https://support.discord.com/hc/en-us/articles/360028038352-Server-Boosting- + */ + premium_since?: string | null; + /** + * Whether the user is deafened in voice channels + */ + deaf: boolean; + /** + * Whether the user is muted in voice channels + */ + mute: boolean; + /** + * Whether the user has not yet passed the guild's Membership Screening requirements + * + * *If this field is not present, it can be assumed as `false`.* + */ + pending?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/guild#integration-object + */ +export interface APIGuildIntegration { + /** + * Integration id + */ + id: string; + /** + * Integration name + */ + name: string; + /** + * Integration type + */ + type: APIGuildInteractionType; + /** + * Is this integration enabled + */ + enabled: boolean; + /** + * Is this integration syncing + * + * **This field is not provided for `discord` bot integrations.** + */ + syncing?: boolean; + /** + * ID that this integration uses for "subscribers" + * + * **This field is not provided for `discord` bot integrations.** + */ + role_id?: string; + /** + * Whether emoticons should be synced for this integration (`twitch` only currently) + * + * **This field is not provided for `discord` bot integrations.** + */ + enable_emoticons?: boolean; + /** + * The behavior of expiring subscribers + * + * **This field is not provided for `discord` bot integrations.** + * + * See https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors + */ + expire_behavior?: IntegrationExpireBehavior; + /** + * The grace period (in days) before expiring subscribers + * + * **This field is not provided for `discord` bot integrations.** + */ + expire_grace_period?: number; + /** + * User for this integration + * + * **This field is not provided for `discord` bot integrations.** + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + user?: APIUser; + /** + * Integration account information + * + * See https://discord.com/developers/docs/resources/guild#integration-account-object + */ + account: APIIntegrationAccount; + /** + * When this integration was last synced + * + * **This field is not provided for `discord` bot integrations.** + */ + synced_at?: string; + /** + * How many subscribers this integration has + * + * **This field is not provided for `discord` bot integrations.** + */ + subscriber_count?: number; + /** + * Has this integration been revoked + * + * **This field is not provided for `discord` bot integrations.** + */ + revoked?: boolean; + /** + * The bot/OAuth2 application for discord integrations + * + * See https://discord.com/developers/docs/resources/guild#integration-application-object + * + * **This field is not provided for `discord` bot integrations.** + */ + application?: APIGuildIntegrationApplication; +} + +export type APIGuildInteractionType = 'twitch' | 'youtube' | 'discord'; + +/** + * https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors + */ +export const enum IntegrationExpireBehavior { + RemoveRole, + Kick, +} + +/** + * https://discord.com/developers/docs/resources/guild#integration-account-object + */ +export interface APIIntegrationAccount { + /** + * ID of the account + */ + id: string; + /** + * Name of the account + */ + name: string; +} + +/** + * https://discord.com/developers/docs/resources/guild#integration-application-object + */ +export interface APIGuildIntegrationApplication { + /** + * The id of the app + */ + id: string; + /** + * The name of the app + */ + name: string; + /** + * The icon hash of the app + * + * See https://discord.com/developers/docs/reference#image-formatting + */ + icon: string | null; + /** + * The description of the app + */ + description: string; + /** + * The summary of the app + */ + summary: string; + /** + * The bot associated with this application + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + bot?: APIUser; +} + +/** + * https://discord.com/developers/docs/resources/guild#ban-object + */ +export interface APIBan { + /** + * The reason for the ban + */ + reason: string | null; + /** + * The banned user + */ + user: APIUser; +} + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget + */ +export interface APIGuildWidget { + id: string; + name: string; + instant_invite: string | null; + channels: APIGuildWidgetChannel[]; + members: APIGuildWidgetMember[]; + presence_count: number; +} + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget + */ +export interface APIGuildWidgetChannel { + id: string; + name: string; + position: number; +} + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget + */ +export interface APIGuildWidgetMember { + id: string; + username: string; + discriminator: string; + avatar: string | null; + status: PresenceUpdateStatus; + activity?: { name: string }; + avatar_url: string; +} + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-widget-image-widget-style-options + */ +export const enum GuildWidgetStyle { + /** + * Shield style widget with Discord icon and guild members online count + */ + Shield = 'shield', + /** + * Large image with guild icon, name and online count. "POWERED BY DISCORD" as the footer of the widget + */ + Banner1 = 'banner1', + /** + * Smaller widget style with guild icon, name and online count. Split on the right with Discord logo + */ + Banner2 = 'banner2', + /** + * Large image with guild icon, name and online count. In the footer, Discord logo on the left and "Chat Now" on the right + */ + Banner3 = 'banner3', + /** + * Large Discord logo at the top of the widget. Guild icon, name and online count in the middle portion of the widget + * and a "JOIN MY SERVER" button at the bottom + */ + Banner4 = 'banner4', +} + +export interface APIGuildWelcomeScreen { + /** + * The welcome screen short message + */ + description: string | null; + /** + * Array of suggested channels + */ + welcome_channels: APIGuildWelcomeScreenChannel[]; +} + +export interface APIGuildWelcomeScreenChannel { + /** + * The channel id that is suggested + */ + channel_id: string; + /** + * The emoji id of the emoji that is shown on the left of the channel + */ + emoji_id: string | null; + /** + * The emoji name of the emoji that is shown on the left of the channel + */ + emoji_name: string | null; +} + +export interface APIGuildMembershipScreening { + /** + * When the fields were last updated + */ + version: string; + /** + * The steps in the screening form + */ + form_fields: APIGuildMembershipScreeningField[]; + /** + * The server description shown in the screening form + */ + description: string | null; +} + +// TODO: make this a union based on the type in the future, when new types are added + +export interface APIGuildMembershipScreeningField { + /** + * The type of field + */ + field_type: MembershipScreeningFieldType; + /** + * The title of the field + */ + label: string; + /** + * The list of rules + */ + values?: string[]; + /** + * Whether the user has to fill out this field + */ + required: boolean; +} + +export const enum MembershipScreeningFieldType { + /** + * Server Rules + */ + TERMS = 'TERMS', +} diff --git a/.deno/v8/payloads/interactions.ts b/.deno/v8/payloads/interactions.ts new file mode 100644 index 00000000..8774feb1 --- /dev/null +++ b/.deno/v8/payloads/interactions.ts @@ -0,0 +1,180 @@ +import type { APIGuildMember, APIUser, MessageFlags } from './mod.ts'; +import type { RESTPostAPIWebhookWithTokenJSONBody } from '../rest/mod.ts'; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#applicationcommand + */ +export interface APIApplicationCommand { + id: string; + application_id: string; + name: string; + description: string; + options?: APIApplicationCommandOption[]; +} + +interface APIApplicationCommandOptionBase { + type: + | ApplicationCommandOptionType.BOOLEAN + | ApplicationCommandOptionType.USER + | ApplicationCommandOptionType.CHANNEL + | ApplicationCommandOptionType.ROLE; + name: string; + description: string; + default?: boolean; + required?: boolean; +} + +/** + * https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption + */ +export type APIApplicationCommandOption = + | APIApplicationCommandArgumentOptions + | APIApplicationCommandSubCommandOptions + | APIApplicationCommandOptionBase; + +/** + * This type is exported as a way to make it stricter for you when you're writing your commands + * + * If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters + */ +export interface APIApplicationCommandSubCommandOptions extends Omit { + type: ApplicationCommandOptionType.SUB_COMMAND | ApplicationCommandOptionType.SUB_COMMAND_GROUP; + options?: APIApplicationCommandOption[]; +} + +/** + * This type is exported as a way to make it stricter for you when you're writing your commands + * + * In contrast to @see APIApplicationCommandSubCommandOptions, these types cannot have an `options` array, + * but they can have a `choices` one + */ +export interface APIApplicationCommandArgumentOptions extends Omit { + type: ApplicationCommandOptionType.STRING | ApplicationCommandOptionType.INTEGER; + choices?: APIApplicationCommandOptionChoice[]; +} + +/** + * https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype + */ +export const enum ApplicationCommandOptionType { + SUB_COMMAND = 1, + SUB_COMMAND_GROUP, + STRING, + INTEGER, + BOOLEAN, + USER, + CHANNEL, + ROLE, +} + +/** + * https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice + */ +export interface APIApplicationCommandOptionChoice { + name: string; + value: string | number; +} + +/** + * https://discord.com/developers/docs/interactions/slash-commands#interaction + */ +export interface APIInteraction { + id: string; + type: InteractionType; + data?: APIApplicationCommandInteractionData; + guild_id: string; + channel_id: string; + member: APIGuildMember & { permissions: string; user: APIUser }; + token: string; + version: 1; +} + +/** + * Like See APIInteraction, only with the `data` property always present + */ +export type APIApplicationCommandInteraction = Required; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype + */ +export const enum InteractionType { + Ping = 1, + ApplicationCommand, +} + +/** + * https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata + */ +export interface APIApplicationCommandInteractionData { + id: string; + name: string; + options?: APIApplicationCommandInteractionDataOption[]; +} + +/** + * https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption + */ +export interface APIApplicationCommandInteractionDataOption { + name: string; + /** + * The value returned here depends on the `ApplicationCommandOptionType` type of the option with the name + * that matches this interface's `name`. + * + * You will need to manually cast this to the appropriate type based on the returned data + */ + value?: unknown; + options?: APIApplicationCommandInteractionDataOption[]; +} + +/** + * https://discord.com/developers/docs/interactions/slash-commands#interaction-interaction-response + */ +export type APIInteractionResponse = + | APIInteractionResponsePong + | APIInteractionResponseAcknowledge + | APIInteractionResponseAcknowledgeWithSource + | APIInteractionResponseChannelMessage + | APIInteractionResponseChannelMessageWithSource; + +export type APIInteractionResponsePong = InteractionResponsePayload; + +export type APIInteractionResponseAcknowledge = InteractionResponsePayload; + +export type APIInteractionResponseAcknowledgeWithSource = InteractionResponsePayload; + +export type APIInteractionResponseChannelMessage = InteractionResponsePayload< + APIInteractionResponseType.ChannelMessage, + true +>; + +export type APIInteractionResponseChannelMessageWithSource = InteractionResponsePayload< + APIInteractionResponseType.ChannelMessageWithSource, + true +>; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#interaction-interactionresponsetype + */ +export const enum APIInteractionResponseType { + Pong = 1, + Acknowledge, + ChannelMessage, + ChannelMessageWithSource, + AcknowledgeWithSource, +} + +/** + * https://discord.com/developers/docs/interactions/slash-commands#interaction-interactionapplicationcommandcallbackdata + */ +export type APIInteractionApplicationCommandCallbackData = Omit< + RESTPostAPIWebhookWithTokenJSONBody, + 'username' | 'avatar_url' +> & { flags?: MessageFlags }; + +/** + * @internal + */ +interface InteractionResponsePayload { + type: T; + data?: D extends true ? APIInteractionApplicationCommandCallbackData : never; +} diff --git a/.deno/v8/payloads/invite.ts b/.deno/v8/payloads/invite.ts new file mode 100644 index 00000000..ec4d435c --- /dev/null +++ b/.deno/v8/payloads/invite.ts @@ -0,0 +1,88 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/invite + */ + +import type { APIPartialChannel } from './channel.ts'; +import type { APIPartialGuild } from './guild.ts'; +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/resources/invite#invite-object + */ +export interface APIInvite { + /** + * The invite code (unique ID) + */ + code: string; + /** + * The guild this invite is for + * + * See https://discord.com/developers/docs/resources/guild#guild-object + */ + guild?: APIPartialGuild; + /** + * The channel this invite is for + * + * See https://discord.com/developers/docs/resources/channel#channel-object + */ + channel?: Required; + /** + * The user who created the invite + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + inviter?: APIUser; + /** + * The target user for this invite + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + target_user?: APIUser; + /** + * The type of user target for this invite + * + * See https://discord.com/developers/docs/resources/invite#invite-object-target-user-types + */ + target_user_type?: InviteTargetUserType; + /** + * Approximate count of online members (only present when `target_user` is set) + */ + approximate_presence_count?: number; + /** + * Approximate count of total members + */ + approximate_member_count?: number; +} + +/** + * https://discord.com/developers/docs/resources/invite#invite-object-target-user-types + */ +export const enum InviteTargetUserType { + STREAM = 1, +} + +/** + * https://discord.com/developers/docs/resources/invite#invite-metadata-object + */ +export interface APIExtendedInvite extends APIInvite { + /** + * Number of times this invite has been used + */ + uses: number; + /** + * Max number of times this invite can be used + */ + max_uses: number; + /** + * Duration (in seconds) after which the invite expires + */ + max_age: number; + /** + * Whether this invite only grants temporary membership + */ + temporary: boolean; + /** + * When this invite was created + */ + created_at: string; +} diff --git a/.deno/v8/payloads/mod.ts b/.deno/v8/payloads/mod.ts new file mode 100644 index 00000000..f512c8bf --- /dev/null +++ b/.deno/v8/payloads/mod.ts @@ -0,0 +1,14 @@ +export * from './auditLog.ts'; +export * from './channel.ts'; +export * from './emoji.ts'; +export * from './gateway.ts'; +export * from './guild.ts'; +export * from './interactions.ts'; +export * from './invite.ts'; +export * from './oauth2.ts'; +export * from './permissions.ts'; +export * from './teams.ts'; +export * from './template.ts'; +export * from './user.ts'; +export * from './voice.ts'; +export * from './webhook.ts'; diff --git a/.deno/v8/payloads/oauth2.ts b/.deno/v8/payloads/oauth2.ts new file mode 100644 index 00000000..b16032c9 --- /dev/null +++ b/.deno/v8/payloads/oauth2.ts @@ -0,0 +1,192 @@ +/** + * Types extracted from https://discord.com/developers/docs/topics/oauth2 + */ + +import type { APITeam } from './teams.ts'; +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/topics/oauth2#get-current-application-information-response-structure + */ +export interface APIApplication { + /** + * The id of the app + */ + id: string; + /** + * 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 containing info on the owner of the application + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + owner: APIUser; + /** + * If this application is a game sold on Discord, this field will be the summary field for the store page + * of its primary sku + */ + summary: string; + /** + * The base64 encoded key for the GameSDK's GetTicket + * + * See https://discord.com/developers/docs/game-sdk/applications#get-ticket + */ + verify_key: string; + /** + * The team this application belongs to + * + * See https://discord.com/developers/docs/topics/teams#data-models-team-object + */ + team: APITeam | null; + /** + * If this application is a game sold on Discord, this field will be the guild to which it has been linked + */ + guild_id?: string; + /** + * 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?: string; + /** + * 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 + */ + flags: number; +} + +export const enum OAuth2Scopes { + /** + * For oauth2 bots, this puts the bot in the user's selected guild by default + */ + Bot = 'bot', + /** + * Allows [/users/@me/connections](https://discord.com/developers/docs/resources/user#get-user-connections) + * to return linked third-party accounts + * + * See https://discord.com/developers/docs/resources/user#get-user-connections + */ + Connections = 'connections', + /** + * Enables [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) to return an `email` + * + * See https://discord.com/developers/docs/resources/user#get-current-user + */ + Email = 'email', + /** + * Allows [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) without `email` + * + * See https://discord.com/developers/docs/resources/user#get-current-user + */ + Identify = 'identify', + /** + * Allows [/users/@me/guilds](https://discord.com/developers/docs/resources/user#get-current-user-guilds) + * to return basic information about all of a user's guilds + * + * See https://discord.com/developers/docs/resources/user#get-current-user-guilds + */ + Guilds = 'guilds', + /** + * Allows [/guilds/{guild.id}/members/{user.id}](https://discord.com/developers/docs/resources/guild#add-guild-member) + * to be used for joining users to a guild + * + * See https://discord.com/developers/docs/resources/guild#add-guild-member + */ + GuildsJoin = 'guilds.join', + /** + * Allows your app to join users to a group dm + * + * See https://discord.com/developers/docs/resources/channel#group-dm-add-recipient + */ + GroupDMJoins = 'gdm.join', + /** + * For local rpc server api access, this allows you to read messages from all client channels + * (otherwise restricted to channels/guilds your app creates) + */ + MessagesRead = 'messages.read', + /** + * For local rpc server access, this allows you to control a user's local Discord client - whitelist only + */ + RPC = 'rpc', + /** + * For local rpc server api access, this allows you to access the API as the local user - whitelist only + */ + RPCApi = 'rpc.api', + /** + * For local rpc server api access, this allows you to receive notifications pushed out to the user - whitelist only + */ + RPCNotificationsRead = 'rpc.notifications.read', + /** + * This generates a webhook that is returned in the oauth token response for authorization code grants + */ + WebhookIncoming = 'webhook.incoming', + /** + * Allows your app to upload/update builds for a user's applications - whitelist only + */ + ApplicationsBuildsUpload = 'applications.builds.upload', + /** + * Allows your app to read build data for a user's applications + */ + ApplicationsBuildsRead = 'applications.builds.read', + /** + * Allows your app to read and update store data (SKUs, store listings, achievements, etc.) for a user's applications + */ + ApplicationsStoreUpdate = 'applications.store.update', + /** + * Allows your app to read entitlements for a user's applications + */ + ApplicationsEntitlements = 'applications.entitlements', + /** + * Allows your app to know a user's friends and implicit relationships - whitelist only + */ + RelationshipsRead = 'relationships.read', + /** + * Allows your app to fetch data from a user's "Now Playing/Recently Played" list - whitelist only + */ + ActivitiesRead = 'activities.read', + /** + * Allows your app to update a user's activity - whitelist only (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER) + * + * See https://discord.com/developers/docs/game-sdk/activities + */ + ActivitiesWrite = 'activities.write', + /** + * Allows your app to create Slash Commands in the authorized guild + * + * See https://discord.com/developers/docs/interactions/slash-commands + */ + ApplicationsCommands = 'applications.commands', + /** + * Allows your app to update Slash Commands via this bearer token + * + * See https://discord.com/developers/docs/interactions/slash-commands + */ + ApplicationsCommandsUpdate = 'applications.commands.update', +} diff --git a/.deno/v8/payloads/permissions.ts b/.deno/v8/payloads/permissions.ts new file mode 100644 index 00000000..7282a7ad --- /dev/null +++ b/.deno/v8/payloads/permissions.ts @@ -0,0 +1,113 @@ +/** + * Types extracted from https://discord.com/developers/docs/topics/permissions + */ + +/** + * https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags + * + * These flags are exported as `BigInt`s and NOT numbers. For most of them, you can + * convert them in a number by wrapping it in `Number()`, however be careful as any + * further bits added may cause issues if done so. Try to use BigInts as much as possible + * or modules that can replicate them in some way + */ +export const PermissionFlagsBits = { + CREATE_INSTANT_INVITE: 1n << 0n, + KICK_MEMBERS: 1n << 1n, + BAN_MEMBERS: 1n << 2n, + ADMINISTRATOR: 1n << 3n, + MANAGE_CHANNELS: 1n << 4n, + MANAGE_GUILD: 1n << 5n, + ADD_REACTIONS: 1n << 6n, + VIEW_AUDIT_LOG: 1n << 7n, + PRIORITY_SPEAKER: 1n << 8n, + STREAM: 1n << 9n, + VIEW_CHANNEL: 1n << 10n, + SEND_MESSAGES: 1n << 11n, + SEND_TTS_MESSAGES: 1n << 12n, + MANAGE_MESSAGES: 1n << 13n, + EMBED_LINKS: 1n << 14n, + ATTACH_FILES: 1n << 15n, + READ_MESSAGE_HISTORY: 1n << 16n, + MENTION_EVERYONE: 1n << 17n, + USE_EXTERNAL_EMOJIS: 1n << 18n, + VIEW_GUILD_INSIGHTS: 1n << 19n, + CONNECT: 1n << 20n, + SPEAK: 1n << 21n, + MUTE_MEMBERS: 1n << 22n, + DEAFEN_MEMBERS: 1n << 23n, + MOVE_MEMBERS: 1n << 24n, + USE_VAD: 1n << 25n, + CHANGE_NICKNAME: 1n << 26n, + MANAGE_NICKNAMES: 1n << 27n, + MANAGE_ROLES: 1n << 28n, + MANAGE_WEBHOOKS: 1n << 29n, + MANAGE_EMOJIS: 1n << 30n, +} as const; + +/** + * Freeze the object of bits, preventing any modifications to it + * @internal + */ +Object.freeze(PermissionFlagsBits); + +/** + * https://discord.com/developers/docs/topics/permissions#role-object + */ +export interface APIRole { + /** + * Role id + */ + id: string; + /** + * Role name + */ + name: string; + /** + * Integer representation of hexadecimal color code + */ + color: number; + /** + * If this role is pinned in the user listing + */ + hoist: boolean; + /** + * Position of this role + */ + position: number; + /** + * Permission bit set + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + permissions: string; + /** + * Whether this role is managed by an integration + */ + managed: boolean; + /** + * Whether this role is mentionable + */ + mentionable: boolean; + /** + * The tags this role has + */ + tags?: APIRoleTags; +} + +/** + * https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure + */ +export interface APIRoleTags { + /** + * The id of the bot this role belongs to + */ + bot_id?: string; + /** + * Whether this is the guild's premium subscriber role + */ + premium_subscriber?: null; + /** + * The id of the integration this role belongs to + */ + integration_id?: string; +} diff --git a/.deno/v8/payloads/teams.ts b/.deno/v8/payloads/teams.ts new file mode 100644 index 00000000..197c6652 --- /dev/null +++ b/.deno/v8/payloads/teams.ts @@ -0,0 +1,61 @@ +/** + * Types extracted from https://discord.com/developers/docs/topics/teams + */ + +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/topics/teams#data-models-team-object + */ +export interface APITeam { + /** + * A hash of the image of the team's icon + */ + icon: string | null; + /** + * The unique id of the team + */ + id: string; + /** + * The members of the team + */ + members: APITeamMember[]; + /** + * The user id of the current team owner + */ + owner_user_id: string; +} + +/** + * https://discord.com/developers/docs/topics/teams#data-models-team-members-object + */ +export interface APITeamMember { + /** + * The user's membership state on the team + * + * See https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum + */ + membership_state: TeamMemberMembershipState; + /** + * Will always be `["*"]` + */ + permissions: ['*']; + /** + * The id of the parent team of which they are a member + */ + team_id: string; + /** + * The avatar, discriminator, id, and username of the user + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + user: APIUser; +} + +/** + * https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum + */ +export const enum TeamMemberMembershipState { + INVITED = 1, + ACCEPTED, +} diff --git a/.deno/v8/payloads/template.ts b/.deno/v8/payloads/template.ts new file mode 100644 index 00000000..74021f4b --- /dev/null +++ b/.deno/v8/payloads/template.ts @@ -0,0 +1,64 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/template + */ + +import type { APIUser } from './user.ts'; +import type { RESTPostAPIGuildsJSONBody } from '../rest/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/template#template-object + */ +export interface APITemplate { + /** + * The template code (unique ID) + */ + code: string; + /** + * Template name + */ + name: string; + /** + * The description for the template + */ + description: string | null; + /** + * Number of times this template has been used + */ + usage_count: number; + /** + * The ID of the user who created the template + */ + creator_id: string; + /** + * The user who created the template + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + creator: APIUser; + /** + * When this template was created + */ + created_at: string; + /** + * When this template was last synced to the source guild + */ + updated_at: string; + /** + * The ID of the guild this template is based on + */ + source_guild_id: string; + /** + * The guild snapshot this template contains + */ + serialized_source_guild: APITemplateSerializedSourceGuild; + /** + * Whether the template has unsynced changes + */ + is_dirty: boolean | null; +} + +export interface APITemplateSerializedSourceGuild extends Omit { + description: string | null; + preferred_locale: string; + icon_hash: string | null; +} diff --git a/.deno/v8/payloads/user.ts b/.deno/v8/payloads/user.ts new file mode 100644 index 00000000..5b669d34 --- /dev/null +++ b/.deno/v8/payloads/user.ts @@ -0,0 +1,157 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/user + */ + +import type { APIGuildIntegration } from './guild.ts'; + +/** + * https://discord.com/developers/docs/resources/user#user-object + */ +export interface APIUser { + /** + * The user's id + */ + id: string; + /** + * The user's username, not unique across the platform + */ + username: string; + /** + * The user's 4-digit discord-tag + */ + discriminator: string; + /** + * The user's avatar hash + * + * See https://discord.com/developers/docs/reference#image-formatting + */ + avatar: string | null; + /** + * Whether the user belongs to an OAuth2 application + */ + bot?: boolean; + /** + * Whether the user is an Official Discord System user (part of the urgent message system) + */ + system?: boolean; + /** + * Whether the user has two factor enabled on their account + */ + mfa_enabled?: boolean; + /** + * The user's chosen language option + */ + locale?: string; + /** + * Whether the email on this account has been verified + */ + verified?: boolean; + /** + * The user's email + */ + email?: string | null; + /** + * The flags on a user's account + * + * See https://discord.com/developers/docs/resources/user#user-object-user-flags + */ + flags?: UserFlags; + /** + * The type of Nitro subscription on a user's account + * + * See https://discord.com/developers/docs/resources/user#user-object-premium-types + */ + premium_type?: UserPremiumType; + /** + * The public flags on a user's account + * + * See https://discord.com/developers/docs/resources/user#user-object-user-flags + */ + public_flags?: UserFlags; +} + +/** + * https://discord.com/developers/docs/resources/user#user-object-user-flags + */ +export const enum UserFlags { + None = 0, + DiscordEmployee = 1 << 0, + PartneredServerOwner = 1 << 1, + DiscordHypeSquadEvents = 1 << 2, + BugHunterLevel1 = 1 << 3, + HypeSquadHouseBravery = 1 << 6, + HypeSquadHouseBrilliance = 1 << 7, + HypeSquadHouseBalance = 1 << 8, + EarlySupporter = 1 << 9, + TeamUser = 1 << 10, + System = 1 << 12, + BugHunterLevel2 = 1 << 14, + VerifiedBot = 1 << 16, + EarlyVerifiedBotDeveloper = 1 << 17, +} + +/** + * https://discord.com/developers/docs/resources/user#user-object-premium-types + */ +export const enum UserPremiumType { + None, + NitroClassic, + Nitro, +} + +/** + * https://discord.com/developers/docs/resources/user#connection-object + */ +export interface APIConnection { + /** + * ID of the connection account + */ + id: string; + /** + * The username of the connection account + */ + name: string; + /** + * The service of the connection + */ + type: string; + /** + * Whether the connection is revoked + */ + revoked?: boolean; + /** + * An array of partial server integrations + * + * See https://discord.com/developers/docs/resources/guild#integration-object + */ + integrations?: Partial[]; + /** + * Whether the connection is verified + */ + verified: boolean; + /** + * Whether friend sync is enabled for this connection + */ + friend_sync: boolean; + /** + * Whether activities related to this connection will be shown in presence updates + */ + show_activity: boolean; + /** + * Visibility of this connection + * + * See https://discord.com/developers/docs/resources/user#connection-object-visibility-types + */ + visibility: ConnectionVisibility; +} + +export const enum ConnectionVisibility { + /** + * Invisible to everyone except the user themselves + */ + None, + /** + * Visible to everyone + */ + Everyone, +} diff --git a/.deno/v8/payloads/voice.ts b/.deno/v8/payloads/voice.ts new file mode 100644 index 00000000..15648d1f --- /dev/null +++ b/.deno/v8/payloads/voice.ts @@ -0,0 +1,91 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/voice + */ + +import type { APIGuildMember } from './guild.ts'; + +/** + * https://discord.com/developers/docs/resources/voice#voice-state-object + */ +export interface GatewayVoiceState { + /** + * The guild id this voice state is for + */ + guild_id?: string; + /** + * The channel id this user is connected to + */ + channel_id: string | null; + /** + * The user id this voice state is for + */ + user_id: string; + /** + * The guild member this voice state is for + * + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ + member?: APIGuildMember; + /** + * The session id for this voice state + */ + session_id: string; + /** + * Whether this user is deafened by the server + */ + deaf: boolean; + /** + * Whether this user is muted by the server + */ + mute: boolean; + /** + * Whether this user is locally deafened + */ + self_deaf: boolean; + /** + * Whether this user is locally muted + */ + self_mute: boolean; + /** + * Whether this user is streaming using "Go Live" + */ + self_stream?: boolean; + /** + * Whether this user's camera is enabled + */ + self_video: boolean; + /** + * Whether this user is muted by the current user + */ + suppress: boolean; +} + +/** + * https://discord.com/developers/docs/resources/voice#voice-region-object + */ +export interface APIVoiceRegion { + /** + * Unique ID for the region + */ + id: string; + /** + * Name of the region + */ + name: string; + /** + * `true` if this is a vip-only server + */ + vip: boolean; + /** + * `true` for a single server that is closest to the current user's client + */ + optimal: boolean; + /** + * Whether this is a deprecated voice region (avoid switching to these) + */ + deprecated: boolean; + /** + * Whether this is a custom voice region (used for events/etc) + */ + custom: boolean; +} diff --git a/.deno/v8/payloads/webhook.ts b/.deno/v8/payloads/webhook.ts new file mode 100644 index 00000000..c6a9b143 --- /dev/null +++ b/.deno/v8/payloads/webhook.ts @@ -0,0 +1,64 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/webhook + */ + +import type { APIPartialChannel, APIPartialGuild, APIUser } from './mod.ts'; + +/** + * https://discord.com/developers/docs/resources/webhook#webhook-object + */ +export interface APIWebhook { + /** + * The id of the webhook + */ + id: string; + /** + * The type of the webhook + * + * See https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types + */ + type: WebhookType; + /** + * The guild id this webhook is for + */ + guild_id?: string; + /** + * The channel id this webhook is for + */ + channel_id: string; + /** + * The user this webhook was created by (not returned when getting a webhook with its token) + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + user?: APIUser; + /** + * The default name of the webhook + */ + name: string | null; + /** + * The default avatar of the webhook + */ + avatar: string | null; + /** + * The secure token of the webhook (returned for Incoming Webhooks) + */ + token?: string; + /** + * The bot/OAuth2 application that created this webhook + */ + application_id: string | null; + source_guild?: APIPartialGuild; + source_channel?: APIPartialChannel; +} + +export const enum WebhookType { + /** + * Incoming Webhooks can post messages to channels with a generated token + */ + Incoming = 1, + /** + * Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels + */ + ChannelFollower, +} diff --git a/.deno/v8/rest/auditLog.ts b/.deno/v8/rest/auditLog.ts new file mode 100644 index 00000000..54c6c796 --- /dev/null +++ b/.deno/v8/rest/auditLog.ts @@ -0,0 +1,27 @@ +import type { APIAuditLog, AuditLogEvent } from '../payloads/auditLog.ts'; + +/** + * https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log + */ +export interface RESTGetAPIAuditLogQuery { + /** + * Filter the log for actions made by a user + */ + user_id?: string; + /** + * The type of audit log events + */ + action_type?: AuditLogEvent; + /** + * Filter the log before a certain entry ID + */ + before?: string; + /** + * How many entries are returned (default 50, minimum 1, maximum 100) + * + * @default 50 + */ + limit?: number; +} + +export type RESTGetAPIAuditLogResult = APIAuditLog; diff --git a/.deno/v8/rest/channel.ts b/.deno/v8/rest/channel.ts new file mode 100644 index 00000000..45d7e147 --- /dev/null +++ b/.deno/v8/rest/channel.ts @@ -0,0 +1,443 @@ +import type { + APIAllowedMentions, + APIChannel, + APIEmbed, + APIExtendedInvite, + APIFollowedChannel, + APIMessage, + APIMessageReference, + APIOverwrite, + APIUser, + ChannelType, + InviteTargetUserType, + MessageFlags, + OverwriteType, +} from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/channel#get-channel + */ +export type RESTGetAPIChannelResult = APIChannel; + +/** + * https://discord.com/developers/docs/resources/channel#modify-channel + */ +export interface RESTPatchAPIChannelJSONBody { + /** + * 2-100 character channel name + * + * Channel types: all + */ + name?: string; + + /** + * The type of channel; only conversion between `text` and `news` + * is supported and only in guilds with the "NEWS" feature + * + * Channel types: text, news + */ + type?: ChannelType.GUILD_NEWS | ChannelType.GUILD_TEXT; + /** + * The position of the channel in the left-hand listing + * + * Channel types: all + */ + position?: number | null; + /** + * 0-1024 character channel topic + * + * Channel types: text, news + */ + topic?: string | null; + /** + * Whether the channel is nsfw + * + * Channel types: text, news, store + */ + nsfw?: boolean | 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 + * + * Channel types: text + */ + rate_limit_per_user?: number | null; + /** + * The bitrate (in bits) of the voice channel; 8000 to 96000 (128000 for VIP servers) + * + * Channel types: voice + */ + bitrate?: number | null; + /** + * The user limit of the voice channel; 0 refers to no limit, 1 to 99 refers to a user limit + * + * Channel types: voice + */ + user_limit?: number | null; + /** + * Channel or category-specific permissions + * + * Channel types: all + */ + permission_overwrites?: APIOverwrite[] | null; + /** + * ID of the new parent category for a channel + * + * Channel types: text, news, store, voice + */ + parent_id?: string | null; +} + +/** + * https://discord.com/developers/docs/resources/channel#modify-channel + */ +export type RESTPatchAPIChannelResult = APIChannel; + +/** + * https://discord.com/developers/docs/resources/channel#deleteclose-channel + */ +export type RESTDeleteAPIChannelResult = APIChannel; + +/** + * https://discord.com/developers/docs/resources/channel#get-channel-messages + */ +export interface RESTGetAPIChannelMessagesQuery { + /** + * Get messages around this message ID + */ + around?: string; + /** + * Get messages before this message ID + */ + before?: string; + /** + * Get messages after this message ID + */ + after?: string; + /** + * Max number of messages to return (1-100) + * + * @default 50 + */ + limit?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#get-channel-messages + */ +export type RESTGetAPIChannelMessagesResult = APIMessage[]; + +/** + * https://discord.com/developers/docs/resources/channel#get-channel-message + */ +export type RESTGetAPIChannelMessageResult = APIMessage; + +export type APIMessageReferenceSend = Partial & Required>; + +/** + * https://discord.com/developers/docs/resources/channel#create-message + */ +export interface RESTPostAPIChannelMessageJSONBody { + /** + * The message contents (up to 2000 characters) + */ + content?: string; + /** + * A nonce that can be used for optimistic message sending + */ + nonce?: number | string; + /** + * `true` if this is a TTS message + */ + tts?: true; + /** + * Embedded `rich` content + * + * See https://discord.com/developers/docs/resources/channel#embed-object + */ + embed?: APIEmbed; + /** + * Allowed mentions for a message + * + * See https://discord.com/developers/docs/resources/channel#allowed-mentions-object + */ + allowed_mentions?: APIAllowedMentions; + /** + * Include to make your message a reply + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure + */ + message_reference?: APIMessageReferenceSend; +} + +/** + * https://discord.com/developers/docs/resources/channel#create-message + */ +export type RESTPostAPIChannelMessageFormDataBody = + | { + /** + * JSON stringified message body + */ + payload_json?: string; + /** + * The file contents + */ + file: unknown; + } + | (RESTPostAPIChannelMessageJSONBody & { + /** + * The file contents + */ + file: unknown; + }); + +/** + * https://discord.com/developers/docs/resources/channel#create-message + */ +export type RESTPostAPIChannelMessageResult = APIMessage; + +/** + * https://discord.com/developers/docs/resources/channel#crosspost-message + */ +export type RESTPostAPIChannelMessageCrosspostResult = APIMessage; + +/** + * https://discord.com/developers/docs/resources/channel#create-reaction + */ +export type RESTPutAPIChannelMessageReactionResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#delete-own-reaction + */ +export type RESTDeleteAPIChannelMessageOwnReaction = never; + +/** + * https://discord.com/developers/docs/resources/channel#delete-user-reaction + */ +export type RESTDeleteAPIChannelMessageUserReactionResult = never; + +/* + * https://discord.com/developers/docs/resources/channel#get-reactions + */ +export interface RESTGetAPIChannelMessageReactionUsersQuery { + /** + * Get users before this user ID + */ + before?: string; + /** + * Get users after this user ID + */ + after?: string; + /** + * Max number of users to return (1-100) + * + * @default 25 + */ + limit?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#get-reactions + */ +export type RESTGetAPIChannelMessageReactionUsersResult = APIUser[]; + +/** + * https://discord.com/developers/docs/resources/channel#delete-all-reactions + */ +export type RESTDeleteAPIChannelAllMessageReactionsResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#delete-all-reactions-for-emoji + */ +export type RESTDeleteAPIChannelMessageReactionResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#edit-message + */ +export interface RESTPatchAPIChannelMessageJSONBody { + /** + * The new message contents (up to 2000 characters) + */ + content?: string | null; + /** + * Embedded `rich` content + */ + embed?: APIEmbed | null; + /** + * Edit the flags of a message (only `SUPPRESS_EMBEDS` can currently be set/unset) + * + * When specifying flags, ensure to include all previously set flags/bits + * in addition to ones that you are modifying + */ + flags?: MessageFlags | null; + /** + * Allowed mentions for the message + */ + allowed_mentions?: APIAllowedMentions | null; +} + +/** + * https://discord.com/developers/docs/resources/channel#edit-message + */ +export type RESTPatchAPIChannelMessageResult = APIMessage; + +/** + * https://discord.com/developers/docs/resources/channel#delete-message + */ +export type RESTDeleteAPIChannelMessageResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#bulk-delete-messages + */ +export interface RESTPostAPIChannelMessagesBulkDeleteJSONBody { + /** + * An array of message ids to delete (2-100) + */ + messages: string[]; +} + +/** + * https://discord.com/developers/docs/resources/channel#bulk-delete-messages + */ +export type RESTPostAPIChannelMessagesBulkDeleteResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#edit-channel-permissions + */ +export interface RESTPutAPIChannelPermissionJSONBody { + /** + * The bitwise value of all allowed permissions + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + allow: string; + /** + * The bitwise value of all disallowed permissions + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + deny: string; + /** + * `0` for a role or `1` for a member + */ + type: OverwriteType; +} + +/** + * https://discord.com/developers/docs/resources/channel#edit-channel-permissions + */ +export type RESTPutAPIChannelPermissionResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#get-channel-invites + */ +export type RESTGetAPIChannelInvitesResult = APIExtendedInvite[]; + +/** + * https://discord.com/developers/docs/resources/channel#create-channel-invite + */ +export interface RESTPostAPIChannelInviteJSONBody { + /** + * Duration of invite in seconds before expiry, or 0 for never + * + * @default 86400 (24 hours) + */ + max_age?: number; + /** + * Max number of uses or 0 for unlimited + * + * @default 0 + */ + max_uses?: number; + /** + * Whether this invite only grants temporary membership + * + * @default false + */ + temporary?: boolean; + /** + * If true, don't try to reuse a similar invite + * (useful for creating many unique one time use invites) + * + * @default false + */ + unique?: boolean; + /** + * The target user id for this invite + */ + target_user_id?: string; + /** + * The type of target user for this invite + */ + target_user_type?: InviteTargetUserType; +} + +/** + * https://discord.com/developers/docs/resources/channel#create-channel-invite + */ +export type RESTPostAPIChannelInviteResult = APIExtendedInvite; + +/** + * https://discord.com/developers/docs/resources/channel#delete-channel-permission + */ +export type RESTDeleteAPIChannelPermissionResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#follow-news-channel + */ +export interface RESTPostAPIChannelFollowersJSONBody { + /** + * ID of target channel + */ + webhook_channel_id: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#follow-news-channel + */ +export type RESTPostAPIChannelFollowersResult = APIFollowedChannel; + +/** + * https://discord.com/developers/docs/resources/channel#trigger-typing-indicator + */ +export type RESTPostAPIChannelTypingResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#get-pinned-messages + */ +export type RESTGetAPIChannelPinsResult = APIMessage[]; + +/** + * https://discord.com/developers/docs/resources/channel#add-pinned-channel-message + */ +export type RESTPutAPIChannelPinResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#delete-pinned-channel-message + */ +export type RESTDeleteAPIChannelPinResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#group-dm-add-recipient + */ +export interface RESTPutAPIChannelRecipientJSONBody { + /** + * Access token of a user that has granted your app the `gdm.join` scope + */ + access_token: string; + /** + * Nickname of the user being added + */ + nick?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#group-dm-add-recipient + */ +export type RESTPutAPIChannelRecipientResult = unknown; + +/** + * https://discord.com/developers/docs/resources/channel#group-dm-remove-recipient + */ +export type RESTDeleteAPIChannelRecipientResult = unknown; diff --git a/.deno/v8/rest/emoji.ts b/.deno/v8/rest/emoji.ts new file mode 100644 index 00000000..1e1c8247 --- /dev/null +++ b/.deno/v8/rest/emoji.ts @@ -0,0 +1,60 @@ +import type { APIEmoji } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/emoji#list-guild-emojis + */ +export type RESTGetAPIGuildEmojisResult = APIEmoji[]; + +/** + * https://discord.com/developers/docs/resources/emoji#get-guild-emoji + */ +export type RESTGetAPIGuildEmojiResult = APIEmoji; + +/** + * https://discord.com/developers/docs/resources/emoji#create-guild-emoji-json-params + */ +export interface RESTPostAPIGuildEmojiJSONBody { + /** + * Name of the emoji + */ + name: string; + /** + * The 128x128 emoji image + * + * https://discord.com/developers/docs/reference#image-data + */ + image: string; + /** + * Roles for which this emoji will be whitelisted + */ + roles?: string[]; +} + +/** + * https://discord.com/developers/docs/resources/emoji#create-guild-emoji + */ +export type RESTPostAPIGuildEmojiResult = APIEmoji; + +/** + * https://discord.com/developers/docs/resources/emoji#modify-guild-emoji + */ +export interface RESTPatchAPIGuildEmojiJSONBody { + /** + * Name of the emoji + */ + name?: string; + /** + * Roles for which this emoji will be whitelisted + */ + roles?: string[] | null; +} + +/** + * https://discord.com/developers/docs/resources/emoji#modify-guild-emoji + */ +export type RESTPatchAPIGuildEmojiResult = APIEmoji; + +/** + * https://discord.com/developers/docs/resources/emoji#delete-guild-emoji + */ +export type RESTDeleteAPIGuildEmojiResult = never; diff --git a/.deno/v8/rest/gateway.ts b/.deno/v8/rest/gateway.ts new file mode 100644 index 00000000..c939050b --- /dev/null +++ b/.deno/v8/rest/gateway.ts @@ -0,0 +1,11 @@ +import type { APIGatewayBotInfo, APIGatewayInfo } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/topics/gateway#get-gateway + */ +export type RESTGetAPIGatewayResult = APIGatewayInfo; + +/** + * https://discord.com/developers/docs/topics/gateway#get-gateway-bot + */ +export type RESTGetAPIGatewayBotResult = APIGatewayBotInfo; diff --git a/.deno/v8/rest/guild.ts b/.deno/v8/rest/guild.ts new file mode 100644 index 00000000..d2eef558 --- /dev/null +++ b/.deno/v8/rest/guild.ts @@ -0,0 +1,771 @@ +import type { + APIBan, + APIChannel, + APIExtendedInvite, + APIGuild, + APIGuildIntegration, + APIGuildMember, + APIGuildMembershipScreening, + APIGuildPreview, + APIGuildWidget, + APIGuildWidgetSettings, + APIRole, + APIVoiceRegion, + GuildDefaultMessageNotifications, + GuildExplicitContentFilter, + GuildFeature, + GuildSystemChannelFlags, + GuildVerificationLevel, + GuildWidgetStyle, + IntegrationExpireBehavior, +} from '../payloads/mod.ts'; +import type { RESTPutAPIChannelPermissionJSONBody } from './channel.ts'; + +export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionJSONBody { + id: number | string; +} + +export type APIGuildCreatePartialChannel = Partial< + Pick +> & { + name: string; + id?: number | string; + parent_id?: number | string; + permission_overwrites?: APIGuildCreateOverwrite[]; +}; + +export interface APIGuildCreateRole extends RESTPostAPIGuildRoleJSONBody { + id: number | string; +} + +/** + * https://discord.com/developers/docs/resources/guild#create-guild + */ +export interface RESTPostAPIGuildsJSONBody { + /** + * Name of the guild (2-100 characters) + */ + name: string; + /** + * Voice region id + * + * See https://discord.com/developers/docs/resources/voice#voice-region-object + */ + region?: string; + /** + * base64 1024x1024 png/jpeg image for the guild icon + * + * See https://discord.com/developers/docs/reference#image-data + */ + icon?: string; + /** + * Verification level + * + * See https://discord.com/developers/docs/resources/guild#guild-object-verification-level + */ + verification_level?: GuildVerificationLevel; + /** + * Default message notification level + * + * See https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level + */ + default_message_notifications?: GuildDefaultMessageNotifications; + /** + * Explicit content filter level + * + * See https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level + */ + explicit_content_filter?: GuildExplicitContentFilter; + /** + * New guild roles + * + * **When using this parameter, the first member of the array is used to change properties of the guild's @everyone role. + * If you are trying to bootstrap a guild with additional roles, keep this in mind.** + * + * *When using this parameter, the required `id` field within each role object is an integer placeholder, + * and will be replaced by the API upon consumption. Its purpose is to allow you to overwrite a role's permissions + * in a channel when also passing in channels with the channels array.* + * + * See https://discord.com/developers/docs/topics/permissions#role-object + */ + roles?: APIGuildCreateRole[]; + /** + * New guild's channels + * + * **When using the channels parameter, the `position` field is ignored, and none of the default channels are created.** + * + * *When using the channels parameter, the `id` field within each channel object may be set to an integer placeholder, + * and will be replaced by the API upon consumption. Its purpose is to allow you to create `GUILD_CATEGORY` channels + * by setting the `parent_id` field on any children to the category's id field. + * Category channels must be listed before any children.* + * + * See https://discord.com/developers/docs/resources/channel#channel-object + */ + channels?: APIGuildCreatePartialChannel[]; + /** + * ID for afk channel + */ + afk_channel_id?: number | string; + /** + * AFK timeout in seconds + */ + afk_timeout?: number; + /** + * The id of the channel where guild notices such as welcome messages and boost events are posted + */ + system_channel_id?: number | string; + /** + * System channel flags + * + * See https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags + */ + system_channel_flags?: GuildSystemChannelFlags; +} + +/** + * https://discord.com/developers/docs/resources/guild#create-guild + */ +export type RESTPostAPIGuildsResult = APIGuild; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild + */ +export interface RESTGetAPIGuildQuery { + /** + * When `true`, will return approximate member and presence counts for the guild + * + * @default false + */ + with_counts?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/guild#get-guild + */ +export type RESTGetAPIGuildResult = APIGuild; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-preview + */ +export type RESTGetAPIGuildPreviewResult = APIGuildPreview; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild + */ +export interface RESTPatchAPIGuildJSONBody { + /** + * New name for the guild (2-100 characters) + */ + name?: string; + /** + * Voice region id + * + * See https://discord.com/developers/docs/resources/voice#voice-region-object + */ + region?: string | null; + /** + * Verification level + * + * See https://discord.com/developers/docs/resources/guild#guild-object-verification-level + */ + verification_level?: GuildVerificationLevel | null; + /** + * Default message notification level + * + * See https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level + */ + default_message_notifications?: GuildDefaultMessageNotifications | null; + /** + * Explicit content filter level + * + * See https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level + */ + explicit_content_filter?: GuildExplicitContentFilter | null; + /** + * ID for afk channel + */ + afk_channel_id?: string | null; + /** + * AFK timeout in seconds + */ + afk_timeout?: number; + /** + * base64 1024x1024 png/jpeg/gif image for the guild icon (can be animated gif when the guild has `ANIMATED_ICON` feature) + * + * See https://discord.com/developers/docs/reference#image-data + */ + icon?: string | null; + /** + * User id to transfer guild ownership to (must be owner) + */ + owner_id?: string; + /** + * base64 16:9 png/jpeg image for the guild splash (when the guild has `INVITE_SPLASH` feature) + * + * See https://discord.com/developers/docs/reference#image-data + */ + splash?: string | null; + /** + * base64 png/jpeg image for the guild discovery splash (when the guild has `DISCOVERABLE` feature) + */ + discovery_splash?: string | null; + /** + * base64 16:9 png/jpeg image for the guild banner (when the guild has `BANNER` feature) + */ + banner?: string | null; + /** + * The id of the channel where guild notices such as welcome messages and boost events are posted + */ + system_channel_id?: string | null; + /** + * System channel flags + * + * See https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags + */ + system_channel_flags?: GuildSystemChannelFlags; + /** + * The id of the channel where Community guilds display rules and/or guidelines + */ + rules_channel_id?: string | null; + /** + * The id of the channel where admins and moderators of Community guilds receive notices from Discord + */ + public_updates_channel_id?: string | null; + /** + * The preferred locale of a Community guild used in server discovery and notices from Discord; defaults to "en-US" + * + * @default "en-US" (if the value is set to `null`) + */ + preferred_locale?: string | null; + /** + * Enabled guild features + * + * See https://discord.com/developers/docs/resources/guild#guild-object-guild-features + */ + features?: GuildFeature[]; + /** + * The description for the guild, if the guild is discoverable + */ + description?: string | null; +} + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild + */ +export type RESTPatchAPIGuildResult = APIGuild; + +/** + * https://discord.com/developers/docs/resources/guild#delete-guild + */ +export type RESTDeleteAPIGuildResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-channels + */ +export type RESTGetAPIGuildChannelsResult = APIChannel[]; + +/** + * https://discord.com/developers/docs/resources/guild#create-guild-channel + */ +export type RESTPostAPIGuildChannelJSONBody = Omit; + +/** + * https://discord.com/developers/docs/resources/guild#create-guild-channel + */ +export type RESTPostAPIGuildChannelResult = APIChannel; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions + */ +export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{ + /** + * Channel id + */ + id: string; + /** + * Sorting position of the channel + */ + position: number; + /** + * Sync channel overwrites with the new parent, when moving to a new `parent_id` + */ + lock_permissions?: boolean; + /** + * The new parent id of this channel + */ + parent_id?: string | null; +}>; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions + */ +export type RESTPatchAPIGuildChannelPositionsResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-member + */ +export type RESTGetAPIGuildMemberResult = APIGuildMember; + +/** + * https://discord.com/developers/docs/resources/guild#list-guild-members + */ +export interface RESTGetAPIGuildMembersQuery { + /** + * Max number of members to return (1-1000) + * + * @default 1 + */ + limit?: number; + /** + * The highest user id in the previous page + * + * @default 0 + */ + after?: string; +} + +/** + * https://discord.com/developers/docs/resources/guild#list-guild-members + */ +export type RESTGetAPIGuildMembersResult = APIGuildMember[]; + +export interface RESTGetAPIGuildMembersSearchQuery { + /** + * Query string to match username(s) and nickname(s) against + */ + query: string; + /** + * Max number of members to return (1-1000) + * + * @default 1 + */ + limit?: number; +} + +export type RESTGetAPIGuildMembersSearchResult = APIGuildMember[]; + +/** + * https://discord.com/developers/docs/resources/guild#add-guild-member + */ +export interface RESTPutAPIGuildMemberJSONBody { + /** + * An oauth2 access token granted with the `guilds.join` to the bot's application for the user you want to add to the guild + */ + access_token: string; + /** + * Value to set users nickname to + * + * Requires `MANAGE_NICKNAMES` permission + */ + nick?: string; + /** + * Array of role ids the member is assigned + * + * Requires `MANAGE_ROLES` permission + */ + roles?: string[]; + /** + * Whether the user is muted in voice channels + * + * Requires `MUTE_MEMBERS` permission + */ + mute?: boolean; + /** + * Whether the user is deafened in voice channels + * + * Requires `DEAFEN_MEMBERS` permission + */ + deaf?: boolean; +} + +export type RESTPutAPIGuildMemberResult = APIGuildMember | undefined; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-member + */ +export interface RESTPatchAPIGuildMemberJSONBody { + /** + * Value to set users nickname to + * + * Requires `MANAGE_NICKNAMES` permission + */ + nick?: string | null; + /** + * Array of role ids the member is assigned + * + * Requires `MANAGE_ROLES` permission + */ + roles?: string[] | null; + /** + * Whether the user is muted in voice channels. Will throw a 400 if the user is not in a voice channel + * + * Requires `MUTE_MEMBERS` permission + */ + mute?: boolean | null; + /** + * Whether the user is deafened in voice channels. Will throw a 400 if the user is not in a voice channel + * + * Requires `DEAFEN_MEMBERS` permission + */ + deaf?: boolean | null; + /** + * ID of channel to move user to (if they are connected to voice) + * + * Requires `MOVE_MEMBERS` permission + */ + channel_id?: string | null; +} + +/** + * https://discord.com/developers/docs/resources/guild#add-guild-member + */ +export type RESTPatchAPIGuildMemberResult = APIGuildMember; + +/** + * https://discord.com/developers/docs/resources/guild#modify-current-user-nick + */ +export interface RESTPatchAPICurrentGuildMemberNicknameJSONBody { + /** + * Value to set users nickname to + * + * Requires `CHANGE_NICKNAME` permission + */ + nick?: string | null; +} + +/** + * https://discord.com/developers/docs/resources/guild#modify-current-user-nick + */ +export type RESTPatchAPICurrentGuildMemberNicknameResult = Required; + +/** + * https://discord.com/developers/docs/resources/guild#add-guild-member-role + */ +export type RESTPutAPIGuildMemberRoleResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#remove-guild-member-role + */ +export type RESTDeleteAPIGuildMemberRoleResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#remove-guild-member + */ +export type RESTDeleteAPIGuildMemberResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-bans + */ +export type RESTGetAPIGuildBansResult = APIBan[]; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-ban + */ +export type RESTGetAPIGuildBanResult = APIBan; + +/** + * https://discord.com/developers/docs/resources/guild#create-guild-ban + */ +export interface RESTPutAPIGuildBanJSONBody { + /** + * Number of days to delete messages for (0-7) + */ + delete_message_days?: number; + /** + * Reason for the ban + */ + reason?: string; +} + +/** + * https://discord.com/developers/docs/resources/guild#create-guild-ban + */ +export type RESTPutAPIGuildBanResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#remove-guild-ban + */ +export type RESTDeleteAPIGuildBanResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-roles + */ +export type RESTGetAPIGuildRolesResult = APIRole[]; + +/** + * https://discord.com/developers/docs/resources/guild#create-guild-role + */ +export interface RESTPostAPIGuildRoleJSONBody { + /** + * Name of the role + * + * @default "new role" + */ + name?: string | null; + /** + * Bitwise value of the enabled/disabled permissions + * + * @default "​default role permissions in guild" + */ + permissions?: string | null; + /** + * RGB color value + * + * @default 0 + */ + color?: number | null; + /** + * Whether the role should be displayed separately in the sidebar + * + * @default false + */ + hoist?: boolean | null; + /** + * Whether the role should be mentionable + * + * @default false + */ + mentionable?: boolean | null; +} + +/** + * https://discord.com/developers/docs/resources/guild#create-guild-role + */ +export type RESTPostAPIGuildRoleResult = APIRole; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-role-positions + */ +export type RESTPatchAPIGuildRolePositionsJSONBody = Array<{ + /** + * Role id + */ + id: string; + /** + * Sorting position of the role + */ + position?: number; +}>; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-role-positions + */ +export type RESTPatchAPIGuildRolePositionsResult = APIRole[]; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-role + */ +export interface RESTPatchAPIGuildRoleJSONBody { + /** + * Name of the role + */ + name?: string | null; + /** + * Bitwise value of the enabled/disabled permissions + */ + permissions?: string | null; + /** + * RGB color value + */ + color?: number | null; + /** + * Whether the role should be displayed separately in the sidebar + */ + hoist?: boolean | null; + /** + * Whether the role should be mentionable + */ + mentionable?: boolean | null; +} + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-role + */ +export type RESTPatchAPIGuildRoleResult = APIRole; + +/** + * https://discord.com/developers/docs/resources/guild#delete-guild-role + */ +export type RESTDeleteAPIGuildRoleResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-prune-count + */ +export interface RESTGetAPIGuildPruneCountQuery { + /** + * Number of days to count prune for (1 or more) + * + * @default 7 + */ + days?: number; + /** + * Role(s) to include + * + * While this is typed as a string, it represents an array of + * role IDs delimited by commas + * + * See https://discord.com/developers/docs/resources/guild#get-guild-prune-count-query-string-params + */ + include_roles?: string; +} + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-prune-count + */ +export interface RESTGetAPIGuildPruneCountResult { + pruned: number; +} + +/** + * https://discord.com/developers/docs/resources/guild#begin-guild-prune + */ +export interface RESTPostAPIGuildPruneJSONBody { + /** + * Number of days to count prune for (1 or more) + * + * @default 7 + */ + days?: number; + /** + * Whether `pruned is returned, discouraged for large guilds + * + * @default true + */ + compute_prune_count?: boolean; + /** + * Role(s) to include + */ + include_roles?: string[]; +} + +/** + * https://discord.com/developers/docs/resources/guild#begin-guild-prune + */ +export interface RESTPostAPIGuildPruneResult { + pruned: number | null; +} + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-voice-regions + */ +export type RESTGetAPIGuildVoiceRegionsResult = APIVoiceRegion[]; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-invites + */ +export type RESTGetAPIGuildInvitesResult = APIExtendedInvite[]; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-integrations + */ +export type RESTGetAPIGuildIntegrationsResult = APIGuildIntegration[]; + +/** + * https://discord.com/developers/docs/resources/guild#create-guild-integration + */ +export interface RESTPostAPIGuildIntegrationJSONBody { + type: string; + id: string; +} + +export type RESTPostAPIGuildIntegrationResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-integration + */ +export interface RESTPatchAPIGuildIntegrationJSONBody { + /** + * The behavior when an integration subscription lapses + * + * See https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors + */ + expire_behavior?: IntegrationExpireBehavior | null; + /** + * Period (in days) where the integration will ignore lapsed subscriptions + */ + expire_grace_period?: number | null; + /** + * Whether emoticons should be synced for this integration (`twitch` only currently) + */ + enable_emoticons?: boolean | null; +} + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-integration + */ +export type RESTPatchAPIGuildIntegrationResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#delete-guild-integration + */ +export type RESTDeleteAPIGuildIntegrationResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#sync-guild-integration + */ +export type RESTPostAPIGuildIntegrationSyncResult = never; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-widget-settings + */ +export type RESTGetAPIGuildWidgetSettingsResult = APIGuildWidgetSettings; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-widget + */ +export type RESTPatchAPIGuildWidgetSettingsJSONBody = Partial; + +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-widget + */ +export type RESTPatchAPIGuildWidgetSettingsResult = APIGuildWidgetSettings; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-widget + */ +export type RESTGetAPIGuildWidgetJSONResult = APIGuildWidget; + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-vanity-url + */ +export interface RESTGetAPIGuildVanityUrlResult { + code: string | null; + uses: number; +} + +/** + * https://discord.com/developers/docs/resources/guild#get-guild-widget-image + */ +export interface RESTGetAPIGuildWidgetImageQuery { + /** + * Style of the widget image returned + * + * @default "shield" + */ + style?: GuildWidgetStyle; +} + +/** + * Note: while the return type is `ArrayBuffer`, the expected result is + * a buffer of sorts (depends if in browser or on node.js/deno). + */ +export type RESTGetAPIGuildWidgetImageResult = ArrayBuffer; + +export type RESTGetAPIGuildMemberVerificationResult = APIGuildMembershipScreening; + +export interface RESTPatchAPIGuildMemberVerificationJSONBody { + /** + * Whether Membership Screening is enabled + */ + enabled?: boolean; + /** + * Array of field objects serialized in a string + */ + form_fields?: string; + /** + * The server description to show in the screening form + */ + description?: string | null; +} + +export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening; diff --git a/.deno/v8/rest/interactions.ts b/.deno/v8/rest/interactions.ts new file mode 100644 index 00000000..6611a5f9 --- /dev/null +++ b/.deno/v8/rest/interactions.ts @@ -0,0 +1,77 @@ +import type { APIApplicationCommand, APIInteractionResponse } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#get-global-application-commands + */ +export type RESTGetAPIApplicationCommandsResult = APIApplicationCommand[]; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command + */ +export type RESTPostAPIApplicationCommandsJSONBody = Omit; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command + */ +export type RESTPostAPIApplicationCommandsResult = APIApplicationCommand; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command + */ +export type RESTPatchAPIApplicationCommandJSONBody = Partial; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command + */ +export type RESTPatchAPIApplicationCommandResult = APIApplicationCommand; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-commands + */ +export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[]; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command + */ +export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command + */ +export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command + */ +export type RESTPatchAPIApplicationGuildCommandJSONBody = Partial; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command + */ +export type RESTPatchAPIApplicationGuildCommandResult = APIApplicationCommand; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response + */ +export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse; + +/** + * https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response + */ +export type RESTPostAPIInteractionCallbackFormDataBody = + | { + /** + * JSON stringified message body + */ + payload_json?: string; + /** + * The file contents + */ + file: unknown; + } + | (RESTPostAPIInteractionCallbackJSONBody & { + /** + * The file contents + */ + file: unknown; + }); diff --git a/.deno/v8/rest/invite.ts b/.deno/v8/rest/invite.ts new file mode 100644 index 00000000..90c4a58b --- /dev/null +++ b/.deno/v8/rest/invite.ts @@ -0,0 +1,18 @@ +import type { APIInvite } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/invite#get-invite + */ +export interface RESTGetAPIInviteQuery { + /** + * Whether the invite should contain approximate member counts + */ + with_counts?: boolean; +} + +export type RESTGetAPIInviteResult = APIInvite; + +/** + * https://discord.com/developers/docs/resources/invite#delete-invite + */ +export type RESTDeleteAPIInviteResult = APIInvite; diff --git a/.deno/v8/rest/mod.ts b/.deno/v8/rest/mod.ts new file mode 100644 index 00000000..48e1b167 --- /dev/null +++ b/.deno/v8/rest/mod.ts @@ -0,0 +1,632 @@ +export * from './auditLog.ts'; +export * from './channel.ts'; +export * from './emoji.ts'; +export * from './gateway.ts'; +export * from './guild.ts'; +export * from './interactions.ts'; +export * from './invite.ts'; +export * from './oauth2.ts'; +export * from './template.ts'; +export * from './user.ts'; +export * from './voice.ts'; +export * from './webhook.ts'; + +export const APIVersion = '8'; +export const Routes = { + /** + * Route for: + * - GET `/guilds/{guild.id}/audit-logs` + */ + guildAuditLog(guildID: string) { + return `/guilds/${guildID}/audit-logs`; + }, + + /** + * Route for: + * - GET `/channels/{channel.id}` + * - PATCH `/channels/{channel.id}` + * - DELETE `/channels/{channel.id}` + */ + channel(channelID: string) { + return `/channels/${channelID}`; + }, + + /** + * Route for: + * - GET `/channels/{channel.id}/messages` + * - POST `/channels/{channel.id}/messages` + */ + channelMessages(channelID: string) { + return `/channels/${channelID}/messages`; + }, + + /** + * Route for: + * - GET `/channels/{channel.id}/messages/{message.id}` + * - PATCH `/channels/{channel.id}/messages/{message.id}` + * - DELETE `/channels/{channel.id}/messages/{message.id}` + */ + channelMessage(channelID: string, messageID: string) { + return `/channels/${channelID}/messages/${messageID}`; + }, + + /** + * Route for: + * - POST `/channels/{channel.id}/messages/{message.id}/crosspost` + */ + channelMessageCrosspost(channelID: string, messageID: string) { + return `/channels/${channelID}/messages/${messageID}/crosspost`; + }, + + /** + * Route for: + * - PUT `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me` + * - DELETE `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me` + * + * **Note**: You need to URL encode the emoji yourself + */ + channelMessageOwnReaction(channelID: string, messageID: string, emoji: string) { + return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me`; + }, + + /** + * Route for: + * - DELETE `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/{user.id}` + * + * **Note**: You need to URL encode the emoji yourself + */ + channelMessageUserReaction(channelID: string, messageID: string, emoji: string, userID: string) { + return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}`; + }, + + /** + * Route for: + * - GET `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}` + * - DELETE `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}` + * + * **Note**: You need to URL encode the emoji yourself + */ + channelMessageReaction(channelID: string, messageID: string, emoji: string) { + return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}`; + }, + + /** + * Route for: + * - DELETE `/channels/{channel.id}/messages/{message.id}/reactions` + */ + channelMessageAllReactions(channelID: string, messageID: string) { + return `/channels/${channelID}/messages/${messageID}/reactions`; + }, + + /** + * Route for: + * - POST `/channels/{channel.id}/messages/bulk-delete` + */ + channelBulkDelete(channelID: string) { + return `/channels/${channelID}/messages/bulk-delete`; + }, + + /** + * Route for: + * - PUT `/channels/{channel.id}/permissions/{overwrite.id}` + * - DELETE `/channels/{channel.id}/permissions/{overwrite.id}` + */ + channelPermission(channelID: string, overwriteID: string) { + return `/channels/${channelID}/permissions/${overwriteID}`; + }, + + /** + * Route for: + * - GET `/channels/{channel.id}/invites` + * - POST `/channels/{channel.id}/invites` + */ + channelInvites(channelID: string) { + return `/channels/${channelID}/invites`; + }, + + /** + * Route for: + * - POST `/channels/{channel.id}/followers` + */ + channelFollowers(channelID: string) { + return `/channels/${channelID}/followers`; + }, + + /** + * Route for: + * - POST `/channels/{channel.id}/typing` + */ + channelTyping(channelID: string) { + return `/channels/${channelID}/typing`; + }, + + /** + * Route for: + * - GET `/channels/{channel.id}/pins` + */ + channelPins(channelID: string) { + return `/channels/${channelID}/pins`; + }, + + /** + * Route for: + * - PUT `/channels/{channel.id}/pins/{message.id}` + * - DELETE `/channels/{channel.id}/pins/{message.id}` + */ + channelPin(channelID: string, messageID: string) { + return `/channels/${channelID}/pins/${messageID}`; + }, + + /** + * Route for: + * - PUT `/channels/{channel.id}/recipients/{user.id}` + * - DELETE `/channels/{channel.id}/recipients/{user.id}` + */ + channelRecipient(channelID: string, userID: string) { + return `/channels/${channelID}/recipients/${userID}`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/emojis` + * - POST `/guilds/{guild.id}/emojis` + */ + guildEmojis(guildID: string) { + return `/guilds/${guildID}/emojis`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/emojis/{emoji.id}` + * - PATCH `/guilds/{guild.id}/emojis/{emoji.id}` + * - DELETE `/guilds/{guild.id}/emojis/{emoji.id}` + */ + guildEmoji(guildID: string, emojiID: string) { + return `/guilds/${guildID}/emojis/${emojiID}`; + }, + + /** + * Route for: + * - POST `/guilds` + */ + guilds() { + return '/guilds'; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}` + * - PATCH `/guilds/{guild.id}` + * - DELETE `/guilds/{guild.id}` + */ + guild(guildID: string) { + return `/guilds/${guildID}`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/preview` + */ + guildPreview(guildID: string) { + return `/guilds/${guildID}/preview`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/channels` + * - POST `/guilds/{guild.id}/channels` + * - PATCH `/guilds/{guild.id}/channels` + */ + guildChannels(guildID: string) { + return `/guilds/${guildID}/channels`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/members/{user.id}` + * - PUT `/guilds/{guild.id}/members/{user.id}` + * - PATCH `/guilds/{guild.id}/members/{user.id}` + * - DELETE `/guilds/{guild.id}/members/{user.id}` + */ + guildMember(guildID: string, userID: string) { + return `/guilds/${guildID}/members/${userID}`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/members` + */ + guildMembers(guildID: string) { + return `/guilds/${guildID}/members`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/members/search` + */ + guildMembersSearch(guildID: string) { + return `/guilds/${guildID}/members/search`; + }, + + /** + * Route for: + * - PATCH `/guilds/{guild.id}/members/@me/nick` + */ + guildCurrentMemberNickname(guildID: string) { + return `/guilds/${guildID}/members/@me/nick`; + }, + + /** + * Route for: + * - PUT `/guilds/{guild.id}/members/{user.id}/roles/{role.id}` + * - DELETE `/guilds/{guild.id}/members/{user.id}/roles/{role.id}` + */ + guildMemberRole(guildID: string, memberID: string, roleID: string) { + return `/guilds/${guildID}/members/${memberID}/roles/${roleID}`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/bans` + */ + guildBans(guildID: string) { + return `/guilds/${guildID}/bans`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/bans/{user.id}` + * - PUT `/guilds/{guild.id}/bans/{user.id}` + * - DELETE `/guilds/{guild.id}/bans/{user.id}` + */ + guildBan(guildID: string, userID: string) { + return `/guilds/${guildID}/bans/${userID}`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/roles` + * - POST `/guilds/{guild.id}/roles` + * - PATCH `/guilds/{guild.id}/roles` + */ + guildRoles(guildID: string) { + return `/guilds/${guildID}/roles`; + }, + + /** + * Route for: + * - PATCH `/guilds/{guild.id}/roles/{role.id}` + * - DELETE `/guilds/{guild.id}/roles/{role.id}` + */ + guildRole(guildID: string, roleID: string) { + return `/guilds/${guildID}/roles/${roleID}`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/prune` + * - POST `/guilds/{guild.id}/prune` + */ + guildPrune(guildID: string) { + return `/guilds/${guildID}/prune`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/regions` + */ + guildVoiceRegions(guildID: string) { + return `/guilds/${guildID}/regions`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/invites` + */ + guildInvites(guildID: string) { + return `/guilds/${guildID}/invites`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/integrations` + * - POST `/guilds/{guild.id}/integrations` + */ + guildIntegrations(guildID: string) { + return `/guilds/${guildID}/integrations`; + }, + + /** + * Route for: + * - PATCH `/guilds/{guild.id}/integrations/{integration.id}` + * - DELETE `/guilds/{guild.id}/integrations/{integration.id}` + */ + guildIntegration(guildID: string, integrationID: string) { + return `/guilds/${guildID}/integrations/${integrationID}`; + }, + + /** + * Route for: + * - POST `/guilds/{guild.id}/integrations/{integration.id}/sync` + */ + guildIntegrationSync(guildID: string, integrationID: string) { + return `/guilds/${guildID}/integrations/${integrationID}/sync`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/widget` + * - PATCH `/guilds/{guild.id}/widget` + */ + guildWidgetSettings(guildID: string) { + return `/guilds/${guildID}/widget`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/widget.json` + */ + guildWidgetJSON(guildID: string) { + return `/guilds/${guildID}/widget.json`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/vanity-url` + */ + guildVanityUrl(guildID: string) { + return `/guilds/${guildID}/vanity-url`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/widget.png` + */ + guildWidgetImage(guildID: string) { + return `/guilds/${guildID}/widget.png`; + }, + + /** + * Route for: + * - GET `/invites/{invite.code}` + * - DELETE `/invites/{invite.code}` + */ + invite(code: string) { + return `/invites/${code}`; + }, + + /** + * Route for: + * - GET `/guilds/templates/{template.code}` + * - POST `/guilds/templates/{template.code}` + */ + template(code: string) { + return `/guilds/templates/${code}`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/templates` + * - POST `/guilds/{guild.id}/templates` + */ + guildTemplates(guildID: string) { + return `/guilds/${guildID}/templates`; + }, + + /** + * Route for: + * - PUT `/guilds/{guild.id}/templates/{template.code}` + * - PATCH `/guilds/{guild.id}/templates/{template.code}` + * - DELETE `/guilds/{guild.id}/templates/{template.code}` + */ + guildTemplate(guildID: string, code: string) { + return `/guilds/${guildID}/templates/${code}`; + }, + + /** + * Route for: + * - GET `/users/@me` + * - GET `/users/{user.id}` + * - PATCH `/users/@me` + * + * @param [userID='@me'] The user ID, defaulted to `@me` + */ + user(userID = '@me') { + return `/users/${userID}`; + }, + + /** + * Route for: + * - GET `/users/@me/guilds` + */ + userGuilds() { + return `/users/@me/guilds`; + }, + + /** + * Route for: + * - DELETE `/users/@me/guilds/{guild.id}` + */ + userGuild(guildID: string) { + return `/users/@me/guilds/${guildID}`; + }, + + /** + * Route for: + * - POST `/users/@me/channels` + */ + userChannels() { + return `/users/@me/channels`; + }, + + /** + * Route for: + * - GET `/users/@me/connections` + */ + userConnections() { + return `/users/@me/connections`; + }, + + /** + * Route for: + * - GET `/voice/regions` + */ + voiceRegions() { + return `/voice/regions`; + }, + + /** + * Route for: + * - GET `/channels/{channel.id}/webhooks` + * - POST `/channels/{channel.id}/webhooks` + */ + channelWebhooks(channelID: string) { + return `/channels/${channelID}/webhooks`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/webhooks` + */ + guildWebhooks(guildID: string) { + return `/guilds/${guildID}/webhooks`; + }, + + /** + * Route for: + * - GET `/webhooks/{webhook.id}` + * - GET `/webhooks/{webhook.id}/{webhook.token}` + * - PATCH `/webhooks/{webhook.id}` + * - PATCH `/webhooks/{webhook.id}/{webhook.token}` + * - DELETE `/webhooks/{webhook.id}` + * - DELETE `/webhooks/{webhook.id}/{webhook.token}` + * - POST `/webhooks/{webhook.id}/{webhook.token}` + * + * - POST `/webhooks/{application.id}/{interaction.token}` + */ + webhook(webhookID: string, webhookToken?: string) { + const parts = ['', 'webhooks', webhookID]; + + if (webhookToken) parts.push(webhookToken); + + return parts.join('/'); + }, + + /** + * Route for: + * - PATCH `/webhooks/{webhook.id}/{webhook.token}/messages/@original` + * - PATCH `/webhooks/{webhook.id}/{webhook.token}/messages/{message.id}` + * - DELETE `/webhooks/{webhook.id}/{webhook.token}/messages/@original` + * - DELETE `/webhooks/{webhook.id}/{webhook.token}/messages/{message.id}` + * + * - PATCH `/webhooks/{application.id}/{interaction.token}/messages/@original` + * - PATCH `/webhooks/{application.id}/{interaction.token}/messages/{message.id}` + * - DELETE `/webhooks/{application.id}/{interaction.token}/messages/{message.id}` + * + * @param [messageID='@original'] The message ID to change, defaulted to `@original` + */ + webhookMessage(webhookID: string, webhookToken: string, messageID = '@original') { + return `/webhooks/${webhookID}/${webhookToken}/messages/${messageID}`; + }, + + /** + * Route for: + * - POST `/webhooks/{webhook.id}/{webhook.token}/github` + * - POST `/webhooks/{webhook.id}/{webhook.token}/slack` + */ + webhookPlatform(webhookID: string, webhookToken: string, platform: 'github' | 'slack') { + return `/webhooks/${webhookID}/${webhookToken}/${platform}`; + }, + + /** + * Route for: + * - GET `/gateway` + */ + gateway() { + return `/gateway`; + }, + + /** + * Route for: + * - GET `/gateway/bot` + */ + gatewayBot() { + return `/gateway/bot`; + }, + + /** + * Route for: + * - GET `/oauth2/applications/@me` + */ + oauth2CurrentApplication() { + return `/oauth2/applications/@me`; + }, + + /** + * Route for: + * - GET `/applications/{application.id}/commands` + * - POST `/applications/{application.id}/commands` + */ + applicationCommands(applicationID: string) { + return `/applications/${applicationID}/commands`; + }, + + /** + * Route for: + * - PATCH `/applications/{application.id}/commands/{command.id}` + * - DELETE `/applications/{application.id}/commands/{command.id}` + */ + applicationCommand(applicationID: string, commandID: string) { + return `/applications/${applicationID}/commands/${commandID}`; + }, + + /** + * Route for: + * - GET `/applications/{application.id}/guilds/{guild.id}/commands` + * - POST `/applications/{application.id}/guilds/{guild.id}/commands` + */ + applicationGuildCommands(applicationID: string, guildID: string) { + return `/applications/${applicationID}/guilds/${guildID}/commands`; + }, + + /** + * Route for: + * - PATCH `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}` + * - DELETE `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}` + */ + applicationGuildCommand(applicationID: string, guildID: string, commandID: string) { + return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}`; + }, + + /** + * Route for: + * - POST `/interactions/{interaction.id}/{interaction.token}/callback` + */ + interactionCallback(interactionID: string, interactionToken: string) { + return `/interactions/${interactionID}/${interactionToken}/callback`; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/member-verification` + * - PATCH `/guilds/{guild.id}/member-verification` + */ + guildMemberVerification(guildID: string) { + return `/guilds/${guildID}/member-verification`; + }, +}; + +export const OAuth2Routes = { + authorizationURL: `https://discord.com/api/v${APIVersion}/oauth2/authorize`, + tokenURL: `https://discord.com/api/v${APIVersion}/oauth2/token`, + /** + * See https://tools.ietf.org/html/rfc7009 + */ + tokenRevocationURL: `https://discord.com/api/v${APIVersion}/oauth2/token/revoke`, +} as const; + +/** + * Freeze route object + * @internal + */ +Object.freeze(OAuth2Routes); diff --git a/.deno/v8/rest/oauth2.ts b/.deno/v8/rest/oauth2.ts new file mode 100644 index 00000000..c7ee9013 --- /dev/null +++ b/.deno/v8/rest/oauth2.ts @@ -0,0 +1,179 @@ +import type { APIApplication, APIGuild, APIWebhook, OAuth2Scopes } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/topics/oauth2#get-current-application-information + */ +export type RESTGetAPIOauth2CurrentApplicationResult = Omit; + +/** + * https://discord.com/developers/docs/topics/oauth2#authorization-code-grant + */ +export interface RESTOAuth2AuthorizationQuery { + response_type: 'code'; + client_id: string; + scope: string; + redirect_uri?: string; + state?: string; + prompt?: 'consent' | 'none'; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-redirect-url-example + */ +export interface RESTOAuth2AuthorizationQueryResult { + code: string; + state?: string; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-redirect-url-example + */ +export interface RESTPostOAuth2AccessTokenURLEncodedData { + client_id: string; + client_secret: string; + grant_type: 'authorization_code'; + code: string; + redirect_uri?: string; + scope: string; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-access-token-response + */ +export interface RESTPostOAuth2AccessTokenResult { + access_token: string; + token_type: string; + expires_in: number; + refresh_token: string; + scope: string; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-refresh-token-exchange-example + */ +export interface RESTPostOAuth2RefreshTokenURLEncodedData { + client_id: string; + client_secret: string; + grant_type: 'refresh_token'; + refresh_token: string; + redirect_uri?: string; + scope: string; +} + +export type RESTPostOAuth2RefreshTokenResult = RESTPostOAuth2AccessTokenResult; + +/** + * https://discord.com/developers/docs/topics/oauth2#implicit-grant + */ +export interface RESTOAuth2ImplicitAuthorizationQuery { + response_type: 'token'; + client_id: string; + scope: string; + redirect_uri?: string; + state?: string; + prompt?: 'consent' | 'none'; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#implicit-grant-redirect-url-example + */ +export type RESTOAuth2ImplicitAuthorizationURLFragmentResult = Omit; + +/** + * https://discord.com/developers/docs/topics/oauth2#client-credentials-grant + */ +export interface RESTPostOAuth2ClientCredentialsURLEncodedData { + grant_type: 'client_credentials'; + scope: string; +} + +export type RESTPostOAuth2ClientCredentialsResult = RESTOAuth2ImplicitAuthorizationURLFragmentResult; + +/** + * https://discord.com/developers/docs/topics/oauth2#bot-authorization-flow-bot-auth-parameters + */ +export interface RESTOAuth2BotAuthorizationQuery { + /** + * Your app's client id + */ + client_id: string; + /** + * Needs to include bot for the bot flow + */ + scope: + | OAuth2Scopes.Bot + | `${string}${' ' | '%20'}${OAuth2Scopes.Bot}` + | `${OAuth2Scopes.Bot}${' ' | '%20'}${string}` + | `${string}${' ' | '%20'}${OAuth2Scopes.Bot}${string}${' ' | '%20'}`; + /** + * The permissions you're requesting + * + * See https://discord.com/developers/docs/topics/permissions + */ + permissions?: string; + /** + * Pre-fills the dropdown picker with a guild for the user + */ + guild_id?: string; + /** + * `true` or `false`—disallows the user from changing the guild dropdown + */ + disable_guild_select?: boolean; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization + */ +export interface RESTOAuth2AdvancedBotAuthorizationQuery { + client_id: string; + /** + * This assumes you include the `bot` scope alongside others (like `identify` for example) + */ + scope: + | OAuth2Scopes.Bot + | `${string}${' ' | '%20'}${OAuth2Scopes.Bot}` + | `${OAuth2Scopes.Bot}${' ' | '%20'}${string}` + | `${string}${' ' | '%20'}${OAuth2Scopes.Bot}${string}${' ' | '%20'}`; + /** + * The required permissions bitfield, stringified + */ + permissions?: string; + guild_id?: string; + disable_guild_select?: boolean; + response_type: string; + redirect_uri?: string; +} + +export interface RESTOAuth2AdvancedBotAuthorizationQueryResult { + code: string; + state?: string; + guild_id: string; + permissions: string; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization-extended-bot-authorization-access-token-example + */ +export interface RESTPostOAuth2AccessTokenWithBotAndGuildsScopeResult { + access_token: string; + token_type: string; + expires_in: number; + refresh_token: string; + scope: string; + guild: APIGuild; +} + +/** + * https://discord.com/developers/docs/topics/oauth2#webhooks-webhook-token-response-example + */ +export interface RESTPostOAuth2AccessTokenWithBotAndWebhookIncomingScopeResult { + access_token: string; + token_type: string; + expires_in: number; + refresh_token: string; + scope: string; + webhook: APIWebhook; +} + +export type RESTPostOAuth2AccessTokenWithBotAndGuildsAndWebhookIncomingScopeResult = RESTPostOAuth2AccessTokenWithBotAndGuildsScopeResult & + RESTPostOAuth2AccessTokenWithBotAndWebhookIncomingScopeResult; diff --git a/.deno/v8/rest/template.ts b/.deno/v8/rest/template.ts new file mode 100644 index 00000000..ceb89eb2 --- /dev/null +++ b/.deno/v8/rest/template.ts @@ -0,0 +1,70 @@ +import type { APIGuild, APITemplate } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/template#get-template + */ +export type RESTGetAPITemplateResult = APITemplate; + +/** + * https://discord.com/developers/docs/resources/template#create-guild-from-template + */ +export interface RESTPostAPITemplateCreateGuildJSONBody { + /** + * Name of the guild (2-100 characters) + */ + name: string; + /** + * base64 1024x1024 png/jpeg image for the guild icon + * + * See https://discord.com/developers/docs/reference#image-data + */ + icon?: string; +} +/** + * https://discord.com/developers/docs/resources/template#create-guild-from-template + */ +export type RESTPostAPITemplateCreateGuildResult = APIGuild; + +/** + * https://discord.com/developers/docs/resources/template#get-guild-templates + */ +export type RESTGetAPIGuildTemplatesResult = APITemplate[]; + +/** + * https://discord.com/developers/docs/resources/template#create-guild-template + */ +export interface RESTPostAPIGuildTemplatesJSONBody { + /** + * Name of the template (1-100 characters) + */ + name: string; + /** + * Description for the template (0-120 characters) + */ + description?: string | null; +} + +/** + * https://discord.com/developers/docs/resources/template#create-guild-template + */ +export type RESTPostAPIGuildTemplatesResult = APITemplate; + +/** + * https://discord.com/developers/docs/resources/template#sync-guild-template + */ +export type RESTPutAPIGuildTemplateSyncResult = APITemplate; + +/** + * https://discord.com/developers/docs/resources/template#modify-guild-template + */ +export type RESTPatchAPIGuildTemplateJSONBody = Partial; + +/** + * https://discord.com/developers/docs/resources/template#modify-guild-template + */ +export type RESTPatchAPIGuildTemplateResult = APITemplate; + +/** + * https://discord.com/developers/docs/resources/template#delete-guild-template + */ +export type RESTDeleteAPIGuildTemplateResult = APITemplate; diff --git a/.deno/v8/rest/user.ts b/.deno/v8/rest/user.ts new file mode 100644 index 00000000..3e28a138 --- /dev/null +++ b/.deno/v8/rest/user.ts @@ -0,0 +1,89 @@ +import type { APIChannel, APIConnection, APIUser, GuildFeature } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/user#get-current-user + */ +export type RESTGetAPICurrentUserResult = APIUser; + +/** + * https://discord.com/developers/docs/resources/user#get-user + */ +export type RESTGetAPIUserResult = APIUser; + +/** + * https://discord.com/developers/docs/resources/user#modify-current-user + */ +export interface RESTPatchAPICurrentUserJSONBody { + /** + * User's username, if changed may cause the user's discriminator to be randomized + */ + username?: string; + /** + * If passed, modifies the user's avatar + */ + avatar?: string | null; +} + +/** + * https://discord.com/developers/docs/resources/user#modify-current-user + */ +export type RESTPatchAPICurrentUserResult = APIUser; + +/** + * https://discord.com/developers/docs/resources/user#get-current-user-guilds + */ +export interface RESTGetAPICurrentUserGuildsQuery { + /** + * Get guilds before this guild ID + */ + before?: string; + /** + * Get guilds after this guild ID + */ + after?: string; + /** + * Max number of guilds to return (1-100) + * + * @default 100 + */ + limit?: number; +} + +export interface RESTAPIPartialCurrentUserGuild { + id: string; + name: string; + icon: string | null; + owner: boolean; + features: GuildFeature[]; + permissions: string; +} + +/** + * https://discord.com/developers/docs/resources/user#get-current-user-guilds + */ +export type RESTGetAPICurrentUserGuildsResult = RESTAPIPartialCurrentUserGuild[]; + +/** + * https://discord.com/developers/docs/resources/user#leave-guild + */ +export type RESTDeleteAPICurrentUserGuildResult = never; + +/** + * https://discord.com/developers/docs/resources/user#create-dm + */ +export interface RESTPostAPICurrentUserCreateDMChannelJSONBody { + /** + * The recipient to open a DM channel with + */ + recipient_id: string; +} + +/** + * https://discord.com/developers/docs/resources/user#create-dm + */ +export type RESTPostAPICurrentUserCreateDMChannelResult = APIChannel; + +/** + * https://discord.com/developers/docs/resources/user#get-user-connections + */ +export type RESTGetAPICurrentUserConnectionsResult = APIConnection[]; diff --git a/.deno/v8/rest/voice.ts b/.deno/v8/rest/voice.ts new file mode 100644 index 00000000..4fabe2c4 --- /dev/null +++ b/.deno/v8/rest/voice.ts @@ -0,0 +1,6 @@ +import type { APIVoiceRegion } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/voice#list-voice-regions + */ +export type GetAPIVoiceRegionsResult = APIVoiceRegion[]; diff --git a/.deno/v8/rest/webhook.ts b/.deno/v8/rest/webhook.ts new file mode 100644 index 00000000..7bceff93 --- /dev/null +++ b/.deno/v8/rest/webhook.ts @@ -0,0 +1,222 @@ +import type { APIAllowedMentions, APIEmbed, APIMessage, APIWebhook } from '../payloads/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/webhook#create-webhook + */ +export interface RESTPostAPIChannelWebhookJSONBody { + /** + * Name of the webhook (1-80 characters) + */ + name: string; + /** + * Image for the default webhook avatar + * + * See https://discord.com/developers/docs/reference#image-data + */ + avatar?: string | null; +} + +/** + * https://discord.com/developers/docs/resources/webhook#create-webhook + */ +export type RESTPostAPIChannelWebhookResult = APIWebhook; + +/** + * https://discord.com/developers/docs/resources/webhook#get-channel-webhooks + */ +export type RESTGetAPIChannelWebhooksResult = APIWebhook[]; + +/** + * https://discord.com/developers/docs/resources/webhook#get-guild-webhooks + */ +export type RESTGetAPIGuildWebhooksResult = APIWebhook[]; + +/** + * https://discord.com/developers/docs/resources/webhook#get-webhook + */ +export type RESTGetAPIWebhookResult = APIWebhook; + +/** + * https://discord.com/developers/docs/resources/webhook#get-webhook-with-token + */ +export type RESTGetAPIWebhookWithTokenResult = Omit; + +/** + * https://discord.com/developers/docs/resources/webhook#modify-webhook + */ +export interface RESTPatchAPIWebhookJSONBody { + /** + * The default name of the webhook + */ + name?: string; + /** + * Image for the default webhook avatar + * + * See https://discord.com/developers/docs/reference#image-data + */ + avatar?: string | null; + /** + * The new channel id this webhook should be moved to + */ + channel_id?: string; +} + +/** + * https://discord.com/developers/docs/resources/webhook#modify-webhook + */ +export type RESTPatchAPIWebhookResult = APIWebhook; + +/** + * https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token + */ +export type RESTPatchAPIWebhookWithTokenJSONBody = Omit; + +/** + * https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token + */ +export type RESTPatchAPIWebhookWithTokenResult = RESTGetAPIWebhookWithTokenResult; + +/** + * https://discord.com/developers/docs/resources/webhook#delete-webhook + */ +export type RESTDeleteAPIWebhookResult = never; + +/** + * https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token + */ +export type RESTDeleteAPIWebhookWithTokenResult = never; + +/** + * https://discord.com/developers/docs/resources/webhook#execute-webhook + */ +export interface RESTPostAPIWebhookWithTokenJSONBody { + /** + * The message contents (up to 2000 characters) + */ + content?: string; + /** + * Override the default username of the webhook + */ + username?: string; + /** + * Override the default avatar of the webhook + */ + avatar_url?: string; + /** + * `true` if this is a TTS message + */ + tts?: boolean; + /** + * Embedded `rich` content + */ + embeds?: APIEmbed[]; + /** + * Allowed mentions for the message + */ + allowed_mentions?: APIAllowedMentions; +} + +/** + * https://discord.com/developers/docs/resources/webhook#execute-webhook + */ +export type RESTPostAPIWebhookWithTokenFormDataBody = + | { + /** + * JSON stringified message body + */ + payload_json?: string; + /** + * The file contents + */ + file: unknown; + } + | (RESTPostAPIWebhookWithTokenJSONBody & { + /** + * The file contents + */ + file: unknown; + }); + +/** + * https://discord.com/developers/docs/resources/webhook#execute-webhook-querystring-params + */ +export interface RESTPostAPIWebhookWithTokenQuery { + /** + * Waits for server confirmation of message send before response, and returns the created message body + * (defaults to `false`; when `false` a message that is not saved does not return an error) + * + * @default false + */ + wait?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/webhook#execute-webhook + */ +export type RESTPostAPIWebhookWithTokenResult = never; + +/** + * Received when a call to https://discord.com/developers/docs/resources/webhook#execute-webhook receives + * the `wait` query parameter set to `true` + * + * See https://discord.com/developers/docs/resources/webhook#execute-webhook-querystring-params + */ +export type RESTPostAPIWebhookWithTokenWaitResult = APIMessage; + +/** + * https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook-querystring-params + */ +export type RESTPostAPIWebhookWithTokenSlackQuery = RESTPostAPIWebhookWithTokenQuery; + +/** + * https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook + */ +export type RESTPostAPIWebhookWithTokenSlackResult = never; + +/** + * Received when a call to https://discord.com/developers/docs/resources/webhook#execute-webhook receives + * the `wait` query parameter set to `true` + * + * See https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook-querystring-params + */ +export type RESTPostAPIWebhookWithTokenSlackWaitResult = APIMessage; + +/** + * https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook-querystring-params + */ +export type RESTPostAPIWebhookWithTokenGitHubQuery = RESTPostAPIWebhookWithTokenQuery; + +/** + * https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook + */ +export type RESTPostAPIWebhookWithTokenGitHubResult = never; + +/** + * Received when a call to https://discord.com/developers/docs/resources/webhook#execute-webhook receives + * the `wait` query parameter set to `true` + * + * See https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook-querystring-params + */ +export type RESTPostAPIWebhookWithTokenGitHubWaitResult = APIMessage; + +/** + * https://discord.com/developers/docs/resources/webhook#edit-webhook-message + */ +export type RESTPatchAPIWebhookWithTokenMessageJSONBody = Nullable< + Pick +>; + +export type RESTPatchAPIWebhookWithTokenMessageFormDataBody = + | { + payload_json: string; + } + | RESTPatchAPIWebhookWithTokenMessageJSONBody; + +/** + * https://discord.com/developers/docs/resources/webhook#delete-webhook-message + */ +export type RESTDeleteAPIWebhookWithTokenMessageResult = never; + +type Nullable = { + [P in keyof T]: T[P] | null; +}; diff --git a/.github/workflows/codequality.yml b/.github/workflows/codequality.yml index 75c0efba..79eb4692 100644 --- a/.github/workflows/codequality.yml +++ b/.github/workflows/codequality.yml @@ -13,30 +13,30 @@ jobs: name: ESLint runs-on: ubuntu-latest steps: - - name: Checkout Project - uses: actions/checkout@v1 - - name: Use Node.js 14 - uses: actions/setup-node@v1 - with: - node-version: 14 - - name: Install Dependencies - run: npm ci - - name: Run ESLint - uses: icrawl/action-eslint@v1 - with: - custom-glob: '{v*,default,common}/**' + - name: Checkout Project + uses: actions/checkout@v1 + - name: Use Node.js 14 + uses: actions/setup-node@v1 + with: + node-version: 14 + - name: Install Dependencies + run: npm ci + - name: Run ESLint + uses: icrawl/action-eslint@v1 + with: + custom-glob: '{v*,default,common}/**' TypeScript: name: TypeScript runs-on: ubuntu-latest steps: - - name: Checkout Project - uses: actions/checkout@v1 - - name: Use Node.js 14 - uses: actions/setup-node@v1 - with: - node-version: 14 - - name: Install Dependencies - run: npm ci - - name: Run TSC - uses: icrawl/action-tsc@v1 + - name: Checkout Project + uses: actions/checkout@v1 + - name: Use Node.js 14 + uses: actions/setup-node@v1 + with: + node-version: 14 + - name: Install Dependencies + run: npm ci + - name: Run TSC + uses: icrawl/action-tsc@v1 diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml new file mode 100644 index 00000000..2e7f4f44 --- /dev/null +++ b/.github/workflows/deno.yml @@ -0,0 +1,40 @@ +name: Deno Deploy + +on: + push: + +jobs: + BuildDeno: + name: Publish Deno Types + runs-on: ubuntu-latest + if: "contains(github.event.head_commit.message, 'release')" + + steps: + - name: Checkout Project + uses: actions/checkout@v2 + + - name: Use Node.js 14 + uses: actions/setup-node@v1 + with: + node-version: 14 + + - name: Install Dependencies + run: npm ci + + - name: Get GitHub Branch Name + run: echo "GITHUB_BRANCH_NAME=$(echo ${{ github.ref }} | cut -c12-)" >> $GITHUB_ENV + + - name: Push new code + run: | + # Build files + npm run build:deno + + echo -e "\n# Commit and push" + git add --all . + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git commit -m "build: deno build for ${GITHUB_SHA}" || true + git push origin $TARGET_BRANCH + env: + TARGET_BRANCH: '${{ env.GITHUB_BRANCH_NAME }}' + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' diff --git a/.gitignore b/.gitignore index 40b0ecdc..f28c7257 100644 --- a/.gitignore +++ b/.gitignore @@ -11,11 +11,14 @@ debug.log v*/**/*.js v*/**/*.map v*/**/*.d.ts +v*/**/*.mjs default/*.js default/*.map default/*.d.ts +default/*.mjs common/*.js common/*.map common/*.d.ts +common/*.mjs diff --git a/README.md b/README.md index cc8d5316..e54094ef 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,43 @@ yarn add discord-api-types pnpm add discord-api-types ``` +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 the default API version +import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/.deno/mod.ts'; + +// Importing a specific API version +import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/.deno/v8/mod.ts'; +``` + +2. From [deno.land/x](https://deno.land/x) + +```ts +// Importing the default API version +import { APIUser } from 'https://deno.land/x/discord_api_types@0.12.0/mod.ts'; + +// Importing a specific API version +import { APIUser } from 'https://deno.land/x/discord_api_types@0.12.0/v8/mod.ts'; +``` + +3. From [skypack.dev](https://www.skypack.dev/) + +```ts +// Importing the default API version +import { APIUser } from 'https://cdn.skypack.dev/discord-api-types?dts'; + +// Importing a specific API version +import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v8?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 `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. @@ -41,7 +73,7 @@ The exports of each API version is split into three main parts: - There may be types exported that are identical for all versions. These will be exported as is and can be found in the `common` directory. They will still be prefixed accordingly as described above. -**Warning**: This package documents just KNOWN (and documented) properties. Anything that isn't documented will NOT be added to this package (unless said properties are in an open Pull Request to Discord's [API Documentation repository](https://github.com/discord/discord-api-docs) or known through other means *and have received the green light to be used*). For clarification's sake, this means that properties that are only known through the process of datamining and have not yet been confirmed in a way as described will NOT be included. +**Warning**: This package documents just KNOWN (and documented) properties. Anything that isn't documented will NOT be added to this package (unless said properties are in an open Pull Request to Discord's [API Documentation repository](https://github.com/discord/discord-api-docs) or known through other means _and have received the green light to be used_). For clarification's sake, this means that properties that are only known through the process of data mining and have not yet been confirmed in a way as described will NOT be included. ## Usage diff --git a/common/index.ts b/common/index.ts index 89531c1f..2d1815b3 100644 --- a/common/index.ts +++ b/common/index.ts @@ -110,9 +110,7 @@ export const enum RESTJSONErrorCodes { */ export const enum RPCErrorCodes { UnknownError = 1000, - InvalidPayload = 4000, - InvalidCommand = 4002, InvalidGuild, InvalidEvent, @@ -122,8 +120,7 @@ export const enum RPCErrorCodes { InvalidOrigin, InvalidToken, InvalidUser, - - Oauth2Error = 5000, + OAuth2Error = 5000, SelectChannelTimedOut, GetGuildTimedOut, SelectVoiceForceRequired, diff --git a/default/index.ts b/default/index.ts index 4a426057..4057428f 100644 --- a/default/index.ts +++ b/default/index.ts @@ -1,4 +1,4 @@ // This file exports all the types available in the default API version // Thereby, things MAY break in the future -export * from '../v8'; +export * from '../v8/index'; diff --git a/package-lock.json b/package-lock.json index 5e7db7be..60bf3c54 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "discord-api-types", - "version": "0.11.2", + "version": "0.12.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -568,6 +568,16 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, + "assert": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", + "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", + "dev": true, + "requires": { + "object-assign": "^4.1.1", + "util": "0.10.3" + } + }, "astral-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", @@ -605,6 +615,16 @@ "fill-range": "^7.0.1" } }, + "call-bind": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.0.tgz", + "integrity": "sha512-AEXsYIyyDY3MCzbwdhzG3Jx1R0J2wetQyUynn6dYHAO+bg8l1k7jwZtRv4ryryFs7EP+NDlikJlVe59jr0cM2w==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.0" + } + }, "callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -854,6 +874,15 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, "dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -914,6 +943,37 @@ "is-arrayish": "^0.2.1" } }, + "es-abstract": { + "version": "1.18.0-next.1", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.1.tgz", + "integrity": "sha512-I4UGspA0wpZXWENrdA0uHbnhte683t3qT/1VFH9aX2dA5PPSf6QW5HHXf5HImaqPmjXaVeVk4RGWnaylmV7uAA==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.2", + "is-negative-zero": "^2.0.0", + "is-regex": "^1.1.1", + "object-inspect": "^1.8.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.1", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -1263,12 +1323,32 @@ "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "dev": true }, + "gen-esm-wrapper": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/gen-esm-wrapper/-/gen-esm-wrapper-1.1.1.tgz", + "integrity": "sha512-/ZMuX3itPtnjjWuIArzBi6mDnkGVcsx8guLCeH3WLB+iLeFr8TOKhIrNaYmPuRtQcpeBKrlswCPAY9oLRKIxKw==", + "dev": true, + "requires": { + "is-valid-identifier": "^2.0.2" + } + }, "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, + "get-intrinsic": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.0.2.tgz", + "integrity": "sha512-aeX0vrFm21ILl3+JpFFRNe9aUvp6VFZb2/CTbgLb8j75kOhvoNYjt9d8KA/tJG4gSo8nzEDedRl0h7vDmBYRVg==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + } + }, "get-own-enumerable-property-symbols": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz", @@ -1393,6 +1473,12 @@ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, "hosted-git-info": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-3.0.7.tgz", @@ -1490,6 +1576,12 @@ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, + "is-callable": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.2.tgz", + "integrity": "sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA==", + "dev": true + }, "is-core-module": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz", @@ -1499,6 +1591,12 @@ "has": "^1.0.3" } }, + "is-date-object": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", + "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", + "dev": true + }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -1520,6 +1618,12 @@ "is-extglob": "^2.1.1" } }, + "is-negative-zero": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.1.tgz", + "integrity": "sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w==", + "dev": true + }, "is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -1538,6 +1642,15 @@ "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", "dev": true }, + "is-regex": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", + "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + }, "is-regexp": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", @@ -1550,6 +1663,15 @@ "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==", "dev": true }, + "is-symbol": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", + "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + }, "is-text-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-1.0.1.tgz", @@ -1559,6 +1681,15 @@ "text-extensions": "^1.0.0" } }, + "is-valid-identifier": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-valid-identifier/-/is-valid-identifier-2.0.2.tgz", + "integrity": "sha512-mpS5EGqXOwzXtKAg6I44jIAqeBfntFLxpAth1rrKbxtKyI6LPktyDYpHBI+tHlduhhX/SF26mFXmxQu995QVqg==", + "dev": true, + "requires": { + "assert": "^1.4.1" + } + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -1587,6 +1718,12 @@ "esprima": "^4.0.0" } }, + "json-parse-better-errors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", + "dev": true + }, "json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", @@ -1690,6 +1827,30 @@ "through": "^2.3.8" } }, + "load-json-file": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", + "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^4.0.0", + "pify": "^3.0.0", + "strip-bom": "^3.0.0" + }, + "dependencies": { + "parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "dev": true, + "requires": { + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" + } + } + } + }, "locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -1785,6 +1946,12 @@ "integrity": "sha512-glc9y00wgtwcDmp7GaE/0b0OnxpNJsVf3ael/An6Fe2Q51LLwN1er6sdomLRzz5h0+yMpiYLhWYF5R7HeqVd4g==", "dev": true }, + "memorystream": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz", + "integrity": "sha1-htcJCzDORV1j+64S3aUaR93K+bI=", + "dev": true + }, "meow": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/meow/-/meow-8.0.0.tgz", @@ -1870,6 +2037,12 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, "normalize-package-data": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.0.tgz", @@ -1888,6 +2061,162 @@ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "dev": true }, + "npm-run-all": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/npm-run-all/-/npm-run-all-4.1.5.tgz", + "integrity": "sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "chalk": "^2.4.1", + "cross-spawn": "^6.0.5", + "memorystream": "^0.3.1", + "minimatch": "^3.0.4", + "pidtree": "^0.3.0", + "read-pkg": "^3.0.0", + "shell-quote": "^1.6.1", + "string.prototype.padend": "^3.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "hosted-git-info": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "dev": true + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, + "path-type": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "dev": true, + "requires": { + "pify": "^3.0.0" + } + }, + "read-pkg": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", + "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", + "dev": true, + "requires": { + "load-json-file": "^4.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^3.0.0" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, "npm-run-path": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", @@ -1897,6 +2226,36 @@ "path-key": "^3.0.0" } }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "object-inspect": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.9.0.tgz", + "integrity": "sha512-i3Bp9iTqwhaLZBxGkRfo5ZbE07BQRT7MGu8+nNgwW9ItGp1TzCTw2DLEoWwjClxBjOFI/hWljTAmYGCEwmtnOw==", + "dev": true + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, + "object.assign": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", + "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "has-symbols": "^1.0.1", + "object-keys": "^1.1.1" + } + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -2025,6 +2384,18 @@ "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", "dev": true }, + "pidtree": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.3.1.tgz", + "integrity": "sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA==", + "dev": true + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + }, "pkg-dir": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", @@ -2326,6 +2697,12 @@ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, + "shell-quote": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz", + "integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==", + "dev": true + }, "signal-exit": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", @@ -2457,6 +2834,37 @@ "strip-ansi": "^6.0.0" } }, + "string.prototype.padend": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.padend/-/string.prototype.padend-3.1.1.tgz", + "integrity": "sha512-eCzTASPnoCr5Ht+Vn1YXgm8SB015hHKgEIMu9Nr9bQmLhRBxKRfmzSj/IQsxDFc8JInJDDFA0qXwK+xxI7wDkg==", + "dev": true, + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "es-abstract": "^1.18.0-next.1" + } + }, + "string.prototype.trimend": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.3.tgz", + "integrity": "sha512-ayH0pB+uf0U28CtjlLvL7NaohvR1amUvVZk+y3DYb0Ey2PUV5zPkkKy9+U1ndVEIXO8hNg18eIv9Jntbii+dKw==", + "dev": true, + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3" + } + }, + "string.prototype.trimstart": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.3.tgz", + "integrity": "sha512-oBIBUy5lea5tt0ovtOFiEQaBkoBBkyJhZXzJYrSmDo5IUUqbOPvVezuRs/agBIdZ2p2Eo1FD6bD9USyBLfl3xg==", + "dev": true, + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3" + } + }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -2494,6 +2902,12 @@ "ansi-regex": "^5.0.0" } }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, "strip-final-newline": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", @@ -2688,6 +3102,23 @@ "punycode": "^2.1.0" } }, + "util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "dev": true, + "requires": { + "inherits": "2.0.1" + }, + "dependencies": { + "inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", + "dev": true + } + } + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/package.json b/package.json index f058090d..fcfcd4e8 100644 --- a/package.json +++ b/package.json @@ -1,94 +1,128 @@ { - "name": "discord-api-types", - "version": "0.11.2", - "description": "Discord API typings that are kept up to date for use in bot library creation.", - "main": "default/index.js", - "scripts": { - "prepublishOnly": "npm run clean && npm run test:lint && npm run build", - "build": "tsc", - "test:lint": "eslint --ext ts {v*,default,common}/**", - "lint": "eslint --fix --ext ts {v*,default,common}/**", - "clean": "npx rimraf {v*,default,common}/**/*.{js,d.ts,map}" - }, - "keywords": [ - "discord", - "discord api", - "types", - "discordjs" - ], - "author": "Vlad Frangu ", - "license": "MIT", - "files": [ - "v*/*", - "default/*", - "common/*", - "!**/*.ts", - "**/*.d.ts" - ], - "engines": { - "node": ">=12" - }, - "devDependencies": { - "@commitlint/cli": "^11.0.0", - "@commitlint/config-angular": "^11.0.0", - "@typescript-eslint/eslint-plugin": "^4.10.0", - "@typescript-eslint/parser": "^4.10.0", - "eslint": "^7.15.0", - "eslint-config-marine": "^7.2.0", - "eslint-config-prettier": "^7.0.0", - "eslint-plugin-prettier": "^3.3.0", - "husky": "^4.3.6", - "lint-staged": "^10.5.3", - "prettier": "^2.2.1", - "typescript": "^4.1.3" - }, - "repository": { - "type": "git", - "url": "https://github.com/discordjs/discord-api-types" - }, - "eslintConfig": { - "extends": "marine/prettier/node", - "parserOptions": { - "project": "./tsconfig.json" - }, - "rules": { - "@typescript-eslint/naming-convention": 0 - } - }, - "husky": { - "hooks": { - "pre-commit": "lint-staged", - "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" - } - }, - "lint-staged": { - "*.js": "eslint --fix", - "*.ts": "eslint --fix --ext ts" - }, - "commitlint": { - "extends": [ - "@commitlint/config-angular" - ], - "rules": { - "type-enum": [ - 2, - "always", - [ - "chore", - "build", - "ci", - "docs", - "feat", - "fix", - "perf", - "refactor", - "revert", - "style", - "test", - "types", - "wip" - ] - ] - } - } + "name": "discord-api-types", + "version": "0.12.0", + "description": "Discord API typings that are kept up to date for use in bot library creation.", + "main": "./default/index.js", + "types": "./default/index.d.ts", + "exports": { + ".": { + "require": "./default/index.js", + "import": "./default/index.mjs" + }, + "./v6": { + "require": "./v6/index.js", + "import": "./v6/index.mjs" + }, + "./v8": { + "require": "./v8/index.js", + "import": "./v8/index.mjs" + } + }, + "scripts": { + "prepublishOnly": "run-s clean test:lint build:node", + "postpublish": "run-s clean:node build:deno", + "build:deno": "node ./scripts/deno.mjs", + "build:node": "tsc && run-p esm:*", + "esm:common": "gen-esm-wrapper ./common/index.js ./common/index.mjs", + "esm:default": "gen-esm-wrapper ./default/index.js ./default/index.mjs", + "esm:v6": "gen-esm-wrapper ./v6/index.js ./v6/index.mjs", + "esm:v8": "gen-esm-wrapper ./v8/index.js ./v8/index.mjs", + "lint": "eslint --fix --ext mjs,js,ts {v*,default,common}/**", + "test:lint": "eslint --ext mjs,js,ts {v*,default,common}/**", + "clean": "run-p clean:*", + "clean:node": "rimraf {v*,default,common}/**/*.{js,mjs,d.ts,map}", + "clean:deno": "rimraf .deno/" + }, + "keywords": [ + "discord", + "discord api", + "types", + "discordjs" + ], + "author": "Vlad Frangu ", + "license": "MIT", + "files": [ + "v*/*", + "default/*", + "common/*", + "!**/*.ts", + "**/*.d.ts", + "!\\.deno/*" + ], + "engines": { + "node": ">=12" + }, + "devDependencies": { + "@commitlint/cli": "^11.0.0", + "@commitlint/config-angular": "^11.0.0", + "@typescript-eslint/eslint-plugin": "^4.10.0", + "@typescript-eslint/parser": "^4.10.0", + "eslint": "^7.15.0", + "eslint-config-marine": "^7.2.0", + "eslint-config-prettier": "^7.0.0", + "eslint-plugin-prettier": "^3.3.0", + "gen-esm-wrapper": "^1.1.1", + "husky": "^4.3.6", + "lint-staged": "^10.5.3", + "npm-run-all": "^4.1.5", + "prettier": "^2.2.1", + "rimraf": "^3.0.2", + "typescript": "^4.1.3" + }, + "repository": { + "type": "git", + "url": "https://github.com/discordjs/discord-api-types" + }, + "eslintConfig": { + "extends": "marine/prettier/node", + "parserOptions": { + "project": "./tsconfig.eslint.json", + "extraFileExtensions": [ + ".mjs" + ] + }, + "rules": { + "@typescript-eslint/naming-convention": 0 + } + }, + "husky": { + "hooks": { + "pre-commit": "lint-staged", + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" + } + }, + "lint-staged": { + "*.{mjs,js,ts}": "eslint --fix --ext mjs,js,ts" + }, + "commitlint": { + "extends": [ + "@commitlint/config-angular" + ], + "rules": { + "type-enum": [ + 2, + "always", + [ + "chore", + "build", + "ci", + "docs", + "feat", + "fix", + "perf", + "refactor", + "revert", + "style", + "test", + "types", + "wip" + ] + ], + "scope-case": [ + 1, + "always", + "pascal-case" + ] + } + } } diff --git a/scripts/deno.mjs b/scripts/deno.mjs new file mode 100644 index 00000000..9c5886e4 --- /dev/null +++ b/scripts/deno.mjs @@ -0,0 +1,92 @@ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +import { + copyFile, // + mkdir, + opendir, + readFile, + rm, + writeFile, +} from 'fs/promises'; + +const baseDirectory = new URL('../', import.meta.url); +const denoPath = new URL('.deno/', baseDirectory); + +// Remove existing deno built files +try { + await rm(denoPath, { recursive: true }); +} catch {} + +// Create .deno folder +await mkdir(denoPath); + +/** + * @param {string} source The raw source + */ +function convertImports(source) { + return source.replace( + /from '(.*)'/g, + /** + * @param {string} importPath The path to import from + */ (_, importPath) => { + if (importPath === '..' || importPath === '../') importPath = '../mod.ts'; + if (importPath.includes('index')) importPath = importPath.replace('index', 'mod'); + if (!importPath.endsWith('.ts')) importPath += '.ts'; + + return `from '${importPath}'`; + }, + ); +} + +/** + * @param {string} folderName The folder name + * @param {URL} node The node path + * @param {URL} deno The deno path + */ +async function adaptFolderToDeno(folderName, node = baseDirectory, deno = denoPath) { + const nodeDirectory = new URL(folderName, node); + const denoDirectory = new URL(folderName, deno); + + await mkdir(denoDirectory, { recursive: true }); + + for await (const file of await opendir(nodeDirectory)) { + if (file.isDirectory()) { + await adaptFolderToDeno(`${file.name}/`, new URL(folderName, node), new URL(folderName, deno)); + continue; + } + + if (!file.name.endsWith('.ts')) continue; + + const fullFilePath = new URL(file.name, nodeDirectory); + const finalDenoPath = new URL(file.name.includes('index') ? 'mod.ts' : file.name, denoDirectory); + + const originalFile = await readFile(fullFilePath, { encoding: 'utf8' }); + + await writeFile(finalDenoPath, convertImports(originalFile)); + } +} + +async function createModTS() { + const defaultFile = await readFile(new URL('./default/index.ts', baseDirectory), { encoding: 'utf8' }); + + const converted = convertImports(defaultFile).replace('../v', './v'); + + await writeFile(new URL('mod.ts', denoPath), converted); +} + +// Create mod.ts which is the default/index.ts +await createModTS(); + +await Promise.all( + [ + 'common/', // + 'v6/', + 'v8/', + ].map((item) => adaptFolderToDeno(item)), +); + +await Promise.all( + [ + 'LICENSE', // + 'README.md', + ].map((item) => copyFile(new URL(item, baseDirectory), new URL(item, denoPath))), +); diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json new file mode 100644 index 00000000..5100a25d --- /dev/null +++ b/tsconfig.eslint.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "allowJs": true, + "checkJs": true + }, + "include": ["common", "default", "v6", "v8", "scripts"] +} diff --git a/tsconfig.json b/tsconfig.json index 365f64a3..7c259e86 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,15 +15,5 @@ "strictNullChecks": true, "preserveConstEnums": true }, - "exclude": [ - "node_modules", - "bin", - "examples", - "scripts" - ], - "include": [ - "v*/**/*", - "default/**/*", - "common/**/*", - ] + "include": ["v*/**/*", "default/**/*", "common/**/*"] } diff --git a/v6/gateway/index.ts b/v6/gateway/index.ts index d7341bd2..4d809fcf 100644 --- a/v6/gateway/index.ts +++ b/v6/gateway/index.ts @@ -16,7 +16,7 @@ import type { GatewayVoiceState, InviteTargetUserType, PresenceUpdateStatus, -} from '../payloads'; +} from '../payloads/index'; /** * @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8. diff --git a/v6/index.ts b/v6/index.ts index 03aa2c8b..fa07576b 100644 --- a/v6/index.ts +++ b/v6/index.ts @@ -1,4 +1,4 @@ -export * from '../common'; -export * from './gateway'; -export * from './payloads'; -export * from './rest'; +export * from '../common/index'; +export * from './gateway/index'; +export * from './payloads/index'; +export * from './rest/index'; diff --git a/v6/rest/channel.ts b/v6/rest/channel.ts index ebd153f1..f3783ad5 100644 --- a/v6/rest/channel.ts +++ b/v6/rest/channel.ts @@ -11,7 +11,7 @@ import type { InviteTargetUserType, MessageFlags, OverwriteType, -} from '../payloads'; +} from '../payloads/index'; // #region TypeDefs diff --git a/v6/rest/emoji.ts b/v6/rest/emoji.ts index 8e825b53..8f1bb2c8 100644 --- a/v6/rest/emoji.ts +++ b/v6/rest/emoji.ts @@ -1,4 +1,4 @@ -import type { APIEmoji } from '../payloads'; +import type { APIEmoji } from '../payloads/index'; /** * https://discord.com/developers/docs/resources/emoji#list-guild-emojis diff --git a/v6/rest/gateway.ts b/v6/rest/gateway.ts index c7704dbe..6cf2aba8 100644 --- a/v6/rest/gateway.ts +++ b/v6/rest/gateway.ts @@ -1,4 +1,4 @@ -import type { APIGatewayBotInfo, APIGatewayInfo } from '../payloads'; +import type { APIGatewayBotInfo, APIGatewayInfo } from '../payloads/index'; /** * https://discord.com/developers/docs/topics/gateway#get-gateway diff --git a/v6/rest/guild.ts b/v6/rest/guild.ts index 53aa363e..d6b0f8a1 100644 --- a/v6/rest/guild.ts +++ b/v6/rest/guild.ts @@ -15,7 +15,7 @@ import type { GuildVerificationLevel, GuildWidgetStyle, IntegrationExpireBehavior, -} from '../payloads'; +} from '../payloads/index'; import type { RESTPutAPIChannelPermissionsJSONBody } from './channel'; /** diff --git a/v6/rest/invite.ts b/v6/rest/invite.ts index 06bee3a8..658f6d33 100644 --- a/v6/rest/invite.ts +++ b/v6/rest/invite.ts @@ -1,4 +1,4 @@ -import type { APIInvite } from '../payloads'; +import type { APIInvite } from '../payloads/index'; /** * https://discord.com/developers/docs/resources/invite#get-invite diff --git a/v6/rest/oauth2.ts b/v6/rest/oauth2.ts index d3ed608c..13a9ca13 100644 --- a/v6/rest/oauth2.ts +++ b/v6/rest/oauth2.ts @@ -1,4 +1,4 @@ -import type { APIApplication, APIGuild, APIWebhook } from '../payloads'; +import type { APIApplication, APIGuild, APIWebhook } from '../payloads/index'; /** * https://discord.com/developers/docs/topics/oauth2#get-current-application-information diff --git a/v6/rest/user.ts b/v6/rest/user.ts index c47ce563..19b716c1 100644 --- a/v6/rest/user.ts +++ b/v6/rest/user.ts @@ -1,4 +1,4 @@ -import type { APIChannel, APIConnection, APIUser, GuildFeature } from '../payloads'; +import type { APIChannel, APIConnection, APIUser, GuildFeature } from '../payloads/index'; /** * https://discord.com/developers/docs/resources/user#get-current-user diff --git a/v6/rest/voice.ts b/v6/rest/voice.ts index 24b75365..f0201adb 100644 --- a/v6/rest/voice.ts +++ b/v6/rest/voice.ts @@ -1,4 +1,4 @@ -import type { APIVoiceRegion } from '../payloads'; +import type { APIVoiceRegion } from '../payloads/index'; /** * https://discord.com/developers/docs/resources/voice#list-voice-regions diff --git a/v6/rest/webhook.ts b/v6/rest/webhook.ts index 27be2dbf..e96a3a7f 100644 --- a/v6/rest/webhook.ts +++ b/v6/rest/webhook.ts @@ -1,5 +1,5 @@ import type { APIAllowedMentionsSend } from './channel'; -import type { APIEmbed, APIMessage, APIWebhook } from '../payloads'; +import type { APIEmbed, APIMessage, APIWebhook } from '../payloads/index'; /** * https://discord.com/developers/docs/resources/webhook#create-webhook diff --git a/v8/gateway/index.ts b/v8/gateway/index.ts index e7de8197..fcb18f93 100644 --- a/v8/gateway/index.ts +++ b/v8/gateway/index.ts @@ -18,7 +18,7 @@ import type { PresenceUpdateStatus, APIApplicationCommandInteraction, APIApplication, -} from '../payloads'; +} from '../payloads/index'; export const GatewayVersion = '8'; @@ -26,17 +26,49 @@ export const GatewayVersion = '8'; * https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes */ export const enum GatewayOPCodes { + /** + * An event was dispatched + */ Dispatch, + /** + * Fired periodically by the client to keep the connection alive + */ Heartbeat, + /** + * Starts a new session during the initial handshake + */ Identify, + /** + * Update the client's presence + */ PresenceUpdate, + /** + * Used to join/leave or move between voice channels + */ VoiceStateUpdate, - + /** + * Resume a previous session that was disconnected + */ Resume = 6, + /** + * You should attempt to reconnect and resume immediately + */ Reconnect, + /** + * Request information about offline guild members in a large guild + */ RequestGuildMembers, + /** + * The session has been invalidated. You should reconnect and identify/resume accordingly + */ InvalidSession, + /** + * Sent immediately after connecting, contains the `heartbeat_interval` to use + */ Hello, + /** + * Sent in response to receiving a heartbeat to acknowledge that it has been received + */ HeartbeatAck, } @@ -44,20 +76,82 @@ export const enum GatewayOPCodes { * https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes */ export const enum GatewayCloseCodes { + /** + * We're not sure what went wrong. Try reconnecting? + */ UnknownError = 4000, + /** + * You sent an invalid Gateway opcode or an invalid payload for an opcode. Don't do that! + * + * See https://discord.com/developers/docs/topics/gateway#payloads-and-opcodes + */ UnknownOpCode, + /** + * You sent an invalid payload to us. Don't do that! + * + * See https://discord.com/developers/docs/topics/gateway#sending-payloads + */ DecodeError, + /** + * You sent us a payload prior to identifying + * + * See https://discord.com/developers/docs/topics/gateway#identify + */ NotAuthenticated, + /** + * The account token sent with your identify payload is incorrect + * + * See https://discord.com/developers/docs/topics/gateway#identify + */ AuthenticationFailed, + /** + * You sent more than one identify payload. Don't do that! + */ AlreadyAuthenticated, - + /** + * The sequence sent when resuming the session was invalid. Reconnect and start a new session + * + * See https://discord.com/developers/docs/topics/gateway#resume + */ InvalidSeq = 4007, + /** + * Woah nelly! You're sending payloads to us too quickly. Slow it down! You will be disconnected on receiving this + */ RateLimited, + /** + * Your session timed out. Reconnect and start a new one + */ SessionTimedOut, + /** + * You sent us an invalid shard when identifying + * + * See https://discord.com/developers/docs/topics/gateway#sharding + */ InvalidShard, + /** + * The session would have handled too many guilds - you are required to shard your connection in order to connect + * + * See https://discord.com/developers/docs/topics/gateway#sharding + */ ShardingRequired, + /** + * You sent an invalid version for the gateway + */ InvalidAPIVersion, + /** + * You sent an invalid intent for a Gateway Intent. You may have incorrectly calculated the bitwise value + * + * See https://discord.com/developers/docs/topics/gateway#gateway-intents + */ InvalidIntents, + /** + * You sent a disallowed intent for a Gateway Intent. You may have tried to specify an intent that you have not + * enabled or are not whitelisted for + * + * See https://discord.com/developers/docs/topics/gateway#gateway-intents + * + * See https://discord.com/developers/docs/topics/gateway#privileged-intents + */ DisallowedIntents, } @@ -65,18 +159,53 @@ export const enum GatewayCloseCodes { * https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-opcodes */ export const enum VoiceOPCodes { + /** + * Begin a voice websocket connection + */ Identify, + /** + * Select the voice protocol + */ SelectProtocol, + /** + * Complete the websocket handshake + */ Ready, + /** + * Keep the websocket connection alive + */ Heartbeat, + /** + * Describe the session + */ SessionDescription, + /** + * Indicate which users are speaking + */ Speaking, + /** + * Sent to acknowledge a received client heartbeat + */ HeartbeatAck, + /** + * Resume a connection + */ Resume, + /** + * Time to wait between sending heartbeats in milliseconds + */ Hello, + /** + * Acknowledge a successful session resume + */ Resumed, - + /** + * A client has connected to the voice channel + */ ClientConnect = 12, + /** + * A client has disconnected from the voice channel + */ ClientDisconnect, } @@ -84,20 +213,53 @@ export const enum VoiceOPCodes { * https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes */ export const enum VoiceCloseCodes { + /** + * You sent an invalid opcode + */ UnknownOpCode = 4001, - - NotAuthenticated = 4003, + /** + * You sent a invalid payload in your identifying to the Gateway + */ + FailedToDecode, + /** + * You sent a payload before identifying with the Gateway + */ + NotAuthenticated, + /** + * The token you sent in your identify payload is incorrect + */ AuthenticationFailed, + /** + * You sent more than one identify payload. Stahp + */ AlreadyAuthenticated, + /** + * Your session is no longer valid + */ SessionNoLongerValid, - + /** + * Your session has timed out + */ SessionTimeout = 4009, - + /** + * We can't find the server you're trying to connect to + */ ServerNotFound = 4011, + /** + * We didn't recognize the protocol you sent + */ UnknownProtocol, - + /** + * Either the channel was deleted or you were kicked. Should not reconnect + */ Disconnected = 4014, + /** + * The server crashed. Our bad! Try resuming + */ VoiceServerCrashed, + /** + * We didn't recognize your encryption + */ UnknownEncryptionMode, } @@ -229,6 +391,9 @@ export interface GatewayHello extends NonDispatchPayload { * https://discord.com/developers/docs/topics/gateway#hello */ export interface GatewayHelloData { + /** + * The interval (in milliseconds) the client should heartbeat with + */ heartbeat_interval: number; } @@ -278,12 +443,43 @@ export type GatewayReadyDispatch = DataPayload; } @@ -309,13 +505,34 @@ export type GatewayChannelModifyDispatch = DataPayload< */ export type GatewayChannelModifyDispatchData = APIChannel; +/** + * https://discord.com/developers/docs/topics/gateway#channel-create + */ export type GatewayChannelCreateDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-create + */ export type GatewayChannelCreateDispatchData = GatewayChannelModifyDispatchData; +/** + * https://discord.com/developers/docs/topics/gateway#channel-update + */ export type GatewayChannelUpdateDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-update + */ export type GatewayChannelUpdateDispatchData = GatewayChannelModifyDispatchData; +/** + * https://discord.com/developers/docs/topics/gateway#channel-delete + */ export type GatewayChannelDeleteDispatch = GatewayChannelModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#channel-delete + */ export type GatewayChannelDeleteDispatchData = GatewayChannelModifyDispatchData; /** @@ -330,8 +547,17 @@ export type GatewayChannelPinsUpdateDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#channel-pins-update */ export interface GatewayChannelPinsUpdateDispatchData { + /** + * The id of the guild + */ guild_id?: string; + /** + * The id of the channel + */ channel_id: string; + /** + * The time at which the most recent pinned message was pinned + */ last_pin_timestamp?: string | null; } @@ -350,10 +576,24 @@ export type GatewayGuildModifyDispatch = DataPayload< */ export type GatewayGuildModifyDispatchData = APIGuild; +/** + * https://discord.com/developers/docs/topics/gateway#guild-create + */ export type GatewayGuildCreateDispatch = GatewayGuildModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-create + */ export type GatewayGuildCreateDispatchData = GatewayGuildModifyDispatchData; +/** + * https://discord.com/developers/docs/topics/gateway#guild-update + */ export type GatewayGuildUpdateDispatch = GatewayGuildModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-update + */ export type GatewayGuildUpdateDispatchData = GatewayGuildModifyDispatchData; /** @@ -380,14 +620,36 @@ export type GatewayGuildBanModifyDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#guild-ban-remove */ export interface GatewayGuildBanModifyDispatchData { + /** + * ID of the guild + */ guild_id: string; + /** + * The banned user + * + * See https://discord.com/developers/docs/resources/user#user-object + */ user: APIUser; } +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-add + */ export type GatewayGuildBanAddDispatch = GatewayGuildBanModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-add + */ export type GatewayGuildBanAddDispatchData = GatewayGuildBanModifyDispatchData; +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + */ export type GatewayGuildBanRemoveDispatch = GatewayGuildBanModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-ban-remove + */ export type GatewayGuildBanRemoveDispatchData = GatewayGuildBanModifyDispatchData; /** @@ -402,7 +664,15 @@ export type GatewayGuildEmojisUpdateDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#guild-emojis-update */ export interface GatewayGuildEmojisUpdateDispatchData { + /** + * ID of the guild + */ guild_id: string; + /** + * Array of emojis + * + * See https://discord.com/developers/docs/resources/emoji#emoji-object + */ emojis: APIEmoji[]; } @@ -418,6 +688,9 @@ export type GatewayGuildIntegrationsUpdateDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#guild-integrations-update */ export interface GatewayGuildIntegrationsUpdateDispatchData { + /** + * ID of the guild whose integrations were updated + */ guild_id: string; } @@ -433,6 +706,9 @@ export type GatewayGuildMemberAddDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#guild-member-add */ export interface GatewayGuildMemberAddDispatchData extends APIGuildMember { + /** + * The id of the guild + */ guild_id: string; } @@ -448,7 +724,15 @@ export type GatewayGuildMemberRemoveDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#guild-member-remove */ export interface GatewayGuildMemberRemoveDispatchData { + /** + * The id of the guild + */ guild_id: string; + /** + * The user who was removed + * + * See https://discord.com/developers/docs/resources/user#user-object + */ user: APIUser; } @@ -464,6 +748,9 @@ export type GatewayGuildMemberUpdateDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#guild-member-update */ export type GatewayGuildMemberUpdateDispatchData = Omit & { + /** + * The id of the guild + */ guild_id: string; }; @@ -479,12 +766,39 @@ export type GatewayGuildMembersChunkDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#guild-members-chunk */ export interface GatewayGuildMembersChunkDispatchData { + /** + * The id of the guild + */ guild_id: string; + /** + * Set of guild members + * + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ members: APIGuildMember[]; + /** + * The chunk index in the expected chunks for this response (`0 <= chunk_index < chunk_count`) + */ chunk_index?: number; + /** + * The total number of expected chunks for this response + */ chunk_count?: number; + /** + * If passing an invalid id to `REQUEST_GUILD_MEMBERS`, it will be returned here + */ not_found?: unknown[]; + /** + * If passing true to `REQUEST_GUILD_MEMBERS`, presences of the returned members will be here + * + * See https://discord.com/developers/docs/topics/gateway#presence + */ presences?: RawGatewayPresenceUpdate[]; + /** + * The nonce used in the Guild Members Request + * + * See https://discord.com/developers/docs/topics/gateway#request-guild-members + */ nonce?: string; } @@ -502,14 +816,36 @@ export type GatewayGuildRoleModifyDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#guild-role-update */ export interface GatewayGuildRoleModifyDispatchData { + /** + * The id of the guild + */ guild_id: string; + /** + * The role created or updated + * + * See https://discord.com/developers/docs/topics/permissions#role-object + */ role: APIRole; } +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-create + */ export type GatewayGuildRoleCreateDispatch = GatewayGuildRoleModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-create + */ export type GatewayGuildRoleCreateDispatchData = GatewayGuildRoleModifyDispatchData; +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-update + */ export type GatewayGuildRoleUpdateDispatch = GatewayGuildRoleModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-role-update + */ export type GatewayGuildRoleUpdateDispatchData = GatewayGuildRoleModifyDispatchData; /** @@ -524,7 +860,13 @@ export type GatewayGuildRoleDeleteDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#guild-role-delete */ export interface GatewayGuildRoleDeleteDispatchData { + /** + * The id of the guild + */ guild_id: string; + /** + * The id of the role + */ role_id: string; } @@ -553,16 +895,57 @@ export type GatewayInviteCreateDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#invite-create */ export interface GatewayInviteCreateDispatchData { + /** + * The channel the invite is for + */ channel_id: string; + /** + * 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?: string; + /** + * 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 target user for this invite + * + * See https://discord.com/developers/docs/resources/user#user-object + */ target_user?: APIUser; + /** + * The type of user target for this invite + * + * See https://discord.com/developers/docs/resources/invite#invite-object-target-user-types + */ target_user_type?: InviteTargetUserType; + /** + * 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; } @@ -578,8 +961,19 @@ export type GatewayInviteDeleteDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#invite-delete */ export interface GatewayInviteDeleteDispatchData { + /** + * The channel of the invite + */ channel_id: string; + /** + * The guild of the invite + */ guild_id?: string; + /** + * The unique invite code + * + * See https://discord.com/developers/docs/resources/invite#invite-object + */ code: string; } @@ -624,8 +1018,17 @@ export type GatewayMessageDeleteDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#message-delete */ export interface GatewayMessageDeleteDispatchData { + /** + * The id of the message + */ id: string; + /** + * The id of the channel + */ channel_id: string; + /** + * The id of the guild + */ guild_id?: string; } @@ -641,8 +1044,17 @@ export type GatewayMessageDeleteBulkDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#message-delete-bulk */ export interface GatewayMessageDeleteBulkDispatchData { + /** + * The ids of the messages + */ ids: string[]; + /** + * The id of the channel + */ channel_id: string; + /** + * The id of the guild + */ guild_id?: string; } @@ -691,6 +1103,9 @@ export type GatewayMessageReactionRemoveEmojiDispatch = DataPayload< * https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji */ export interface GatewayMessageReactionRemoveEmojiDispatchData extends MessageReactionRemoveData { + /** + * The emoji that was removed + */ emoji: APIEmoji; } @@ -716,10 +1131,27 @@ export type GatewayTypingStartDispatch = DataPayload = D E, Omit< { + /** + * The id of the user + */ user_id: string; + /** + * The id of the channel + */ channel_id: string; + /** + * The id of the message + */ message_id: string; + /** + * The id of the guild + */ guild_id?: string; + /** + * The member who reacted if this happened in a guild + * + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ member?: APIGuildMember; + /** + * The emoji used to react + * + * See https://discord.com/developers/docs/resources/emoji#emoji-object + */ emoji: APIEmoji; }, O @@ -940,8 +1527,17 @@ type ReactionData = D >; interface MessageReactionRemoveData { + /** + * The id of the channel + */ channel_id: string; + /** + * The id of the message + */ message_id: string; + /** + * The id of the guild + */ guild_id?: string; } // #endregion Shared diff --git a/v8/index.ts b/v8/index.ts index 03aa2c8b..fa07576b 100644 --- a/v8/index.ts +++ b/v8/index.ts @@ -1,4 +1,4 @@ -export * from '../common'; -export * from './gateway'; -export * from './payloads'; -export * from './rest'; +export * from '../common/index'; +export * from './gateway/index'; +export * from './payloads/index'; +export * from './rest/index'; diff --git a/v8/payloads/auditLog.ts b/v8/payloads/auditLog.ts index 944f20a7..76b942f7 100644 --- a/v8/payloads/auditLog.ts +++ b/v8/payloads/auditLog.ts @@ -19,9 +19,29 @@ import type { APIWebhook } from './webhook'; * https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure */ export interface APIAuditLog { + /** + * Webhooks found in the audit log + * + * See https://discord.com/developers/docs/resources/webhook#webhook-object + */ webhooks: APIWebhook[]; + /** + * Users found in the audit log + * + * See https://discord.com/developers/docs/resources/user#user-object + */ users: APIUser[]; + /** + * Audit log entries + * + * See https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object + */ audit_log_entries: APIAuditLogEntry[]; + /** + * Partial integration objects + * + * See https://discord.com/developers/docs/resources/guild#integration-object + */ integrations: APIGuildIntegration[]; } @@ -29,12 +49,42 @@ export interface APIAuditLog { * 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[]; - user_id: string; + /** + * The user who made the changes + * + * *Against all odds, this can be `null` in some cases (webhooks deleting themselves + * by using their own token, for example)* + */ + user_id: string | null; + /** + * ID of the entry + */ id: string; + /** + * 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; } @@ -92,17 +142,23 @@ export const enum AuditLogEvent { */ export interface APIAuditLogOptions { /** + * Number of days after which inactive members were kicked + * * Present from: * - MEMBER_PRUNE */ delete_member_days?: string; /** + * Number of members removed by the prune + * * Present from: * - MEMBER_PRUNE */ members_removed?: string; /** + * Channel in which the entities were targeted + * * Present from: * - MEMBER_MOVE * - MESSAGE_PIN @@ -112,6 +168,8 @@ export interface APIAuditLogOptions { channel_id?: string; /** + * ID of the message that was targeted + * * Present from: * - MESSAGE_PIN * - MESSAGE_UNPIN @@ -119,6 +177,8 @@ export interface APIAuditLogOptions { message_id?: string; /** + * Number of entities that were targeted + * * Present from: * - MESSAGE_DELETE * - MESSAGE_BULK_DELETE @@ -128,6 +188,8 @@ export interface APIAuditLogOptions { count?: string; /** + * ID of the overwritten entity + * * Present from: * - CHANNEL_OVERWRITE_CREATE * - CHANNEL_OVERWRITE_UPDATE @@ -136,20 +198,26 @@ export interface APIAuditLogOptions { id?: string; /** - * Present from: - * - CHANNEL_OVERWRITE_CREATE - * - CHANNEL_OVERWRITE_UPDATE - * - CHANNEL_OVERWRITE_DELETE - */ - type: AuditLogOptionsType; - - /** + * Type of overwritten entity - "0" for "role" or "1" for "member" + * * Present from: * - CHANNEL_OVERWRITE_CREATE * - CHANNEL_OVERWRITE_UPDATE * - CHANNEL_OVERWRITE_DELETE * - * **Present only if the {@link APIAuditLogOptions#type entry type} is "role"** + * {@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; } @@ -431,11 +499,7 @@ export type APIAuditLogChangeKeyAvatarHash = AuditLogChangeData<'avatar_hash', s /** * The ID of the changed entity - sometimes used in conjunction with other keys */ -export interface APIAuditLogChangeKeyID { - key: 'id'; - new_value: string; - old_value?: string; -} +export type APIAuditLogChangeKeyID = AuditLogChangeData<'id', string>; /** * The type of entity created diff --git a/v8/payloads/channel.ts b/v8/payloads/channel.ts index e5ba4cff..c6f67037 100644 --- a/v8/payloads/channel.ts +++ b/v8/payloads/channel.ts @@ -10,8 +10,19 @@ import type { APIUser } from './user'; * Not documented, but partial only includes id, name, and type */ export interface APIPartialChannel { + /** + * The id of the channel + */ id: string; + /** + * The type of the channel + * + * See https://discord.com/developers/docs/resources/channel#channel-object-channel-types + */ type: ChannelType; + /** + * The name of the channel (2-100 characters) + */ name?: string; } @@ -19,21 +30,71 @@ export interface APIPartialChannel { * https://discord.com/developers/docs/resources/channel#channel-object-channel-structure */ export interface APIChannel extends APIPartialChannel { + /** + * The id of the guild + */ guild_id?: string; + /** + * Sorting position of the channel + */ position?: number; + /** + * Explicit permission overwrites for members and roles + * + * See https://discord.com/developers/docs/resources/channel#overwrite-object + */ permission_overwrites?: APIOverwrite[]; - name?: string; + /** + * The channel topic (0-1024 characters) + */ topic?: string | null; + /** + * Whether the channel is nsfw + */ nsfw?: boolean; + /** + * The id of the last message sent in this channel (may not point to an existing or valid message) + */ last_message_id?: string | null; + /** + * The bitrate (in bits) of the voice channel + */ bitrate?: number; + /** + * The user limit of the voice channel + */ user_limit?: number; + /** + * Amount of seconds a user has to wait before sending another message (0-21600); + * bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected + */ rate_limit_per_user?: number; + /** + * The recipients of the DM + * + * See https://discord.com/developers/docs/resources/user#user-object + */ recipients?: APIUser[]; + /** + * Icon hash + */ icon?: string | null; + /** + * ID of the DM creator + */ owner_id?: string; + /** + * Application id of the group DM creator if it is bot-created + */ application_id?: string; + /** + * ID of the parent category for a channel (each parent category can contain up to 50 channels) + */ parent_id?: string | null; + /** + * When the last pinned message was pinned. + * This may be `null` in events such as `GUILD_CREATE` when a message is not pinned + */ last_pin_timestamp?: string | null; } @@ -41,12 +102,39 @@ export interface APIChannel extends APIPartialChannel { * https://discord.com/developers/docs/resources/channel#channel-object-channel-types */ export const enum ChannelType { + /** + * A text channel within a guild + */ GUILD_TEXT = 0, + /** + * A direct message between users + */ DM, + /** + * A voice channel within a guild + */ GUILD_VOICE, + /** + * A direct message between multiple users + */ GROUP_DM, + /** + * An organizational category that contains up to 50 channels + * + * See https://support.discord.com/hc/en-us/articles/115001580171-Channel-Categories-101 + */ GUILD_CATEGORY, + /** + * A channel that users can follow and crosspost into their own guild + * + * See https://support.discord.com/hc/en-us/articles/360032008192 + */ GUILD_NEWS, + /** + * A channel in which game developers can sell their game on Discord + * + * See https://discord.com/developers/docs/game-and-server-management/special-channels + */ GUILD_STORE, } @@ -54,32 +142,169 @@ export const enum ChannelType { * https://discord.com/developers/docs/resources/channel#message-object-message-structure */ export interface APIMessage { + /** + * ID of the message + */ id: string; + /** + * ID of the channel the message was sent in + */ channel_id: string; + /** + * ID of the guild the message was sent in + */ guild_id?: string; + /** + * The author of this message (only a valid user in the case where the message is generated by a user or bot user) + * + * If the message is generated by a webhook, the author object corresponds to the webhook's id, + * username, and avatar. You can tell if a message is generated by a webhook by checking for the `webhook_id` property + * + * See https://discord.com/developers/docs/resources/user#user-object + */ author: APIUser; + /** + * Member properties for this message's author + * + * The member object exists in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events + * from text-based guild channels + * + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ member?: APIGuildMember; + /** + * Contents of the message + */ content: string; + /** + * When this message was sent + */ timestamp: string; + /** + * When this message was edited (or null if never) + */ edited_timestamp: string | null; + /** + * Whether this was a TTS message + */ tts: boolean; + /** + * Whether this message mentions everyone + */ mention_everyone: boolean; + /** + * Users specifically mentioned in the message + * + * The `member` field is only present in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events + * from text-based guild channels + * + * See https://discord.com/developers/docs/resources/user#user-object + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ mentions: (APIUser & { member?: Omit })[]; + /** + * Roles specifically mentioned in this message + * + * See https://discord.com/developers/docs/topics/permissions#role-object + */ mention_roles: string[]; + /** + * Channels specifically mentioned in this message + * + * Not all channel mentions in a message will appear in `mention_channels`. + * - Only textual channels that are visible to everyone in a lurkable guild will ever be included + * - Only crossposted messages (via Channel Following) currently include `mention_channels` at all + * + * If no mentions in the message meet these requirements, this field will not be sent + * + * See https://discord.com/developers/docs/resources/channel#channel-mention-object + */ mention_channels?: APIChannelMention[]; + /** + * Any attached files + * + * See https://discord.com/developers/docs/resources/channel#attachment-object + */ attachments: APIAttachment[]; + /** + * Any embedded content + * + * See https://discord.com/developers/docs/resources/channel#embed-object + */ embeds: APIEmbed[]; + /** + * Reactions to the message + * + * See https://discord.com/developers/docs/resources/channel#reaction-object + */ reactions?: APIReaction[]; + /** + * Used for validating a message was sent + * + * **You will not receive this from further fetches. This is received only once from a `MESSAGE_CREATE` + * event to ensure it got sent** + */ nonce?: string | number; + /** + * Whether this message is pinned + */ pinned: boolean; + /** + * If the message is generated by a webhook, this is the webhook's id + */ webhook_id?: string; + /** + * Type of message + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-types + */ type: MessageType; + /** + * Sent with Rich Presence-related chat embeds + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure + */ activity?: APIMessageActivity; + /** + * Sent with Rich Presence-related chat embeds + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-application-structure + */ application?: APIMessageApplication; + /** + * Reference data sent with crossposted messages and replies + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure + */ message_reference?: APIMessageReference; + /** + * Message flags combined as a bitfield + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-flags + * + * See https://en.wikipedia.org/wiki/Bit_field + */ flags?: MessageFlags; - referenced_message?: APIMessage | null; + /** + * The stickers sent with the message (bots currently can only receive messages with stickers, not send) + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure + */ stickers?: APISticker[]; + /** + * 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; } /** @@ -104,13 +329,24 @@ export const enum MessageType { GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING, GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING, REPLY = 19, + APPLICATION_COMMAND, } /** * 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; } @@ -118,10 +354,25 @@ export interface APIMessageActivity { * https://discord.com/developers/docs/resources/channel#message-object-message-application-structure */ export interface APIMessageApplication { + /** + * ID of the application + */ id: string; + /** + * ID of the embed's image asset + */ cover_image?: string; + /** + * Application's description + */ description: string; + /** + * ID of the application's icon + */ icon: string | null; + /** + * Name of the application + */ name: string; } @@ -129,8 +380,17 @@ export interface APIMessageApplication { * https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure */ export interface APIMessageReference { + /** + * ID of the originating message + */ message_id?: string; - channel_id?: string; + /** + * ID of the originating message's channel + */ + channel_id: string; + /** + * ID of the originating message's guild + */ guild_id?: string; } @@ -148,10 +408,25 @@ export const enum MessageActivityType { * https://discord.com/developers/docs/resources/channel#message-object-message-flags */ export const 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) + */ IS_CROSSPOST = 1 << 1, + /** + * Do not include any embeds when serializing this message + */ SUPPRESS_EMBEDS = 1 << 2, + /** + * The source message for this crosspost has been deleted (via Channel Following) + */ SOURCE_MESSAGE_DELETED = 1 << 3, + /** + * This message came from the urgent message system + */ URGENT = 1 << 4, EPHEMERAL = 1 << 6, } @@ -160,13 +435,39 @@ export const enum MessageFlags { * https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure */ export interface APISticker { + /** + * ID of the sticker + */ id: string; + /** + * ID of the pack the sticker is from + */ pack_id: string; + /** + * Name of the sticker + */ name: string; + /** + * Description of the sticker + */ description: string; + /** + * A comma-separated list of tags for the sticker + */ tags?: string; + /** + * Sticker asset hash + */ asset: string; + /** + * Sticker preview asset hash + */ preview_asset: string | null; + /** + * Type of sticker format + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types + */ format_type: StickerFormatType; } @@ -179,12 +480,37 @@ export const enum StickerFormatType { LOTTIE, } +/** + * https://discord.com/developers/docs/resources/channel#followed-channel-object + */ +export interface APIFollowedChannel { + /** + * Source channel id + */ + channel_id: string; + /** + * Created target webhook id + */ + webhook_id: string; +} + /** * https://discord.com/developers/docs/resources/channel#reaction-object-reaction-structure */ export interface APIReaction { + /** + * Times this emoji has been used to react + */ count: number; + /** + * Whether the current user reacted using this emoji + */ me: boolean; + /** + * Emoji information + * + * See https://discord.com/developers/docs/resources/emoji#emoji-object + */ emoji: APIPartialEmoji; } @@ -192,9 +518,31 @@ export interface APIReaction { * https://discord.com/developers/docs/resources/channel#overwrite-object-overwrite-structure */ export interface APIOverwrite { + /** + * Role or user id + */ id: string; + /** + * 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: string; + /** + * Permission bit set + * + * See https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags + * + * See https://en.wikipedia.org/wiki/Bit_field + */ deny: string; } @@ -205,23 +553,85 @@ export const enum OverwriteType { /** * 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: 2048 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[]; } @@ -230,11 +640,29 @@ export interface APIEmbed { * @deprecated *Embed types should be considered deprecated and might be removed in a future API version* */ export const 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', } @@ -242,9 +670,21 @@ export const enum EmbedType { * 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; } @@ -252,8 +692,17 @@ export interface APIEmbedThumbnail { * https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure */ export interface APIEmbedVideo { + /** + * Source url of video + */ url?: string; + /** + * Height of video + */ height?: number; + /** + * Width of video + */ width?: number; } @@ -261,9 +710,21 @@ export interface APIEmbedVideo { * 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; } @@ -271,7 +732,13 @@ export interface APIEmbedImage { * 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; } @@ -279,9 +746,23 @@ export interface APIEmbedProvider { * 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; } @@ -289,8 +770,19 @@ export interface APIEmbedAuthor { * 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; } @@ -298,8 +790,21 @@ export interface APIEmbedFooter { * 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; } @@ -307,26 +812,100 @@ export interface APIEmbedField { * https://discord.com/developers/docs/resources/channel#attachment-object-attachment-structure */ export interface APIAttachment { + /** + * Attachment id + */ id: string; + /** + * Name of file attached + */ filename: string; + /** + * Size of file in bytes + */ size: number; + /** + * Source url of file + */ url: string; + /** + * A proxied url of file + */ proxy_url: string; - height: number | null; - width: number | null; + /** + * Height of file (if image) + */ + height?: number | null; + /** + * Width of file (if image) + */ + width?: number | null; } /** * https://discord.com/developers/docs/resources/channel#channel-mention-object-channel-mention-structure */ export interface APIChannelMention { + /** + * ID of the channel + */ id: string; + /** + * ID of the guild containing the channel + */ guild_id: string; + /** + * 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; } -export interface APIFollowedChannel { - channel_id: string; - webhook_id: string; +/** + * https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types + */ +export const 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?: string[]; + /** + * Array of user_ids to mention (Max size of 100) + */ + users?: string[]; + /** + * For replies, whether to mention the author of the message being replied to (default false) + * + * @default false + */ + replied_user?: boolean; } diff --git a/v8/payloads/emoji.ts b/v8/payloads/emoji.ts index 3f038a25..51f91b87 100644 --- a/v8/payloads/emoji.ts +++ b/v8/payloads/emoji.ts @@ -8,8 +8,17 @@ import type { APIUser } from './user'; * Not documented but mentioned */ export interface APIPartialEmoji { + /** + * Emoji id + */ id: string | null; + /** + * Emoji name (can be null only in reaction emoji objects) + */ name: string | null; + /** + * Whether this emoji is animated + */ animated?: boolean; } @@ -17,9 +26,24 @@ export interface APIPartialEmoji { * https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure */ export interface APIEmoji extends APIPartialEmoji { + /** + * Roles this emoji is whitelisted to + */ roles?: string[]; + /** + * User that created this emoji + */ user?: APIUser; + /** + * Whether this emoji must be wrapped in colons + */ require_colons?: boolean; + /** + * Whether this emoji is managed + */ managed?: boolean; + /** + * Whether this emoji can be used, may be false due to loss of Server Boosts + */ available?: boolean; } diff --git a/v8/payloads/gateway.ts b/v8/payloads/gateway.ts index 682dd5d1..74423e04 100644 --- a/v8/payloads/gateway.ts +++ b/v8/payloads/gateway.ts @@ -9,6 +9,9 @@ import type { APIUser } from './user'; * https://discord.com/developers/docs/topics/gateway#get-gateway */ export interface APIGatewayInfo { + /** + * The WSS URL that can be used for connecting to the gateway + */ url: string; } @@ -16,7 +19,17 @@ export interface APIGatewayInfo { * https://discord.com/developers/docs/topics/gateway#get-gateway-bot */ export interface APIGatewayBotInfo extends APIGatewayInfo { + /** + * The recommended number of shards to use when connecting + * + * See https://discord.com/developers/docs/topics/gateway#sharding + */ shards: number; + /** + * Information on the current session start limit + * + * See https://discord.com/developers/docs/topics/gateway#session-start-limit-object + */ session_start_limit: APIGatewaySessionStartLimit; } @@ -24,58 +37,170 @@ export interface APIGatewayBotInfo extends APIGatewayInfo { * https://discord.com/developers/docs/topics/gateway#session-start-limit-object */ export interface APIGatewaySessionStartLimit { + /** + * The total number of session starts the current user is allowed + */ total: number; + /** + * The remaining number of session starts the current user is allowed + */ remaining: number; + /** + * The number of milliseconds after which the limit resets + */ reset_after: number; + /** + * The number of identify requests allowed per 5 seconds + */ + max_concurrency: number; } /** * https://discord.com/developers/docs/topics/gateway#presence-update-presence-update-event-fields */ export interface GatewayPresenceUpdate { + /** + * The user presence is being updated for + * + * **The user object within this event can be partial, the only field which must be sent is the `id` field, + * everything else is optional.** + * + * See https://discord.com/developers/docs/resources/user#user-object + */ user: Partial & { id: string; }; - guild_id?: string; + /** + * ID of the guild + */ + guild_id: string; + /** + * Either "idle", "dnd", "online", or "offline" + */ status?: PresenceUpdateStatus; + /** + * User's current activities + * + * See https://discord.com/developers/docs/topics/gateway#activity-object + */ activities?: GatewayActivity[]; + /** + * User's platform-dependent status + * + * See https://discord.com/developers/docs/topics/gateway#client-status-object + */ client_status?: GatewayPresenceClientStatus; } export const enum PresenceUpdateStatus { + Online = 'online', DoNotDisturb = 'dnd', Idle = 'idle', + /** + * Invisible and shown as offline + */ Invisible = 'invisible', Offline = 'offline', - Online = 'online', } /** * https://discord.com/developers/docs/topics/gateway#client-status-object */ -export type GatewayPresenceClientStatus = Partial>; +export interface GatewayPresenceClientStatus { + /** + * The user's status set for an active desktop (Windows, Linux, Mac) application session + */ + desktop?: PresenceUpdateStatus; + /** + * The user's status set for an active mobile (iOS, Android) application session + */ + mobile?: PresenceUpdateStatus; + /** + * The user's status set for an active web (browser, bot account) application session + */ + web?: PresenceUpdateStatus; +} /** * https://discord.com/developers/docs/topics/gateway#activity-object-activity-structure */ export interface GatewayActivity { + /** + * The activity's id + */ id: string; + /** + * The activity's name + */ name: string; + /** + * Activity type + * + * See https://discord.com/developers/docs/topics/gateway#activity-object-activity-types + */ type: ActivityType; + /** + * Stream url, is validated when type is `1` + */ url?: string | null; + /** + * Unix timestamp of when the activity was added to the user's session + */ created_at: number; + /** + * Unix timestamps for start and/or end of the game + */ timestamps?: GatewayActivityTimestamps; sync_id?: string; platform?: ActivityPlatform; + /** + * Application id for the game + */ application_id?: string; + /** + * What the player is currently doing + */ details?: string | null; + /** + * The user's current party status + */ state?: string | null; + /** + * The emoji used for a custom status + * + * See https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji + */ emoji?: GatewayActivityEmoji; session_id?: string; + /** + * Information for the current party of the player + * + * See https://discord.com/developers/docs/topics/gateway#activity-object-activity-party + */ party?: GatewayActivityParty; + /** + * Images for the presence and their hover texts + * + * See https://discord.com/developers/docs/topics/gateway#activity-object-activity-assets + */ assets?: GatewayActivityAssets; + /** + * Secrets for Rich Presence joining and spectating + * + * See https://discord.com/developers/docs/topics/gateway#activity-object-activity-secrets + */ secrets?: GatewayActivitySecrets; + /** + * Whether or not the activity is an instanced game session + */ instance?: boolean; + /** + * Activity flags `OR`d together, describes what the payload includes + * + * See https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags + * + * See https://en.wikipedia.org/wiki/Bit_field + */ flags?: ActivityFlags; buttons?: string[] | GatewayActivityButton[]; } @@ -90,11 +215,29 @@ export enum ActivityPlatform { * https://discord.com/developers/docs/topics/gateway#activity-object-activity-types */ export const enum ActivityType { + /** + * Playing {game} + */ Game, + /** + * Streaming {details} + */ Streaming, + /** + * Listening to {name} + */ Listening, - - Custom = 4, + /** + * Watching {details} + */ + Watching, + /** + * {emoji} {details} + */ + Custom, + /** + * Competing in {name} + */ Competing, } @@ -102,22 +245,33 @@ export const enum ActivityType { * https://discord.com/developers/docs/topics/gateway#activity-object-activity-timestamps */ export interface GatewayActivityTimestamps { + /** + * Unix time (in milliseconds) of when the activity started + */ start?: number; + /** + * Unix time (in milliseconds) of when the activity ends + */ end?: number; } /** * https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji */ -export type GatewayActivityEmoji = Partial> & Pick; +export type GatewayActivityEmoji = Partial> & Pick; /** * https://discord.com/developers/docs/topics/gateway#activity-object-activity-party */ export interface GatewayActivityParty { + /** + * The id of the party + */ id?: string; - // eslint-disable-next-line prettier/prettier - size?: [currentSize: number, maxSize: number]; + /** + * Used to show the party's current and maximum size + */ + size?: [current_size: number, max_size: number]; } /** diff --git a/v8/payloads/guild.ts b/v8/payloads/guild.ts index 94ea13c5..f307029e 100644 --- a/v8/payloads/guild.ts +++ b/v8/payloads/guild.ts @@ -13,7 +13,13 @@ import type { GatewayVoiceState } from './voice'; * https://discord.com/developers/docs/resources/guild#unavailable-guild-object */ export interface APIUnavailableGuild { + /** + * Guild id + */ id: string; + /** + * `true` if this guild is unavailable due to an outage + */ unavailable: boolean; } @@ -21,14 +27,51 @@ export interface APIUnavailableGuild { * https://discord.com/developers/docs/resources/guild#guild-object-guild-structure */ export interface APIPartialGuild extends Omit, Pick { + /** + * Guild name (2-100 characters, excluding trailing and leading whitespace) + */ name: string; + /** + * Icon hash + * + * See https://discord.com/developers/docs/reference#image-formatting + */ icon: string | null; + /** + * Splash hash + * + * See https://discord.com/developers/docs/reference#image-formatting + */ splash: string | null; + /** + * Banner hash + * + * See https://discord.com/developers/docs/reference#image-formatting + */ banner?: string | null; + /** + * The description for the guild, if the guild is discoverable + */ description?: string | null; + /** + * Enabled guild features + * + * See https://discord.com/developers/docs/resources/guild#guild-object-guild-features + */ features?: GuildFeature[]; + /** + * Verification level required for the guild + * + * See https://discord.com/developers/docs/resources/guild#guild-object-verification-level + */ verification_level?: GuildVerificationLevel; + /** + * The vanity url code for the guild + */ vanity_url_code?: string | null; + /** + * `true` if this guild is unavailable due to an outage + */ unavailable?: boolean; } @@ -36,50 +79,220 @@ export interface APIPartialGuild extends Omit[]; + /** + * Users in the guild + * + * **This field is only sent within the [GUILD_CREATE](https://discord.com/developers/docs/topics/gateway#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#guild-create) event** + * + * See https://discord.com/developers/docs/resources/channel#channel-object + */ channels?: 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#guild-create) event** + * + * See https://discord.com/developers/docs/topics/gateway#presence-update + */ presences?: GatewayPresenceUpdate[]; + /** + * The maximum number of presences for the guild (the default value, currently 25000, is in effect when `null` is returned) + */ max_presences?: number | null; + /** + * The maximum number of members for the guild + */ max_members?: number; + /** + * The vanity url code for the guild + */ vanity_url_code: string | null; + /** + * The description for the guild, if the guild is discoverable + */ description: string | null; + /** + * Banner hash + * + * See https://discord.com/developers/docs/reference#image-formatting + */ banner: string | null; + /** + * Premium tier (Server Boost level) + * + * See https://discord.com/developers/docs/resources/guild#guild-object-premium-tier + */ premium_tier: GuildPremiumTier; + /** + * The number of boosts this guild currently has + */ premium_subscription_count?: number; + /** + * The preferred locale of a Community guild; used in guild discovery and notices from Discord; defaults to "en-US" + * + * @default "en-US" + */ preferred_locale: string; + /** + * The id of the channel where admins and moderators of Community guilds receive notices from Discord + */ public_updates_channel_id: string | null; + /** + * The maximum amount of users in a video channel + */ max_video_channel_users?: number; /** - * Returned by calling GET `/guilds/{guild.id}` with the query `with_counts` set to `true` + * **This field is only received from https://discord.com/developers/docs/resources/guild#get-guild with the `with_counts` query parameter set to `true`** */ approximate_member_count?: number; /** - * Returned by calling GET `/guilds/{guild.id}` with the query `with_counts` set to `true` + * **This field is only received from https://discord.com/developers/docs/resources/guild#get-guild with the `with_counts` query parameter set to `true`** */ approximate_presence_count?: number; welcome_screen?: APIGuildWelcomeScreen; @@ -114,10 +327,25 @@ export const enum GuildMFALevel { * https://discord.com/developers/docs/resources/guild#guild-object-verification-level */ export const enum GuildVerificationLevel { + /** + * Unrestricted + */ NONE, + /** + * Must have verified email on account + */ LOW, + /** + * Must be registered on Discord for longer than 5 minutes + */ MEDIUM, + /** + * Must be a member of the guild for longer than 10 minutes + */ HIGH, + /** + * Must have a verified phone number + */ VERY_HIGH, } @@ -135,7 +363,13 @@ export const enum GuildPremiumTier { * https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags */ export const enum GuildSystemChannelFlags { + /** + * Suppress member join notifications + */ SUPPRESS_JOIN_NOTIFICATIONS = 1 << 0, + /** + * Suppress server boost notifications + */ SUPPRESS_PREMIUM_SUBSCRIPTIONS = 1 << 1, } @@ -143,45 +377,353 @@ export const enum GuildSystemChannelFlags { * https://discord.com/developers/docs/resources/guild#guild-object-guild-features */ export const enum GuildFeature { + /** + * Guild has access to set an animated guild icon + */ ANIMATED_ICON = 'ANIMATED_ICON', + /** + * Guild has access to set a guild banner image + */ BANNER = 'BANNER', + /** + * Guild has access to use commerce features (i.e. create store channels) + */ COMMERCE = 'COMMERCE', + /** + * Guild can enable welcome screen, Membership Screening and discovery, and receives community updates + */ COMMUNITY = 'COMMUNITY', + /** + * Guild is able to be discovered in the directory + */ DISCOVERABLE = 'DISCOVERABLE', + /** + * Guild is able to be featured in the directory + */ FEATURABLE = 'FEATURABLE', + /** + * Guild has access to set an invite splash background + */ INVITE_SPLASH = 'INVITE_SPLASH', + /** + * Guild has access to create news channels + */ NEWS = 'NEWS', + /** + * Guild is partnered + */ PARTNERED = 'PARTNERED', RELAY_ENABLED = 'RELAY_ENABLED', + /** + * Guild has access to set a vanity URL + */ VANITY_URL = 'VANITY_URL', + /** + * Guild is verified + */ VERIFIED = 'VERIFIED', + /** + * Guild has access to set 384kbps bitrate in voice (previously VIP voice servers) + */ VIP_REGIONS = 'VIP_REGIONS', + /** + * Guild has enabled the welcome screen + */ WELCOME_SCREEN_ENABLED = 'WELCOME_SCREEN_ENABLED', + /** + * Guild has enabled Membership Screening + */ + MEMBER_VERIFICATION_GATE_ENABLED = 'MEMBER_VERIFICATION_GATE_ENABLED', + /** + * Guild can be previewed before joining via Membership Screening or the directory + */ + PREVIEW_ENABLED = 'PREVIEW_ENABLED', } /** * https://discord.com/developers/docs/resources/guild#guild-preview-object */ export interface APIGuildPreview { + /** + * Guild id + */ id: string; + /** + * Guild name (2-100 characters) + */ name: string; + /** + * Icon hash + * + * See https://discord.com/developers/docs/reference#image-formatting + */ icon: string | null; + /** + * Splash hash + * + * See https://discord.com/developers/docs/reference#image-formatting + */ splash: string | null; + /** + * Discovery splash hash; only present for guilds with the "DISCOVERABLE" feature + * + * See https://discord.com/developers/docs/reference#image-formatting + */ discovery_splash: string | null; + /** + * Custom guild emojis + * + * See https://discord.com/developers/docs/resources/emoji#emoji-object + */ emojis: APIEmoji[]; + /** + * Enabled guild features + * + * See https://discord.com/developers/docs/resources/guild#guild-object-guild-features + */ features: GuildFeature[]; + /** + * Approximate number of members in this guild + */ approximate_member_count: number; + /** + * Approximate number of online members in this guild + */ approximate_presence_count: number; + /** + * The description for the guild + */ + description: string; } /** * https://discord.com/developers/docs/resources/guild#guild-widget-object */ export interface APIGuildWidgetSettings { + /** + * Whether the widget is enabled + */ enabled: boolean; + /** + * The widget channel id + */ channel_id: string | null; } +/** + * https://discord.com/developers/docs/resources/guild#guild-member-object + */ +export interface APIGuildMember { + /** + * The user this guild member represents + * + * **This field won't be included in the member object attached to `MESSAGE_CREATE` and `MESSAGE_UPDATE` gateway events.** + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + user?: APIUser; + /** + * This users guild nickname + */ + nick?: string | null; + /** + * Array of role object ids + * + * See https://discord.com/developers/docs/topics/permissions#role-object + */ + roles: string[]; + /** + * When the user joined the guild + */ + joined_at: string; + /** + * When the user started boosting the guild + * + * See https://support.discord.com/hc/en-us/articles/360028038352-Server-Boosting- + */ + premium_since?: string | null; + /** + * Whether the user is deafened in voice channels + */ + deaf: boolean; + /** + * Whether the user is muted in voice channels + */ + mute: boolean; + /** + * Whether the user has not yet passed the guild's Membership Screening requirements + * + * *If this field is not present, it can be assumed as `false`.* + */ + pending?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/guild#integration-object + */ +export interface APIGuildIntegration { + /** + * Integration id + */ + id: string; + /** + * Integration name + */ + name: string; + /** + * Integration type + */ + type: APIGuildInteractionType; + /** + * Is this integration enabled + */ + enabled: boolean; + /** + * Is this integration syncing + * + * **This field is not provided for `discord` bot integrations.** + */ + syncing?: boolean; + /** + * ID that this integration uses for "subscribers" + * + * **This field is not provided for `discord` bot integrations.** + */ + role_id?: string; + /** + * Whether emoticons should be synced for this integration (`twitch` only currently) + * + * **This field is not provided for `discord` bot integrations.** + */ + enable_emoticons?: boolean; + /** + * The behavior of expiring subscribers + * + * **This field is not provided for `discord` bot integrations.** + * + * See https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors + */ + expire_behavior?: IntegrationExpireBehavior; + /** + * The grace period (in days) before expiring subscribers + * + * **This field is not provided for `discord` bot integrations.** + */ + expire_grace_period?: number; + /** + * User for this integration + * + * **This field is not provided for `discord` bot integrations.** + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + user?: APIUser; + /** + * Integration account information + * + * See https://discord.com/developers/docs/resources/guild#integration-account-object + */ + account: APIIntegrationAccount; + /** + * When this integration was last synced + * + * **This field is not provided for `discord` bot integrations.** + */ + synced_at?: string; + /** + * How many subscribers this integration has + * + * **This field is not provided for `discord` bot integrations.** + */ + subscriber_count?: number; + /** + * Has this integration been revoked + * + * **This field is not provided for `discord` bot integrations.** + */ + revoked?: boolean; + /** + * The bot/OAuth2 application for discord integrations + * + * See https://discord.com/developers/docs/resources/guild#integration-application-object + * + * **This field is not provided for `discord` bot integrations.** + */ + application?: APIGuildIntegrationApplication; +} + +export type APIGuildInteractionType = 'twitch' | 'youtube' | 'discord'; + +/** + * https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors + */ +export const enum IntegrationExpireBehavior { + RemoveRole, + Kick, +} + +/** + * https://discord.com/developers/docs/resources/guild#integration-account-object + */ +export interface APIIntegrationAccount { + /** + * ID of the account + */ + id: string; + /** + * Name of the account + */ + name: string; +} + +/** + * https://discord.com/developers/docs/resources/guild#integration-application-object + */ +export interface APIGuildIntegrationApplication { + /** + * The id of the app + */ + id: string; + /** + * The name of the app + */ + name: string; + /** + * The icon hash of the app + * + * See https://discord.com/developers/docs/reference#image-formatting + */ + icon: string | null; + /** + * The description of the app + */ + description: string; + /** + * The summary of the app + */ + summary: string; + /** + * The bot associated with this application + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + bot?: APIUser; +} + +/** + * https://discord.com/developers/docs/resources/guild#ban-object + */ +export interface APIBan { + /** + * The reason for the ban + */ + reason: string | null; + /** + * The banned user + */ + user: APIUser; +} + /** * https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget */ @@ -216,95 +758,98 @@ export interface APIGuildWidgetMember { avatar_url: string; } -/** - * https://discord.com/developers/docs/resources/guild#guild-member-object - */ -export interface APIGuildMember { - user?: APIUser; - nick: string | null; - roles: string[]; - joined_at: string; - premium_since?: string | null; - deaf: boolean; - mute: boolean; - pending?: boolean; -} - -/** - * https://discord.com/developers/docs/resources/guild#integration-object - */ -export interface APIGuildIntegration { - id: string; - name: string; - type: string; - enabled: boolean; - syncing?: boolean; - role_id?: string; - enable_emoticons?: boolean; - expire_behavior?: IntegrationExpireBehavior; - expire_grace_period?: number; - user?: APIUser; - account: APIIntegrationAccount; - synced_at?: string; - subscriber_count?: number; - revoked?: boolean; - application?: APIGuildIntegrationApplication; -} - -/** - * https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors - */ -export const enum IntegrationExpireBehavior { - RemoveRole, - Kick, -} - -/** - * https://discord.com/developers/docs/resources/guild#integration-account-object - */ -export interface APIIntegrationAccount { - id: string; - name: string; -} - -/** - * https://discord.com/developers/docs/resources/guild#integration-application-object - */ -export interface APIGuildIntegrationApplication { - id: string; - name: string; - icon: string | null; - description: string; - summary: string; - bot?: APIUser; -} - -/** - * https://discord.com/developers/docs/resources/guild#ban-object - */ -export interface APIBan { - reason: string | null; - user: APIUser; -} - /** * https://discord.com/developers/docs/resources/guild#get-guild-widget-image-widget-style-options */ export const enum GuildWidgetStyle { - Banner1 = 'banner1', - Banner2 = 'banner2', - Banner3 = 'banner3', - Banner4 = 'banner4', + /** + * Shield style widget with Discord icon and guild members online count + */ Shield = 'shield', + /** + * Large image with guild icon, name and online count. "POWERED BY DISCORD" as the footer of the widget + */ + Banner1 = 'banner1', + /** + * Smaller widget style with guild icon, name and online count. Split on the right with Discord logo + */ + Banner2 = 'banner2', + /** + * Large image with guild icon, name and online count. In the footer, Discord logo on the left and "Chat Now" on the right + */ + Banner3 = 'banner3', + /** + * Large Discord logo at the top of the widget. Guild icon, name and online count in the middle portion of the widget + * and a "JOIN MY SERVER" button at the bottom + */ + Banner4 = 'banner4', } export interface APIGuildWelcomeScreen { + /** + * The welcome screen short message + */ description: string | null; + /** + * Array of suggested channels + */ welcome_channels: APIGuildWelcomeScreenChannel[]; } export interface APIGuildWelcomeScreenChannel { + /** + * The channel id that is suggested + */ channel_id: string; + /** + * The emoji id of the emoji that is shown on the left of the channel + */ emoji_id: string | null; + /** + * The emoji name of the emoji that is shown on the left of the channel + */ emoji_name: string | null; } + +export interface APIGuildMembershipScreening { + /** + * When the fields were last updated + */ + version: string; + /** + * The steps in the screening form + */ + form_fields: APIGuildMembershipScreeningField[]; + /** + * The server description shown in the screening form + */ + description: string | null; +} + +// TODO: make this a union based on the type in the future, when new types are added + +export interface APIGuildMembershipScreeningField { + /** + * The type of field + */ + field_type: MembershipScreeningFieldType; + /** + * The title of the field + */ + label: string; + /** + * The list of rules + */ + values?: string[]; + /** + * Whether the user has to fill out this field + */ + required: boolean; +} + +export const enum MembershipScreeningFieldType { + /** + * Server Rules + */ + TERMS = 'TERMS', +} diff --git a/v8/payloads/interactions.ts b/v8/payloads/interactions.ts index 41985582..2c299b4f 100644 --- a/v8/payloads/interactions.ts +++ b/v8/payloads/interactions.ts @@ -1,5 +1,5 @@ -import type { APIGuildMember, APIUser, MessageFlags } from './'; -import type { RESTPostAPIWebhookWithTokenJSONBody } from '../rest'; +import type { APIGuildMember, APIUser, MessageFlags } from './index'; +import type { RESTPostAPIWebhookWithTokenJSONBody } from '../rest/index'; /** * https://discord.com/developers/docs/interactions/slash-commands#applicationcommand @@ -33,7 +33,7 @@ export type APIApplicationCommandOption = | APIApplicationCommandOptionBase; /** - * This type is exported as a way to make it stricter for you when you're writing your commands. + * This type is exported as a way to make it stricter for you when you're writing your commands * * If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters */ @@ -43,9 +43,9 @@ export interface APIApplicationCommandSubCommandOptions extends Omit { @@ -90,7 +90,7 @@ export interface APIInteraction { } /** - * Like {@see APIInteraction}, only with the `data` property always present + * Like See APIInteraction, only with the `data` property always present */ export type APIApplicationCommandInteraction = Required; @@ -120,7 +120,7 @@ export interface APIApplicationCommandInteractionDataOption { * The value returned here depends on the `ApplicationCommandOptionType` type of the option with the name * that matches this interface's `name`. * - * You will need to manually cast this to the appropriate type based on the returned data. + * You will need to manually cast this to the appropriate type based on the returned data */ value?: unknown; options?: APIApplicationCommandInteractionDataOption[]; diff --git a/v8/payloads/invite.ts b/v8/payloads/invite.ts index 00bf74a3..eba1d409 100644 --- a/v8/payloads/invite.ts +++ b/v8/payloads/invite.ts @@ -10,13 +10,47 @@ import type { APIUser } from './user'; * https://discord.com/developers/docs/resources/invite#invite-object */ export interface APIInvite { + /** + * The invite code (unique ID) + */ code: string; + /** + * The guild this invite is for + * + * See https://discord.com/developers/docs/resources/guild#guild-object + */ guild?: APIPartialGuild; + /** + * The channel this invite is for + * + * See https://discord.com/developers/docs/resources/channel#channel-object + */ channel?: Required; + /** + * The user who created the invite + * + * See https://discord.com/developers/docs/resources/user#user-object + */ inviter?: APIUser; + /** + * The target user for this invite + * + * See https://discord.com/developers/docs/resources/user#user-object + */ target_user?: APIUser; + /** + * The type of user target for this invite + * + * See https://discord.com/developers/docs/resources/invite#invite-object-target-user-types + */ target_user_type?: InviteTargetUserType; + /** + * Approximate count of online members (only present when `target_user` is set) + */ approximate_presence_count?: number; + /** + * Approximate count of total members + */ approximate_member_count?: number; } @@ -31,9 +65,24 @@ export const enum InviteTargetUserType { * https://discord.com/developers/docs/resources/invite#invite-metadata-object */ export interface APIExtendedInvite extends APIInvite { + /** + * Number of times this invite has been used + */ uses: number; + /** + * Max number of times this invite can be used + */ max_uses: number; + /** + * Duration (in seconds) after which the invite expires + */ max_age: number; + /** + * Whether this invite only grants temporary membership + */ temporary: boolean; + /** + * When this invite was created + */ created_at: string; } diff --git a/v8/payloads/oauth2.ts b/v8/payloads/oauth2.ts index a92233a1..4d3abc4c 100644 --- a/v8/payloads/oauth2.ts +++ b/v8/payloads/oauth2.ts @@ -9,20 +9,184 @@ import type { APIUser } from './user'; * https://discord.com/developers/docs/topics/oauth2#get-current-application-information-response-structure */ export interface APIApplication { + /** + * The id of the app + */ id: string; + /** + * 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 containing info on the owner of the application + * + * See https://discord.com/developers/docs/resources/user#user-object + */ owner: APIUser; + /** + * If this application is a game sold on Discord, this field will be the summary field for the store page + * of its primary sku + */ summary: string; + /** + * The base64 encoded key for the GameSDK's GetTicket + * + * See https://discord.com/developers/docs/game-sdk/applications#get-ticket + */ verify_key: string; + /** + * The team this application belongs to + * + * See https://discord.com/developers/docs/topics/teams#data-models-team-object + */ team: APITeam | null; + /** + * If this application is a game sold on Discord, this field will be the guild to which it has been linked + */ guild_id?: string; + /** + * 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?: string; + /** + * 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 + */ flags: number; } + +export const enum OAuth2Scopes { + /** + * For oauth2 bots, this puts the bot in the user's selected guild by default + */ + Bot = 'bot', + /** + * Allows [/users/@me/connections](https://discord.com/developers/docs/resources/user#get-user-connections) + * to return linked third-party accounts + * + * See https://discord.com/developers/docs/resources/user#get-user-connections + */ + Connections = 'connections', + /** + * Enables [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) to return an `email` + * + * See https://discord.com/developers/docs/resources/user#get-current-user + */ + Email = 'email', + /** + * Allows [/users/@me](https://discord.com/developers/docs/resources/user#get-current-user) without `email` + * + * See https://discord.com/developers/docs/resources/user#get-current-user + */ + Identify = 'identify', + /** + * Allows [/users/@me/guilds](https://discord.com/developers/docs/resources/user#get-current-user-guilds) + * to return basic information about all of a user's guilds + * + * See https://discord.com/developers/docs/resources/user#get-current-user-guilds + */ + Guilds = 'guilds', + /** + * Allows [/guilds/{guild.id}/members/{user.id}](https://discord.com/developers/docs/resources/guild#add-guild-member) + * to be used for joining users to a guild + * + * See https://discord.com/developers/docs/resources/guild#add-guild-member + */ + GuildsJoin = 'guilds.join', + /** + * Allows your app to join users to a group dm + * + * See https://discord.com/developers/docs/resources/channel#group-dm-add-recipient + */ + GroupDMJoins = 'gdm.join', + /** + * For local rpc server api access, this allows you to read messages from all client channels + * (otherwise restricted to channels/guilds your app creates) + */ + MessagesRead = 'messages.read', + /** + * For local rpc server access, this allows you to control a user's local Discord client - whitelist only + */ + RPC = 'rpc', + /** + * For local rpc server api access, this allows you to access the API as the local user - whitelist only + */ + RPCApi = 'rpc.api', + /** + * For local rpc server api access, this allows you to receive notifications pushed out to the user - whitelist only + */ + RPCNotificationsRead = 'rpc.notifications.read', + /** + * This generates a webhook that is returned in the oauth token response for authorization code grants + */ + WebhookIncoming = 'webhook.incoming', + /** + * Allows your app to upload/update builds for a user's applications - whitelist only + */ + ApplicationsBuildsUpload = 'applications.builds.upload', + /** + * Allows your app to read build data for a user's applications + */ + ApplicationsBuildsRead = 'applications.builds.read', + /** + * Allows your app to read and update store data (SKUs, store listings, achievements, etc.) for a user's applications + */ + ApplicationsStoreUpdate = 'applications.store.update', + /** + * Allows your app to read entitlements for a user's applications + */ + ApplicationsEntitlements = 'applications.entitlements', + /** + * Allows your app to know a user's friends and implicit relationships - whitelist only + */ + RelationshipsRead = 'relationships.read', + /** + * Allows your app to fetch data from a user's "Now Playing/Recently Played" list - whitelist only + */ + ActivitiesRead = 'activities.read', + /** + * Allows your app to update a user's activity - whitelist only (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER) + * + * See https://discord.com/developers/docs/game-sdk/activities + */ + ActivitiesWrite = 'activities.write', + /** + * Allows your app to create Slash Commands in the authorized guild + * + * See https://discord.com/developers/docs/interactions/slash-commands + */ + ApplicationsCommands = 'applications.commands', + /** + * Allows your app to update Slash Commands via this bearer token + * + * See https://discord.com/developers/docs/interactions/slash-commands + */ + ApplicationsCommandsUpdate = 'applications.commands.update', +} diff --git a/v8/payloads/permissions.ts b/v8/payloads/permissions.ts index 491aaed7..7282a7ad 100644 --- a/v8/payloads/permissions.ts +++ b/v8/payloads/permissions.ts @@ -8,44 +8,44 @@ * These flags are exported as `BigInt`s and NOT numbers. For most of them, you can * convert them in a number by wrapping it in `Number()`, however be careful as any * further bits added may cause issues if done so. Try to use BigInts as much as possible - * or modules that can replicate them in some way. + * or modules that can replicate them in some way */ export const PermissionFlagsBits = { - CREATE_INSTANT_INVITE: 1n, - KICK_MEMBERS: 2n, - BAN_MEMBERS: 4n, - ADMINISTRATOR: 8n, - MANAGE_CHANNELS: 16n, - MANAGE_GUILD: 32n, - ADD_REACTIONS: 64n, - VIEW_AUDIT_LOG: 128n, - PRIORITY_SPEAKER: 256n, - STREAM: 512n, - VIEW_CHANNEL: 1024n, - SEND_MESSAGES: 2048n, - SEND_TTS_MESSAGES: 4096n, - MANAGE_MESSAGES: 8192n, - EMBED_LINKS: 16384n, - ATTACH_FILES: 32768n, - READ_MESSAGE_HISTORY: 65536n, - MENTION_EVERYONE: 131072n, - USE_EXTERNAL_EMOJIS: 262144n, - VIEW_GUILD_INSIGHTS: 524288n, - CONNECT: 1048576n, - SPEAK: 2097152n, - MUTE_MEMBERS: 4194304n, - DEAFEN_MEMBERS: 8388608n, - MOVE_MEMBERS: 16777216n, - USE_VAD: 33554432n, - CHANGE_NICKNAME: 67108864n, - MANAGE_NICKNAMES: 134217728n, - MANAGE_ROLES: 268435456n, - MANAGE_WEBHOOKS: 536870912n, - MANAGE_EMOJIS: 1073741824n, + CREATE_INSTANT_INVITE: 1n << 0n, + KICK_MEMBERS: 1n << 1n, + BAN_MEMBERS: 1n << 2n, + ADMINISTRATOR: 1n << 3n, + MANAGE_CHANNELS: 1n << 4n, + MANAGE_GUILD: 1n << 5n, + ADD_REACTIONS: 1n << 6n, + VIEW_AUDIT_LOG: 1n << 7n, + PRIORITY_SPEAKER: 1n << 8n, + STREAM: 1n << 9n, + VIEW_CHANNEL: 1n << 10n, + SEND_MESSAGES: 1n << 11n, + SEND_TTS_MESSAGES: 1n << 12n, + MANAGE_MESSAGES: 1n << 13n, + EMBED_LINKS: 1n << 14n, + ATTACH_FILES: 1n << 15n, + READ_MESSAGE_HISTORY: 1n << 16n, + MENTION_EVERYONE: 1n << 17n, + USE_EXTERNAL_EMOJIS: 1n << 18n, + VIEW_GUILD_INSIGHTS: 1n << 19n, + CONNECT: 1n << 20n, + SPEAK: 1n << 21n, + MUTE_MEMBERS: 1n << 22n, + DEAFEN_MEMBERS: 1n << 23n, + MOVE_MEMBERS: 1n << 24n, + USE_VAD: 1n << 25n, + CHANGE_NICKNAME: 1n << 26n, + MANAGE_NICKNAMES: 1n << 27n, + MANAGE_ROLES: 1n << 28n, + MANAGE_WEBHOOKS: 1n << 29n, + MANAGE_EMOJIS: 1n << 30n, } as const; /** - * Freeze the object of bits, preventing any modifications to it. + * Freeze the object of bits, preventing any modifications to it * @internal */ Object.freeze(PermissionFlagsBits); @@ -54,19 +54,60 @@ Object.freeze(PermissionFlagsBits); * https://discord.com/developers/docs/topics/permissions#role-object */ export interface APIRole { + /** + * Role id + */ id: string; + /** + * Role name + */ name: string; + /** + * Integer representation of hexadecimal color code + */ color: number; + /** + * If this role is pinned in the user listing + */ hoist: boolean; + /** + * Position of this role + */ position: number; + /** + * Permission bit set + * + * See https://en.wikipedia.org/wiki/Bit_field + */ permissions: string; + /** + * Whether this role is managed by an integration + */ managed: boolean; + /** + * Whether this role is mentionable + */ mentionable: boolean; + /** + * The tags this role has + */ tags?: APIRoleTags; } +/** + * https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure + */ export interface APIRoleTags { + /** + * The id of the bot this role belongs to + */ bot_id?: string; + /** + * Whether this is the guild's premium subscriber role + */ premium_subscriber?: null; + /** + * The id of the integration this role belongs to + */ integration_id?: string; } diff --git a/v8/payloads/teams.ts b/v8/payloads/teams.ts index 004b096e..2b93b255 100644 --- a/v8/payloads/teams.ts +++ b/v8/payloads/teams.ts @@ -8,9 +8,21 @@ import type { APIUser } from './user'; * https://discord.com/developers/docs/topics/teams#data-models-team-object */ export interface APITeam { - id: string; + /** + * A hash of the image of the team's icon + */ icon: string | null; + /** + * The unique id of the team + */ + id: string; + /** + * The members of the team + */ members: APITeamMember[]; + /** + * The user id of the current team owner + */ owner_user_id: string; } @@ -18,9 +30,25 @@ export interface APITeam { * https://discord.com/developers/docs/topics/teams#data-models-team-members-object */ export interface APITeamMember { + /** + * The user's membership state on the team + * + * See https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum + */ membership_state: TeamMemberMembershipState; - permissions: string[]; + /** + * Will always be `["*"]` + */ + permissions: ['*']; + /** + * The id of the parent team of which they are a member + */ team_id: string; + /** + * The avatar, discriminator, id, and username of the user + * + * See https://discord.com/developers/docs/resources/user#user-object + */ user: APIUser; } diff --git a/v8/payloads/template.ts b/v8/payloads/template.ts index 5f1f2b7f..1921aab9 100644 --- a/v8/payloads/template.ts +++ b/v8/payloads/template.ts @@ -3,22 +3,57 @@ */ import type { APIUser } from './user'; -import type { RESTPostAPIGuildsJSONBody } from '../rest'; +import type { RESTPostAPIGuildsJSONBody } from '../rest/index'; /** * https://discord.com/developers/docs/resources/template#template-object */ export interface APITemplate { + /** + * The template code (unique ID) + */ code: string; + /** + * Template name + */ name: string; + /** + * The description for the template + */ description: string | null; + /** + * Number of times this template has been used + */ usage_count: number; + /** + * The ID of the user who created the template + */ creator_id: string; + /** + * The user who created the template + * + * See https://discord.com/developers/docs/resources/user#user-object + */ creator: APIUser; + /** + * When this template was created + */ created_at: string; + /** + * When this template was last synced to the source guild + */ updated_at: string; + /** + * The ID of the guild this template is based on + */ source_guild_id: string; + /** + * The guild snapshot this template contains + */ serialized_source_guild: APITemplateSerializedSourceGuild; + /** + * Whether the template has unsynced changes + */ is_dirty: boolean | null; } diff --git a/v8/payloads/user.ts b/v8/payloads/user.ts index 81babe75..55546052 100644 --- a/v8/payloads/user.ts +++ b/v8/payloads/user.ts @@ -8,18 +8,65 @@ import type { APIGuildIntegration } from './guild'; * https://discord.com/developers/docs/resources/user#user-object */ export interface APIUser { + /** + * The user's id + */ id: string; + /** + * The user's username, not unique across the platform + */ username: string; + /** + * The user's 4-digit discord-tag + */ discriminator: string; + /** + * The user's avatar hash + * + * See https://discord.com/developers/docs/reference#image-formatting + */ avatar: string | null; + /** + * Whether the user belongs to an OAuth2 application + */ bot?: boolean; + /** + * Whether the user is an Official Discord System user (part of the urgent message system) + */ system?: boolean; + /** + * Whether the user has two factor enabled on their account + */ mfa_enabled?: boolean; + /** + * The user's chosen language option + */ locale?: string; + /** + * Whether the email on this account has been verified + */ verified?: boolean; + /** + * The user's email + */ email?: string | null; + /** + * The flags on a user's account + * + * See https://discord.com/developers/docs/resources/user#user-object-user-flags + */ flags?: UserFlags; + /** + * The type of Nitro subscription on a user's account + * + * See https://discord.com/developers/docs/resources/user#user-object-premium-types + */ premium_type?: UserPremiumType; + /** + * The public flags on a user's account + * + * See https://discord.com/developers/docs/resources/user#user-object-user-flags + */ public_flags?: UserFlags; } @@ -56,18 +103,55 @@ export const enum UserPremiumType { * https://discord.com/developers/docs/resources/user#connection-object */ export interface APIConnection { + /** + * ID of the connection account + */ id: string; + /** + * The username of the connection account + */ name: string; + /** + * The service of the connection + */ type: string; + /** + * Whether the connection is revoked + */ revoked?: boolean; + /** + * An array of partial server integrations + * + * See https://discord.com/developers/docs/resources/guild#integration-object + */ integrations?: Partial[]; + /** + * Whether the connection is verified + */ verified: boolean; + /** + * Whether friend sync is enabled for this connection + */ friend_sync: boolean; + /** + * Whether activities related to this connection will be shown in presence updates + */ show_activity: boolean; + /** + * Visibility of this connection + * + * See https://discord.com/developers/docs/resources/user#connection-object-visibility-types + */ visibility: ConnectionVisibility; } export const enum ConnectionVisibility { + /** + * Invisible to everyone except the user themselves + */ None, + /** + * Visible to everyone + */ Everyone, } diff --git a/v8/payloads/voice.ts b/v8/payloads/voice.ts index 48d91e7c..7952174b 100644 --- a/v8/payloads/voice.ts +++ b/v8/payloads/voice.ts @@ -8,17 +8,55 @@ import type { APIGuildMember } from './guild'; * https://discord.com/developers/docs/resources/voice#voice-state-object */ export interface GatewayVoiceState { + /** + * The guild id this voice state is for + */ guild_id?: string; + /** + * The channel id this user is connected to + */ channel_id: string | null; + /** + * The user id this voice state is for + */ user_id: string; + /** + * The guild member this voice state is for + * + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ member?: APIGuildMember; + /** + * The session id for this voice state + */ session_id: string; + /** + * Whether this user is deafened by the server + */ deaf: boolean; + /** + * Whether this user is muted by the server + */ mute: boolean; + /** + * Whether this user is locally deafened + */ self_deaf: boolean; + /** + * Whether this user is locally muted + */ self_mute: boolean; + /** + * Whether this user is streaming using "Go Live" + */ self_stream?: boolean; + /** + * Whether this user's camera is enabled + */ self_video: boolean; + /** + * Whether this user is muted by the current user + */ suppress: boolean; } @@ -26,10 +64,28 @@ export interface GatewayVoiceState { * https://discord.com/developers/docs/resources/voice#voice-region-object */ export interface APIVoiceRegion { + /** + * Unique ID for the region + */ id: string; + /** + * Name of the region + */ name: string; + /** + * `true` if this is a vip-only server + */ vip: boolean; + /** + * `true` for a single server that is closest to the current user's client + */ optimal: boolean; + /** + * Whether this is a deprecated voice region (avoid switching to these) + */ deprecated: boolean; + /** + * Whether this is a custom voice region (used for events/etc) + */ custom: boolean; } diff --git a/v8/payloads/webhook.ts b/v8/payloads/webhook.ts index 2b77c814..2a756991 100644 --- a/v8/payloads/webhook.ts +++ b/v8/payloads/webhook.ts @@ -2,28 +2,63 @@ * Types extracted from https://discord.com/developers/docs/resources/webhook */ -import type { APIPartialChannel } from './channel'; -import type { APIPartialGuild } from './guild'; -import type { APIUser } from './user'; +import type { APIPartialChannel, APIPartialGuild, APIUser } from './index'; /** * https://discord.com/developers/docs/resources/webhook#webhook-object */ export interface APIWebhook { + /** + * The id of the webhook + */ id: string; + /** + * The type of the webhook + * + * See https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types + */ type: WebhookType; + /** + * The guild id this webhook is for + */ guild_id?: string; + /** + * The channel id this webhook is for + */ channel_id: string; + /** + * The user this webhook was created by (not returned when getting a webhook with its token) + * + * See https://discord.com/developers/docs/resources/user#user-object + */ user?: APIUser; + /** + * The default name of the webhook + */ name: string | null; + /** + * The default avatar of the webhook + */ avatar: string | null; + /** + * The secure token of the webhook (returned for Incoming Webhooks) + */ token?: string; + /** + * The bot/OAuth2 application that created this webhook + */ + application_id: string | null; source_guild?: APIPartialGuild; source_channel?: APIPartialChannel; - application_id: string | null; } export const enum WebhookType { + /** + * Incoming Webhooks can post messages to channels with a generated token + */ Incoming = 1, + /** + * Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels + */ ChannelFollower, } diff --git a/v8/rest/auditLog.ts b/v8/rest/auditLog.ts index e743a008..e5aa95e8 100644 --- a/v8/rest/auditLog.ts +++ b/v8/rest/auditLog.ts @@ -4,9 +4,23 @@ import type { APIAuditLog, AuditLogEvent } from '../payloads/auditLog'; * https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log */ export interface RESTGetAPIAuditLogQuery { + /** + * Filter the log for actions made by a user + */ user_id?: string; + /** + * The type of audit log events + */ action_type?: AuditLogEvent; + /** + * Filter the log before a certain entry ID + */ before?: string; + /** + * How many entries are returned (default 50, minimum 1, maximum 100) + * + * @default 50 + */ limit?: number; } diff --git a/v8/rest/channel.ts b/v8/rest/channel.ts index 939b4b33..a58acfaa 100644 --- a/v8/rest/channel.ts +++ b/v8/rest/channel.ts @@ -1,8 +1,9 @@ import type { + APIAllowedMentions, APIChannel, APIEmbed, + APIExtendedInvite, APIFollowedChannel, - APIInvite, APIMessage, APIMessageReference, APIOverwrite, @@ -11,74 +12,162 @@ import type { InviteTargetUserType, MessageFlags, OverwriteType, -} from '../payloads'; - -// #region TypeDefs +} from '../payloads/index'; /** - * https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types + * https://discord.com/developers/docs/resources/channel#get-channel */ -export const enum AllowedMentionsTypes { - Everyone = 'everyone', - Role = 'roles', - User = 'users', -} - -/** - * https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mentions-structure - */ -export interface APIAllowedMentionsSend { - parse?: AllowedMentionsTypes[]; - roles?: string[]; - users?: string[]; - replied_user?: boolean; -} - -// #endregion TypeDefs +export type RESTGetAPIChannelResult = APIChannel; /** * https://discord.com/developers/docs/resources/channel#modify-channel */ export interface RESTPatchAPIChannelJSONBody { + /** + * 2-100 character channel name + * + * Channel types: all + */ name?: string; + + /** + * The type of channel; only conversion between `text` and `news` + * is supported and only in guilds with the "NEWS" feature + * + * Channel types: text, news + */ type?: ChannelType.GUILD_NEWS | ChannelType.GUILD_TEXT; + /** + * The position of the channel in the left-hand listing + * + * Channel types: all + */ position?: number | null; + /** + * 0-1024 character channel topic + * + * Channel types: text, news + */ topic?: string | null; + /** + * Whether the channel is nsfw + * + * Channel types: text, news, store + */ nsfw?: boolean | 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 + * + * Channel types: text + */ rate_limit_per_user?: number | null; + /** + * The bitrate (in bits) of the voice channel; 8000 to 96000 (128000 for VIP servers) + * + * Channel types: voice + */ bitrate?: number | null; + /** + * The user limit of the voice channel; 0 refers to no limit, 1 to 99 refers to a user limit + * + * Channel types: voice + */ user_limit?: number | null; + /** + * Channel or category-specific permissions + * + * Channel types: all + */ permission_overwrites?: APIOverwrite[] | null; + /** + * ID of the new parent category for a channel + * + * Channel types: text, news, store, voice + */ parent_id?: string | null; } -export type RESTGetAPIChannelResult = APIChannel; +/** + * https://discord.com/developers/docs/resources/channel#modify-channel + */ export type RESTPatchAPIChannelResult = APIChannel; + +/** + * https://discord.com/developers/docs/resources/channel#deleteclose-channel + */ export type RESTDeleteAPIChannelResult = APIChannel; /** * https://discord.com/developers/docs/resources/channel#get-channel-messages */ export interface RESTGetAPIChannelMessagesQuery { + /** + * Get messages around this message ID + */ around?: string; + /** + * Get messages before this message ID + */ before?: string; + /** + * Get messages after this message ID + */ after?: string; + /** + * Max number of messages to return (1-100) + * + * @default 50 + */ limit?: number; } +/** + * https://discord.com/developers/docs/resources/channel#get-channel-messages + */ export type RESTGetAPIChannelMessagesResult = APIMessage[]; -export type APIMessageReferenceSend = APIMessageReference & Required>; +/** + * https://discord.com/developers/docs/resources/channel#get-channel-message + */ +export type RESTGetAPIChannelMessageResult = APIMessage; + +export type APIMessageReferenceSend = Partial & Required>; /** * https://discord.com/developers/docs/resources/channel#create-message */ export interface RESTPostAPIChannelMessageJSONBody { + /** + * The message contents (up to 2000 characters) + */ content?: string; + /** + * A nonce that can be used for optimistic message sending + */ nonce?: number | string; - tts?: boolean; + /** + * `true` if this is a TTS message + */ + tts?: true; + /** + * Embedded `rich` content + * + * See https://discord.com/developers/docs/resources/channel#embed-object + */ embed?: APIEmbed; - allowed_mentions?: APIAllowedMentionsSend; + /** + * Allowed mentions for a message + * + * See https://discord.com/developers/docs/resources/channel#allowed-mentions-object + */ + allowed_mentions?: APIAllowedMentions; + /** + * Include to make your message a reply + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure + */ message_reference?: APIMessageReferenceSend; } @@ -96,84 +185,219 @@ export type RESTPostAPIChannelMessageFormDataBody = */ file: unknown; } - | { - content?: string; - nonce?: number | string; - tts?: boolean; - embed?: APIEmbed; - allowed_mentions?: APIAllowedMentionsSend; - message_reference?: APIMessageReferenceSend; + | (RESTPostAPIChannelMessageJSONBody & { /** * The file contents */ file: unknown; - }; + }); + +/** + * https://discord.com/developers/docs/resources/channel#create-message + */ +export type RESTPostAPIChannelMessageResult = APIMessage; + +/** + * https://discord.com/developers/docs/resources/channel#crosspost-message + */ +export type RESTPostAPIChannelMessageCrosspostResult = APIMessage; + +/** + * https://discord.com/developers/docs/resources/channel#create-reaction + */ +export type RESTPutAPIChannelMessageReactionResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#delete-own-reaction + */ +export type RESTDeleteAPIChannelMessageOwnReaction = never; + +/** + * https://discord.com/developers/docs/resources/channel#delete-user-reaction + */ +export type RESTDeleteAPIChannelMessageUserReactionResult = never; + +/* + * https://discord.com/developers/docs/resources/channel#get-reactions + */ +export interface RESTGetAPIChannelMessageReactionUsersQuery { + /** + * Get users before this user ID + */ + before?: string; + /** + * Get users after this user ID + */ + after?: string; + /** + * Max number of users to return (1-100) + * + * @default 25 + */ + limit?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#get-reactions + */ +export type RESTGetAPIChannelMessageReactionUsersResult = APIUser[]; + +/** + * https://discord.com/developers/docs/resources/channel#delete-all-reactions + */ +export type RESTDeleteAPIChannelAllMessageReactionsResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#delete-all-reactions-for-emoji + */ +export type RESTDeleteAPIChannelMessageReactionResult = never; /** * https://discord.com/developers/docs/resources/channel#edit-message */ export interface RESTPatchAPIChannelMessageJSONBody { + /** + * The new message contents (up to 2000 characters) + */ content?: string | null; + /** + * Embedded `rich` content + */ embed?: APIEmbed | null; - allowed_mentions?: APIAllowedMentionsSend | null; + /** + * Edit the flags of a message (only `SUPPRESS_EMBEDS` can currently be set/unset) + * + * When specifying flags, ensure to include all previously set flags/bits + * in addition to ones that you are modifying + */ flags?: MessageFlags | null; + /** + * Allowed mentions for the message + */ + allowed_mentions?: APIAllowedMentions | null; } -export type RESTGetAPIChannelMessageResult = APIMessage; -export type RESTPostAPIChannelMessageResult = APIMessage; -export type RESTPatchAPIChannelMessageResult = APIMessage; -export type RESTDeleteAPIChannelMessageResult = never; - /** - * https://discord.com/developers/docs/resources/channel#get-reactions + * https://discord.com/developers/docs/resources/channel#edit-message */ -export interface RESTGetAPIChannelMessageReactionsQuery { - before?: string; - after?: string; - limit?: number; -} +export type RESTPatchAPIChannelMessageResult = APIMessage; -export type RESTGetAPIChannelMessageReactionsResult = APIUser[]; - -export type RESTPutAPIChannelMessageReactionResult = never; -export type RESTDeleteAPIChannelMessageReactionResult = never; -export type RESTDeleteAPIChannelAllMessageReactionsResult = never; +/** + * https://discord.com/developers/docs/resources/channel#delete-message + */ +export type RESTDeleteAPIChannelMessageResult = never; /** * https://discord.com/developers/docs/resources/channel#bulk-delete-messages */ export interface RESTPostAPIChannelMessagesBulkDeleteJSONBody { + /** + * An array of message ids to delete (2-100) + */ messages: string[]; } +/** + * https://discord.com/developers/docs/resources/channel#bulk-delete-messages + */ export type RESTPostAPIChannelMessagesBulkDeleteResult = never; /** * https://discord.com/developers/docs/resources/channel#edit-channel-permissions */ -export interface RESTPutAPIChannelPermissionsJSONBody { +export interface RESTPutAPIChannelPermissionJSONBody { + /** + * The bitwise value of all allowed permissions + * + * See https://en.wikipedia.org/wiki/Bit_field + */ allow: string; + /** + * The bitwise value of all disallowed permissions + * + * See https://en.wikipedia.org/wiki/Bit_field + */ deny: string; + /** + * `0` for a role or `1` for a member + */ type: OverwriteType; } -export type RESTPutAPIChannelPermissionsResult = never; -export type RESTDeleteAPIChannelPermissionsResult = never; +/** + * https://discord.com/developers/docs/resources/channel#edit-channel-permissions + */ +export type RESTPutAPIChannelPermissionResult = never; /** * https://discord.com/developers/docs/resources/channel#get-channel-invites */ -export type RESTGetAPIChannelInvitesResult = APIInvite[]; +export type RESTGetAPIChannelInvitesResult = APIExtendedInvite[]; +/** + * https://discord.com/developers/docs/resources/channel#create-channel-invite + */ export interface RESTPostAPIChannelInviteJSONBody { + /** + * Duration of invite in seconds before expiry, or 0 for never + * + * @default 86400 (24 hours) + */ max_age?: number; + /** + * Max number of uses or 0 for unlimited + * + * @default 0 + */ max_uses?: number; + /** + * Whether this invite only grants temporary membership + * + * @default false + */ temporary?: boolean; + /** + * If true, don't try to reuse a similar invite + * (useful for creating many unique one time use invites) + * + * @default false + */ unique?: boolean; + /** + * The target user id for this invite + */ target_user_id?: string; + /** + * The type of target user for this invite + */ target_user_type?: InviteTargetUserType; } +/** + * https://discord.com/developers/docs/resources/channel#create-channel-invite + */ +export type RESTPostAPIChannelInviteResult = APIExtendedInvite; + +/** + * https://discord.com/developers/docs/resources/channel#delete-channel-permission + */ +export type RESTDeleteAPIChannelPermissionResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#follow-news-channel + */ +export interface RESTPostAPIChannelFollowersJSONBody { + /** + * ID of target channel + */ + webhook_channel_id: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#follow-news-channel + */ +export type RESTPostAPIChannelFollowersResult = APIFollowedChannel; + /** * https://discord.com/developers/docs/resources/channel#trigger-typing-indicator */ @@ -188,32 +412,32 @@ export type RESTGetAPIChannelPinsResult = APIMessage[]; * https://discord.com/developers/docs/resources/channel#add-pinned-channel-message */ export type RESTPutAPIChannelPinResult = never; + +/** + * https://discord.com/developers/docs/resources/channel#delete-pinned-channel-message + */ export type RESTDeleteAPIChannelPinResult = never; /** * https://discord.com/developers/docs/resources/channel#group-dm-add-recipient */ export interface RESTPutAPIChannelRecipientJSONBody { + /** + * Access token of a user that has granted your app the `gdm.join` scope + */ access_token: string; + /** + * Nickname of the user being added + */ nick?: string; } +/** + * https://discord.com/developers/docs/resources/channel#group-dm-add-recipient + */ export type RESTPutAPIChannelRecipientResult = unknown; + +/** + * https://discord.com/developers/docs/resources/channel#group-dm-remove-recipient + */ export type RESTDeleteAPIChannelRecipientResult = unknown; - -/** - * https://discord.com/developers/docs/resources/channel#crosspost-message - */ -export type RESTPostAPIChannelMessageCrosspostResult = APIMessage; - -/** - * https://discord.com/developers/docs/resources/channel#follow-news-channel - */ -export interface RESTPostAPIChannelFollowersJSONBody { - webhook_channel_id: string; -} - -/** - * https://discord.com/developers/docs/resources/channel#follow-news-channel - */ -export type RESTPostAPIChannelFollowersResult = APIFollowedChannel; diff --git a/v8/rest/emoji.ts b/v8/rest/emoji.ts index eac614ae..ac469fc1 100644 --- a/v8/rest/emoji.ts +++ b/v8/rest/emoji.ts @@ -1,4 +1,4 @@ -import type { APIEmoji } from '../payloads'; +import type { APIEmoji } from '../payloads/index'; /** * https://discord.com/developers/docs/resources/emoji#list-guild-emojis @@ -14,24 +14,44 @@ export type RESTGetAPIGuildEmojiResult = APIEmoji; * https://discord.com/developers/docs/resources/emoji#create-guild-emoji-json-params */ export interface RESTPostAPIGuildEmojiJSONBody { + /** + * Name of the emoji + */ name: string; /** - * The image data, read more [here](https://discord.com/developers/docs/reference#image-data) + * The 128x128 emoji image + * + * https://discord.com/developers/docs/reference#image-data */ image: string; + /** + * Roles for which this emoji will be whitelisted + */ roles?: string[]; } +/** + * https://discord.com/developers/docs/resources/emoji#create-guild-emoji + */ export type RESTPostAPIGuildEmojiResult = APIEmoji; /** * https://discord.com/developers/docs/resources/emoji#modify-guild-emoji */ export interface RESTPatchAPIGuildEmojiJSONBody { + /** + * Name of the emoji + */ name?: string; + /** + * Roles for which this emoji will be whitelisted + */ roles?: string[] | null; } +/** + * https://discord.com/developers/docs/resources/emoji#modify-guild-emoji + */ export type RESTPatchAPIGuildEmojiResult = APIEmoji; /** diff --git a/v8/rest/gateway.ts b/v8/rest/gateway.ts index d8f53873..fa0fa720 100644 --- a/v8/rest/gateway.ts +++ b/v8/rest/gateway.ts @@ -1,4 +1,4 @@ -import type { APIGatewayBotInfo, APIGatewayInfo } from '../payloads'; +import type { APIGatewayBotInfo, APIGatewayInfo } from '../payloads/index'; /** * https://discord.com/developers/docs/topics/gateway#get-gateway diff --git a/v8/rest/guild.ts b/v8/rest/guild.ts index b9c4a6d3..18426ce4 100644 --- a/v8/rest/guild.ts +++ b/v8/rest/guild.ts @@ -1,13 +1,14 @@ import type { APIBan, APIChannel, + APIExtendedInvite, APIGuild, APIGuildIntegration, APIGuildMember, + APIGuildMembershipScreening, APIGuildPreview, APIGuildWidget, APIGuildWidgetSettings, - APIInvite, APIRole, APIVoiceRegion, GuildDefaultMessageNotifications, @@ -17,10 +18,10 @@ import type { GuildVerificationLevel, GuildWidgetStyle, IntegrationExpireBehavior, -} from '../payloads'; -import type { RESTPutAPIChannelPermissionsJSONBody } from './channel'; +} from '../payloads/index'; +import type { RESTPutAPIChannelPermissionJSONBody } from './channel'; -export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionsJSONBody { +export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionJSONBody { id: number | string; } @@ -41,29 +42,106 @@ export interface APIGuildCreateRole extends RESTPostAPIGuildRoleJSONBody { * https://discord.com/developers/docs/resources/guild#create-guild */ export interface RESTPostAPIGuildsJSONBody { + /** + * Name of the guild (2-100 characters) + */ name: string; + /** + * Voice region id + * + * See https://discord.com/developers/docs/resources/voice#voice-region-object + */ region?: string; + /** + * base64 1024x1024 png/jpeg image for the guild icon + * + * See https://discord.com/developers/docs/reference#image-data + */ icon?: string; + /** + * Verification level + * + * See https://discord.com/developers/docs/resources/guild#guild-object-verification-level + */ verification_level?: GuildVerificationLevel; + /** + * Default message notification level + * + * See https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level + */ default_message_notifications?: GuildDefaultMessageNotifications; + /** + * Explicit content filter level + * + * See https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level + */ explicit_content_filter?: GuildExplicitContentFilter; + /** + * New guild roles + * + * **When using this parameter, the first member of the array is used to change properties of the guild's @everyone role. + * If you are trying to bootstrap a guild with additional roles, keep this in mind.** + * + * *When using this parameter, the required `id` field within each role object is an integer placeholder, + * and will be replaced by the API upon consumption. Its purpose is to allow you to overwrite a role's permissions + * in a channel when also passing in channels with the channels array.* + * + * See https://discord.com/developers/docs/topics/permissions#role-object + */ roles?: APIGuildCreateRole[]; + /** + * New guild's channels + * + * **When using the channels parameter, the `position` field is ignored, and none of the default channels are created.** + * + * *When using the channels parameter, the `id` field within each channel object may be set to an integer placeholder, + * and will be replaced by the API upon consumption. Its purpose is to allow you to create `GUILD_CATEGORY` channels + * by setting the `parent_id` field on any children to the category's id field. + * Category channels must be listed before any children.* + * + * See https://discord.com/developers/docs/resources/channel#channel-object + */ channels?: APIGuildCreatePartialChannel[]; + /** + * ID for afk channel + */ afk_channel_id?: number | string; + /** + * AFK timeout in seconds + */ afk_timeout?: number; + /** + * The id of the channel where guild notices such as welcome messages and boost events are posted + */ system_channel_id?: number | string; + /** + * System channel flags + * + * See https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags + */ system_channel_flags?: GuildSystemChannelFlags; } +/** + * https://discord.com/developers/docs/resources/guild#create-guild + */ export type RESTPostAPIGuildsResult = APIGuild; /** * https://discord.com/developers/docs/resources/guild#get-guild */ export interface RESTGetAPIGuildQuery { + /** + * When `true`, will return approximate member and presence counts for the guild + * + * @default false + */ with_counts?: boolean; } +/** + * https://discord.com/developers/docs/resources/guild#get-guild + */ export type RESTGetAPIGuildResult = APIGuild; /** @@ -75,27 +153,105 @@ export type RESTGetAPIGuildPreviewResult = APIGuildPreview; * https://discord.com/developers/docs/resources/guild#modify-guild */ export interface RESTPatchAPIGuildJSONBody { + /** + * New name for the guild (2-100 characters) + */ name?: string; + /** + * Voice region id + * + * See https://discord.com/developers/docs/resources/voice#voice-region-object + */ region?: string | null; + /** + * Verification level + * + * See https://discord.com/developers/docs/resources/guild#guild-object-verification-level + */ verification_level?: GuildVerificationLevel | null; + /** + * Default message notification level + * + * See https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level + */ default_message_notifications?: GuildDefaultMessageNotifications | null; + /** + * Explicit content filter level + * + * See https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level + */ explicit_content_filter?: GuildExplicitContentFilter | null; + /** + * ID for afk channel + */ afk_channel_id?: string | null; + /** + * AFK timeout in seconds + */ afk_timeout?: number; + /** + * base64 1024x1024 png/jpeg/gif image for the guild icon (can be animated gif when the guild has `ANIMATED_ICON` feature) + * + * See https://discord.com/developers/docs/reference#image-data + */ icon?: string | null; + /** + * User id to transfer guild ownership to (must be owner) + */ owner_id?: string; + /** + * base64 16:9 png/jpeg image for the guild splash (when the guild has `INVITE_SPLASH` feature) + * + * See https://discord.com/developers/docs/reference#image-data + */ splash?: string | null; + /** + * base64 png/jpeg image for the guild discovery splash (when the guild has `DISCOVERABLE` feature) + */ discovery_splash?: string | null; + /** + * base64 16:9 png/jpeg image for the guild banner (when the guild has `BANNER` feature) + */ banner?: string | null; + /** + * The id of the channel where guild notices such as welcome messages and boost events are posted + */ system_channel_id?: string | null; + /** + * System channel flags + * + * See https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags + */ system_channel_flags?: GuildSystemChannelFlags; + /** + * The id of the channel where Community guilds display rules and/or guidelines + */ rules_channel_id?: string | null; + /** + * The id of the channel where admins and moderators of Community guilds receive notices from Discord + */ public_updates_channel_id?: string | null; + /** + * The preferred locale of a Community guild used in server discovery and notices from Discord; defaults to "en-US" + * + * @default "en-US" (if the value is set to `null`) + */ preferred_locale?: string | null; + /** + * Enabled guild features + * + * See https://discord.com/developers/docs/resources/guild#guild-object-guild-features + */ features?: GuildFeature[]; + /** + * The description for the guild, if the guild is discoverable + */ description?: string | null; } +/** + * https://discord.com/developers/docs/resources/guild#modify-guild + */ export type RESTPatchAPIGuildResult = APIGuild; /** @@ -111,20 +267,38 @@ export type RESTGetAPIGuildChannelsResult = APIChannel[]; /** * https://discord.com/developers/docs/resources/guild#create-guild-channel */ -export type RESTPostAPIGuildChannelJSONBody = APIGuildCreatePartialChannel; +export type RESTPostAPIGuildChannelJSONBody = Omit; +/** + * https://discord.com/developers/docs/resources/guild#create-guild-channel + */ export type RESTPostAPIGuildChannelResult = APIChannel; /** * https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions */ export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{ + /** + * Channel id + */ id: string; + /** + * Sorting position of the channel + */ position: number; + /** + * Sync channel overwrites with the new parent, when moving to a new `parent_id` + */ lock_permissions?: boolean; + /** + * The new parent id of this channel + */ parent_id?: string | null; }>; +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions + */ export type RESTPatchAPIGuildChannelPositionsResult = never; /** @@ -136,14 +310,35 @@ export type RESTGetAPIGuildMemberResult = APIGuildMember; * https://discord.com/developers/docs/resources/guild#list-guild-members */ export interface RESTGetAPIGuildMembersQuery { + /** + * Max number of members to return (1-1000) + * + * @default 1 + */ limit?: number; + /** + * The highest user id in the previous page + * + * @default 0 + */ after?: string; } +/** + * https://discord.com/developers/docs/resources/guild#list-guild-members + */ export type RESTGetAPIGuildMembersResult = APIGuildMember[]; export interface RESTGetAPIGuildMembersSearchQuery { + /** + * Query string to match username(s) and nickname(s) against + */ query: string; + /** + * Max number of members to return (1-1000) + * + * @default 1 + */ limit?: number; } @@ -153,10 +348,33 @@ export type RESTGetAPIGuildMembersSearchResult = APIGuildMember[]; * https://discord.com/developers/docs/resources/guild#add-guild-member */ export interface RESTPutAPIGuildMemberJSONBody { + /** + * An oauth2 access token granted with the `guilds.join` to the bot's application for the user you want to add to the guild + */ access_token: string; + /** + * Value to set users nickname to + * + * Requires `MANAGE_NICKNAMES` permission + */ nick?: string; + /** + * Array of role ids the member is assigned + * + * Requires `MANAGE_ROLES` permission + */ roles?: string[]; + /** + * Whether the user is muted in voice channels + * + * Requires `MUTE_MEMBERS` permission + */ mute?: boolean; + /** + * Whether the user is deafened in voice channels + * + * Requires `DEAFEN_MEMBERS` permission + */ deaf?: boolean; } @@ -166,22 +384,58 @@ export type RESTPutAPIGuildMemberResult = APIGuildMember | undefined; * https://discord.com/developers/docs/resources/guild#modify-guild-member */ export interface RESTPatchAPIGuildMemberJSONBody { + /** + * Value to set users nickname to + * + * Requires `MANAGE_NICKNAMES` permission + */ nick?: string | null; + /** + * Array of role ids the member is assigned + * + * Requires `MANAGE_ROLES` permission + */ roles?: string[] | null; + /** + * Whether the user is muted in voice channels. Will throw a 400 if the user is not in a voice channel + * + * Requires `MUTE_MEMBERS` permission + */ mute?: boolean | null; + /** + * Whether the user is deafened in voice channels. Will throw a 400 if the user is not in a voice channel + * + * Requires `DEAFEN_MEMBERS` permission + */ deaf?: boolean | null; + /** + * ID of channel to move user to (if they are connected to voice) + * + * Requires `MOVE_MEMBERS` permission + */ channel_id?: string | null; } +/** + * https://discord.com/developers/docs/resources/guild#add-guild-member + */ export type RESTPatchAPIGuildMemberResult = APIGuildMember; /** * https://discord.com/developers/docs/resources/guild#modify-current-user-nick */ export interface RESTPatchAPICurrentGuildMemberNicknameJSONBody { + /** + * Value to set users nickname to + * + * Requires `CHANGE_NICKNAME` permission + */ nick?: string | null; } +/** + * https://discord.com/developers/docs/resources/guild#modify-current-user-nick + */ export type RESTPatchAPICurrentGuildMemberNicknameResult = Required; /** @@ -213,10 +467,19 @@ export type RESTGetAPIGuildBanResult = APIBan; * https://discord.com/developers/docs/resources/guild#create-guild-ban */ export interface RESTPutAPIGuildBanJSONBody { + /** + * Number of days to delete messages for (0-7) + */ delete_message_days?: number; + /** + * Reason for the ban + */ reason?: string; } +/** + * https://discord.com/developers/docs/resources/guild#create-guild-ban + */ export type RESTPutAPIGuildBanResult = never; /** @@ -233,36 +496,91 @@ export type RESTGetAPIGuildRolesResult = APIRole[]; * https://discord.com/developers/docs/resources/guild#create-guild-role */ export interface RESTPostAPIGuildRoleJSONBody { + /** + * Name of the role + * + * @default "new role" + */ name?: string | null; + /** + * Bitwise value of the enabled/disabled permissions + * + * @default "​default role permissions in guild" + */ permissions?: string | null; + /** + * RGB color value + * + * @default 0 + */ color?: number | null; + /** + * Whether the role should be displayed separately in the sidebar + * + * @default false + */ hoist?: boolean | null; + /** + * Whether the role should be mentionable + * + * @default false + */ mentionable?: boolean | null; } +/** + * https://discord.com/developers/docs/resources/guild#create-guild-role + */ export type RESTPostAPIGuildRoleResult = APIRole; /** * https://discord.com/developers/docs/resources/guild#modify-guild-role-positions */ export type RESTPatchAPIGuildRolePositionsJSONBody = Array<{ + /** + * Role id + */ id: string; + /** + * Sorting position of the role + */ position?: number; }>; +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-role-positions + */ export type RESTPatchAPIGuildRolePositionsResult = APIRole[]; /** * https://discord.com/developers/docs/resources/guild#modify-guild-role */ export interface RESTPatchAPIGuildRoleJSONBody { - name?: string; - permissions?: string; - color?: number; - hoist?: boolean; - mentionable?: boolean; + /** + * Name of the role + */ + name?: string | null; + /** + * Bitwise value of the enabled/disabled permissions + */ + permissions?: string | null; + /** + * RGB color value + */ + color?: number | null; + /** + * Whether the role should be displayed separately in the sidebar + */ + hoist?: boolean | null; + /** + * Whether the role should be mentionable + */ + mentionable?: boolean | null; } +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-role + */ export type RESTPatchAPIGuildRoleResult = APIRole; /** @@ -274,16 +592,26 @@ export type RESTDeleteAPIGuildRoleResult = never; * https://discord.com/developers/docs/resources/guild#get-guild-prune-count */ export interface RESTGetAPIGuildPruneCountQuery { + /** + * Number of days to count prune for (1 or more) + * + * @default 7 + */ days?: number; /** - * While this is typed as a string, it represents an array of - * role IDs delimited by commas. + * Role(s) to include * - * @see https://discord.com/developers/docs/resources/guild#get-guild-prune-count-query-string-params + * While this is typed as a string, it represents an array of + * role IDs delimited by commas + * + * See https://discord.com/developers/docs/resources/guild#get-guild-prune-count-query-string-params */ include_roles?: string; } +/** + * https://discord.com/developers/docs/resources/guild#get-guild-prune-count + */ export interface RESTGetAPIGuildPruneCountResult { pruned: number; } @@ -292,11 +620,27 @@ export interface RESTGetAPIGuildPruneCountResult { * https://discord.com/developers/docs/resources/guild#begin-guild-prune */ export interface RESTPostAPIGuildPruneJSONBody { + /** + * Number of days to count prune for (1 or more) + * + * @default 7 + */ days?: number; + /** + * Whether `pruned is returned, discouraged for large guilds + * + * @default true + */ compute_prune_count?: boolean; + /** + * Role(s) to include + */ include_roles?: string[]; } +/** + * https://discord.com/developers/docs/resources/guild#begin-guild-prune + */ export interface RESTPostAPIGuildPruneResult { pruned: number | null; } @@ -309,8 +653,11 @@ export type RESTGetAPIGuildVoiceRegionsResult = APIVoiceRegion[]; /** * https://discord.com/developers/docs/resources/guild#get-guild-invites */ -export type RESTGetAPIGuildInvitesResult = APIInvite[]; +export type RESTGetAPIGuildInvitesResult = APIExtendedInvite[]; +/** + * https://discord.com/developers/docs/resources/guild#get-guild-integrations + */ export type RESTGetAPIGuildIntegrationsResult = APIGuildIntegration[]; /** @@ -327,11 +674,25 @@ export type RESTPostAPIGuildIntegrationResult = never; * https://discord.com/developers/docs/resources/guild#modify-guild-integration */ export interface RESTPatchAPIGuildIntegrationJSONBody { + /** + * The behavior when an integration subscription lapses + * + * See https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors + */ expire_behavior?: IntegrationExpireBehavior | null; + /** + * Period (in days) where the integration will ignore lapsed subscriptions + */ expire_grace_period?: number | null; + /** + * Whether emoticons should be synced for this integration (`twitch` only currently) + */ enable_emoticons?: boolean | null; } +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-integration + */ export type RESTPatchAPIGuildIntegrationResult = never; /** @@ -354,12 +715,15 @@ export type RESTGetAPIGuildWidgetSettingsResult = APIGuildWidgetSettings; */ export type RESTPatchAPIGuildWidgetSettingsJSONBody = Partial; +/** + * https://discord.com/developers/docs/resources/guild#modify-guild-widget + */ export type RESTPatchAPIGuildWidgetSettingsResult = APIGuildWidgetSettings; /** * https://discord.com/developers/docs/resources/guild#get-guild-widget */ -export type RESTGetAPIGuildWidgetResult = APIGuildWidget; +export type RESTGetAPIGuildWidgetJSONResult = APIGuildWidget; /** * https://discord.com/developers/docs/resources/guild#get-guild-vanity-url @@ -373,6 +737,11 @@ export interface RESTGetAPIGuildVanityUrlResult { * https://discord.com/developers/docs/resources/guild#get-guild-widget-image */ export interface RESTGetAPIGuildWidgetImageQuery { + /** + * Style of the widget image returned + * + * @default "shield" + */ style?: GuildWidgetStyle; } @@ -381,3 +750,22 @@ export interface RESTGetAPIGuildWidgetImageQuery { * a buffer of sorts (depends if in browser or on node.js/deno). */ export type RESTGetAPIGuildWidgetImageResult = ArrayBuffer; + +export type RESTGetAPIGuildMemberVerificationResult = APIGuildMembershipScreening; + +export interface RESTPatchAPIGuildMemberVerificationJSONBody { + /** + * Whether Membership Screening is enabled + */ + enabled?: boolean; + /** + * Array of field objects serialized in a string + */ + form_fields?: string; + /** + * The server description to show in the screening form + */ + description?: string | null; +} + +export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening; diff --git a/v8/rest/index.ts b/v8/rest/index.ts index 31d9f5ca..a5e0da04 100644 --- a/v8/rest/index.ts +++ b/v8/rest/index.ts @@ -63,7 +63,7 @@ export const Routes = { * - PUT `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me` * - DELETE `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me` * - * **Note**: You need to URL encode the emoji yourself. + * **Note**: You need to URL encode the emoji yourself */ channelMessageOwnReaction(channelID: string, messageID: string, emoji: string) { return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me`; @@ -73,7 +73,7 @@ export const Routes = { * Route for: * - DELETE `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/{user.id}` * - * **Note**: You need to URL encode the emoji yourself. + * **Note**: You need to URL encode the emoji yourself */ channelMessageUserReaction(channelID: string, messageID: string, emoji: string, userID: string) { return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}`; @@ -84,7 +84,7 @@ export const Routes = { * - GET `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}` * - DELETE `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}` * - * **Note**: You need to URL encode the emoji yourself. + * **Note**: You need to URL encode the emoji yourself */ channelMessageReaction(channelID: string, messageID: string, emoji: string) { return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}`; @@ -572,6 +572,7 @@ export const Routes = { }, /** + * Route for: * - PATCH `/applications/{application.id}/commands/{command.id}` * - DELETE `/applications/{application.id}/commands/{command.id}` */ @@ -589,6 +590,7 @@ export const Routes = { }, /** + * Route for: * - PATCH `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}` * - DELETE `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}` */ @@ -603,4 +605,28 @@ export const Routes = { interactionCallback(interactionID: string, interactionToken: string) { return `/interactions/${interactionID}/${interactionToken}/callback`; }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/member-verification` + * - PATCH `/guilds/{guild.id}/member-verification` + */ + guildMemberVerification(guildID: string) { + return `/guilds/${guildID}/member-verification`; + }, }; + +export const OAuth2Routes = { + authorizationURL: `https://discord.com/api/v${APIVersion}/oauth2/authorize`, + tokenURL: `https://discord.com/api/v${APIVersion}/oauth2/token`, + /** + * See https://tools.ietf.org/html/rfc7009 + */ + tokenRevocationURL: `https://discord.com/api/v${APIVersion}/oauth2/token/revoke`, +} as const; + +/** + * Freeze route object + * @internal + */ +Object.freeze(OAuth2Routes); diff --git a/v8/rest/interactions.ts b/v8/rest/interactions.ts index 2bcee8e3..f3fc7525 100644 --- a/v8/rest/interactions.ts +++ b/v8/rest/interactions.ts @@ -1,4 +1,4 @@ -import type { APIApplicationCommand, APIInteractionResponse } from '../payloads'; +import type { APIApplicationCommand, APIInteractionResponse } from '../payloads/index'; /** * https://discord.com/developers/docs/interactions/slash-commands#get-global-application-commands diff --git a/v8/rest/invite.ts b/v8/rest/invite.ts index e215a680..7da16a48 100644 --- a/v8/rest/invite.ts +++ b/v8/rest/invite.ts @@ -1,9 +1,12 @@ -import type { APIInvite } from '../payloads'; +import type { APIInvite } from '../payloads/index'; /** * https://discord.com/developers/docs/resources/invite#get-invite */ export interface RESTGetAPIInviteQuery { + /** + * Whether the invite should contain approximate member counts + */ with_counts?: boolean; } diff --git a/v8/rest/oauth2.ts b/v8/rest/oauth2.ts index 9972dfac..60cf533a 100644 --- a/v8/rest/oauth2.ts +++ b/v8/rest/oauth2.ts @@ -1,4 +1,4 @@ -import type { APIApplication, APIGuild, APIWebhook } from '../payloads'; +import type { APIApplication, APIGuild, APIWebhook, OAuth2Scopes } from '../payloads/index'; /** * https://discord.com/developers/docs/topics/oauth2#get-current-application-information @@ -28,7 +28,7 @@ export interface RESTOAuth2AuthorizationQueryResult { /** * https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-redirect-url-example */ -export interface RESTPostOAuth2AccessTokenURIEncodedData { +export interface RESTPostOAuth2AccessTokenURLEncodedData { client_id: string; client_secret: string; grant_type: 'authorization_code'; @@ -51,7 +51,7 @@ export interface RESTPostOAuth2AccessTokenResult { /** * https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-refresh-token-exchange-example */ -export interface RESTPostOAuth2RefreshTokenURIEncodedData { +export interface RESTPostOAuth2RefreshTokenURLEncodedData { client_id: string; client_secret: string; grant_type: 'refresh_token'; @@ -77,31 +77,47 @@ export interface RESTOAuth2ImplicitAuthorizationQuery { /** * https://discord.com/developers/docs/topics/oauth2#implicit-grant-redirect-url-example */ -export type RESTOAuth2ImplicitAuthorizationURIFragmentResult = Omit; +export type RESTOAuth2ImplicitAuthorizationURLFragmentResult = Omit; /** * https://discord.com/developers/docs/topics/oauth2#client-credentials-grant */ -export interface RESTPostOAuth2ClientCredentialsURIEncodedData { - client_id: string; - client_secret: string; +export interface RESTPostOAuth2ClientCredentialsURLEncodedData { grant_type: 'client_credentials'; scope: string; } -export type RESTPostOAuth2ClientCredentialsResult = RESTOAuth2ImplicitAuthorizationURIFragmentResult; +export type RESTPostOAuth2ClientCredentialsResult = RESTOAuth2ImplicitAuthorizationURLFragmentResult; /** * https://discord.com/developers/docs/topics/oauth2#bot-authorization-flow-bot-auth-parameters */ export interface RESTOAuth2BotAuthorizationQuery { - client_id: string; - scope: string; /** - * The required permissions bitfield, stringified + * Your app's client id + */ + client_id: string; + /** + * Needs to include bot for the bot flow + */ + scope: + | OAuth2Scopes.Bot + | `${string}${' ' | '%20'}${OAuth2Scopes.Bot}` + | `${OAuth2Scopes.Bot}${' ' | '%20'}${string}` + | `${string}${' ' | '%20'}${OAuth2Scopes.Bot}${string}${' ' | '%20'}`; + /** + * The permissions you're requesting + * + * See https://discord.com/developers/docs/topics/permissions */ permissions?: string; + /** + * Pre-fills the dropdown picker with a guild for the user + */ guild_id?: string; + /** + * `true` or `false`—disallows the user from changing the guild dropdown + */ disable_guild_select?: boolean; } @@ -113,7 +129,11 @@ export interface RESTOAuth2AdvancedBotAuthorizationQuery { /** * This assumes you include the `bot` scope alongside others (like `identify` for example) */ - scope: string; + scope: + | OAuth2Scopes.Bot + | `${string}${' ' | '%20'}${OAuth2Scopes.Bot}` + | `${OAuth2Scopes.Bot}${' ' | '%20'}${string}` + | `${string}${' ' | '%20'}${OAuth2Scopes.Bot}${string}${' ' | '%20'}`; /** * The required permissions bitfield, stringified */ diff --git a/v8/rest/template.ts b/v8/rest/template.ts index 0aa4f5b6..d5f4673f 100644 --- a/v8/rest/template.ts +++ b/v8/rest/template.ts @@ -1,4 +1,4 @@ -import type { APIGuild, APITemplate } from '../payloads'; +import type { APIGuild, APITemplate } from '../payloads/index'; /** * https://discord.com/developers/docs/resources/template#get-template @@ -9,7 +9,15 @@ export type RESTGetAPITemplateResult = APITemplate; * https://discord.com/developers/docs/resources/template#create-guild-from-template */ export interface RESTPostAPITemplateCreateGuildJSONBody { + /** + * Name of the guild (2-100 characters) + */ name: string; + /** + * base64 1024x1024 png/jpeg image for the guild icon + * + * See https://discord.com/developers/docs/reference#image-data + */ icon?: string; } /** @@ -17,17 +25,46 @@ export interface RESTPostAPITemplateCreateGuildJSONBody { */ export type RESTPostAPITemplateCreateGuildResult = APIGuild; +/** + * https://discord.com/developers/docs/resources/template#get-guild-templates + */ export type RESTGetAPIGuildTemplatesResult = APITemplate[]; +/** + * https://discord.com/developers/docs/resources/template#create-guild-template + */ export interface RESTPostAPIGuildTemplatesJSONBody { + /** + * Name of the template (1-100 characters) + */ name: string; + /** + * Description for the template (0-120 characters) + */ description?: string | null; } + +/** + * https://discord.com/developers/docs/resources/template#create-guild-template + */ export type RESTPostAPIGuildTemplatesResult = APITemplate; +/** + * https://discord.com/developers/docs/resources/template#sync-guild-template + */ export type RESTPutAPIGuildTemplateSyncResult = APITemplate; +/** + * https://discord.com/developers/docs/resources/template#modify-guild-template + */ export type RESTPatchAPIGuildTemplateJSONBody = Partial; + +/** + * https://discord.com/developers/docs/resources/template#modify-guild-template + */ export type RESTPatchAPIGuildTemplateResult = APITemplate; +/** + * https://discord.com/developers/docs/resources/template#delete-guild-template + */ export type RESTDeleteAPIGuildTemplateResult = APITemplate; diff --git a/v8/rest/user.ts b/v8/rest/user.ts index a0774af8..821ed83e 100644 --- a/v8/rest/user.ts +++ b/v8/rest/user.ts @@ -1,4 +1,4 @@ -import type { APIChannel, APIConnection, APIUser, GuildFeature } from '../payloads'; +import type { APIChannel, APIConnection, APIUser, GuildFeature } from '../payloads/index'; /** * https://discord.com/developers/docs/resources/user#get-current-user @@ -14,18 +14,38 @@ export type RESTGetAPIUserResult = APIUser; * https://discord.com/developers/docs/resources/user#modify-current-user */ export interface RESTPatchAPICurrentUserJSONBody { + /** + * User's username, if changed may cause the user's discriminator to be randomized + */ username?: string; + /** + * If passed, modifies the user's avatar + */ avatar?: string | null; } +/** + * https://discord.com/developers/docs/resources/user#modify-current-user + */ export type RESTPatchAPICurrentUserResult = APIUser; /** * https://discord.com/developers/docs/resources/user#get-current-user-guilds */ export interface RESTGetAPICurrentUserGuildsQuery { + /** + * Get guilds before this guild ID + */ before?: string; + /** + * Get guilds after this guild ID + */ after?: string; + /** + * Max number of guilds to return (1-100) + * + * @default 100 + */ limit?: number; } @@ -38,6 +58,9 @@ export interface RESTAPIPartialCurrentUserGuild { permissions: string; } +/** + * https://discord.com/developers/docs/resources/user#get-current-user-guilds + */ export type RESTGetAPICurrentUserGuildsResult = RESTAPIPartialCurrentUserGuild[]; /** @@ -49,9 +72,15 @@ export type RESTDeleteAPICurrentUserGuildResult = never; * https://discord.com/developers/docs/resources/user#create-dm */ export interface RESTPostAPICurrentUserCreateDMChannelJSONBody { + /** + * The recipient to open a DM channel with + */ recipient_id: string; } +/** + * https://discord.com/developers/docs/resources/user#create-dm + */ export type RESTPostAPICurrentUserCreateDMChannelResult = APIChannel; /** diff --git a/v8/rest/voice.ts b/v8/rest/voice.ts index c50f4760..e6fde8f3 100644 --- a/v8/rest/voice.ts +++ b/v8/rest/voice.ts @@ -1,4 +1,4 @@ -import type { APIVoiceRegion } from '../payloads'; +import type { APIVoiceRegion } from '../payloads/index'; /** * https://discord.com/developers/docs/resources/voice#list-voice-regions diff --git a/v8/rest/webhook.ts b/v8/rest/webhook.ts index da8fa21b..60e8cc86 100644 --- a/v8/rest/webhook.ts +++ b/v8/rest/webhook.ts @@ -1,14 +1,24 @@ -import type { APIAllowedMentionsSend } from './channel'; -import type { APIEmbed, APIMessage, APIWebhook } from '../payloads'; +import type { APIAllowedMentions, APIEmbed, APIMessage, APIWebhook } from '../payloads/index'; /** * https://discord.com/developers/docs/resources/webhook#create-webhook */ export interface RESTPostAPIChannelWebhookJSONBody { + /** + * Name of the webhook (1-80 characters) + */ name: string; + /** + * Image for the default webhook avatar + * + * See https://discord.com/developers/docs/reference#image-data + */ avatar?: string | null; } +/** + * https://discord.com/developers/docs/resources/webhook#create-webhook + */ export type RESTPostAPIChannelWebhookResult = APIWebhook; /** @@ -35,11 +45,25 @@ export type RESTGetAPIWebhookWithTokenResult = Omit; * https://discord.com/developers/docs/resources/webhook#modify-webhook */ export interface RESTPatchAPIWebhookJSONBody { + /** + * The default name of the webhook + */ name?: string; + /** + * Image for the default webhook avatar + * + * See https://discord.com/developers/docs/reference#image-data + */ avatar?: string | null; + /** + * The new channel id this webhook should be moved to + */ channel_id?: string; } +/** + * https://discord.com/developers/docs/resources/webhook#modify-webhook + */ export type RESTPatchAPIWebhookResult = APIWebhook; /** @@ -47,24 +71,49 @@ export type RESTPatchAPIWebhookResult = APIWebhook; */ export type RESTPatchAPIWebhookWithTokenJSONBody = Omit; -export type RESTPatchAPIWebhookWithTokenResult = Omit; +/** + * https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token + */ +export type RESTPatchAPIWebhookWithTokenResult = RESTGetAPIWebhookWithTokenResult; /** * https://discord.com/developers/docs/resources/webhook#delete-webhook */ export type RESTDeleteAPIWebhookResult = never; + +/** + * https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token + */ export type RESTDeleteAPIWebhookWithTokenResult = never; /** * https://discord.com/developers/docs/resources/webhook#execute-webhook */ export interface RESTPostAPIWebhookWithTokenJSONBody { + /** + * The message contents (up to 2000 characters) + */ content?: string; + /** + * Override the default username of the webhook + */ username?: string; + /** + * Override the default avatar of the webhook + */ avatar_url?: string; + /** + * `true` if this is a TTS message + */ tts?: boolean; + /** + * Embedded `rich` content + */ embeds?: APIEmbed[]; - allowed_mentions?: APIAllowedMentionsSend; + /** + * Allowed mentions for the message + */ + allowed_mentions?: APIAllowedMentions; } /** @@ -92,16 +141,25 @@ export type RESTPostAPIWebhookWithTokenFormDataBody = * https://discord.com/developers/docs/resources/webhook#execute-webhook-querystring-params */ export interface RESTPostAPIWebhookWithTokenQuery { + /** + * Waits for server confirmation of message send before response, and returns the created message body + * (defaults to `false`; when `false` a message that is not saved does not return an error) + * + * @default false + */ wait?: boolean; } +/** + * https://discord.com/developers/docs/resources/webhook#execute-webhook + */ export type RESTPostAPIWebhookWithTokenResult = never; /** - * Received when a call to POST `/webhooks/{webhook.id}/{webhook.token}` receives + * Received when a call to https://discord.com/developers/docs/resources/webhook#execute-webhook receives * the `wait` query parameter set to `true` * - * @see https://discord.com/developers/docs/resources/webhook#execute-webhook-querystring-params + * See https://discord.com/developers/docs/resources/webhook#execute-webhook-querystring-params */ export type RESTPostAPIWebhookWithTokenWaitResult = APIMessage; @@ -110,12 +168,43 @@ export type RESTPostAPIWebhookWithTokenWaitResult = APIMessage; */ export type RESTPostAPIWebhookWithTokenSlackQuery = RESTPostAPIWebhookWithTokenQuery; +/** + * https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook + */ +export type RESTPostAPIWebhookWithTokenSlackResult = never; + +/** + * Received when a call to https://discord.com/developers/docs/resources/webhook#execute-webhook receives + * the `wait` query parameter set to `true` + * + * See https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook-querystring-params + */ +export type RESTPostAPIWebhookWithTokenSlackWaitResult = APIMessage; + /** * https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook-querystring-params */ export type RESTPostAPIWebhookWithTokenGitHubQuery = RESTPostAPIWebhookWithTokenQuery; -export type RESTPatchAPIWebhookWithTokenMessageJSONBody = RESTPostAPIWebhookWithTokenJSONBody; +/** + * https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook + */ +export type RESTPostAPIWebhookWithTokenGitHubResult = never; + +/** + * Received when a call to https://discord.com/developers/docs/resources/webhook#execute-webhook receives + * the `wait` query parameter set to `true` + * + * See https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook-querystring-params + */ +export type RESTPostAPIWebhookWithTokenGitHubWaitResult = APIMessage; + +/** + * https://discord.com/developers/docs/resources/webhook#edit-webhook-message + */ +export type RESTPatchAPIWebhookWithTokenMessageJSONBody = Nullable< + Pick +>; export type RESTPatchAPIWebhookWithTokenMessageFormDataBody = | { @@ -123,4 +212,11 @@ export type RESTPatchAPIWebhookWithTokenMessageFormDataBody = } | RESTPatchAPIWebhookWithTokenMessageJSONBody; +/** + * https://discord.com/developers/docs/resources/webhook#delete-webhook-message + */ export type RESTDeleteAPIWebhookWithTokenMessageResult = never; + +type Nullable = { + [P in keyof T]: T[P] | null; +};