From d009554caed6c738c4a801f00806ab7cc4ac7e16 Mon Sep 17 00:00:00 2001 From: Advaith Date: Tue, 20 Jul 2021 00:25:51 -0700 Subject: [PATCH] chore: Add more missing stuff (#160) Co-authored-by: Vlad Frangu Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> BREAKING CHANGE: `GatewayGuildMemberUpdateDispatchData#joined_at` is properly marked as nullable now BREAKING CHANGE: In v9, `thread_id` was incorrectly placed in `RESTPostAPIWebhookWithTokenJSONBody` and has been moved to `RESTPostAPIWebhookWithTokenQuery` --- deno/gateway/v8.ts | 16 +-- deno/gateway/v9.ts | 14 ++- deno/payloads/v8/_interactions/base.ts | 10 +- .../v8/_interactions/messageComponents.ts | 6 +- deno/payloads/v8/_interactions/responses.ts | 4 +- .../v8/_interactions/slashCommands.ts | 12 +- deno/payloads/v8/application.ts | 109 ++++++++++++++++++ deno/payloads/v8/channel.ts | 4 +- deno/payloads/v8/guild.ts | 2 +- deno/payloads/v8/interactions.ts | 4 +- deno/payloads/v8/invite.ts | 2 +- deno/payloads/v8/mod.ts | 1 + deno/payloads/v8/oauth2.ts | 101 ---------------- deno/payloads/v8/teams.ts | 4 + deno/payloads/v8/webhook.ts | 4 + deno/payloads/v9/_interactions/base.ts | 10 +- .../v9/_interactions/messageComponents.ts | 6 +- deno/payloads/v9/_interactions/responses.ts | 4 +- .../v9/_interactions/slashCommands.ts | 12 +- deno/payloads/v9/application.ts | 109 ++++++++++++++++++ deno/payloads/v9/channel.ts | 4 +- deno/payloads/v9/guild.ts | 2 +- deno/payloads/v9/interactions.ts | 4 +- deno/payloads/v9/invite.ts | 2 +- deno/payloads/v9/mod.ts | 1 + deno/payloads/v9/oauth2.ts | 101 ---------------- deno/payloads/v9/teams.ts | 4 + deno/payloads/v9/webhook.ts | 4 + deno/rest/common.ts | 53 ++++++++- deno/rest/v8/channel.ts | 53 ++++++++- deno/rest/v8/guild.ts | 5 +- deno/rest/v8/webhook.ts | 30 +++-- deno/rest/v9/channel.ts | 55 ++++++++- deno/rest/v9/guild.ts | 5 +- deno/rest/v9/webhook.ts | 38 ++++-- deno/utils/internals.ts | 3 + gateway/v8.ts | 16 +-- gateway/v9.ts | 14 ++- payloads/v8/_interactions/base.ts | 10 +- .../v8/_interactions/messageComponents.ts | 6 +- payloads/v8/_interactions/responses.ts | 4 +- payloads/v8/_interactions/slashCommands.ts | 12 +- payloads/v8/application.ts | 109 ++++++++++++++++++ payloads/v8/channel.ts | 4 +- payloads/v8/guild.ts | 2 +- payloads/v8/index.ts | 1 + payloads/v8/interactions.ts | 4 +- payloads/v8/invite.ts | 2 +- payloads/v8/oauth2.ts | 101 ---------------- payloads/v8/teams.ts | 4 + payloads/v8/webhook.ts | 4 + payloads/v9/_interactions/base.ts | 10 +- .../v9/_interactions/messageComponents.ts | 6 +- payloads/v9/_interactions/responses.ts | 4 +- payloads/v9/_interactions/slashCommands.ts | 12 +- payloads/v9/application.ts | 109 ++++++++++++++++++ payloads/v9/channel.ts | 4 +- payloads/v9/guild.ts | 2 +- payloads/v9/index.ts | 1 + payloads/v9/interactions.ts | 4 +- payloads/v9/invite.ts | 2 +- payloads/v9/oauth2.ts | 101 ---------------- payloads/v9/teams.ts | 4 + payloads/v9/webhook.ts | 4 + rest/common.ts | 53 ++++++++- rest/v8/channel.ts | 53 ++++++++- rest/v8/guild.ts | 5 +- rest/v8/webhook.ts | 30 +++-- rest/v9/channel.ts | 55 ++++++++- rest/v9/guild.ts | 5 +- rest/v9/webhook.ts | 38 ++++-- tsconfig.json | 2 +- utils/internals.ts | 3 + 73 files changed, 1005 insertions(+), 593 deletions(-) create mode 100644 deno/payloads/v8/application.ts create mode 100644 deno/payloads/v9/application.ts create mode 100644 deno/utils/internals.ts create mode 100644 payloads/v8/application.ts create mode 100644 payloads/v9/application.ts create mode 100644 utils/internals.ts diff --git a/deno/gateway/v8.ts b/deno/gateway/v8.ts index b714f96f..4a5e938c 100644 --- a/deno/gateway/v8.ts +++ b/deno/gateway/v8.ts @@ -25,6 +25,7 @@ import type { InviteTargetType, PresenceUpdateStatus, } from '../payloads/v8/mod.ts'; +import type { Nullable } from '../utils/internals.ts'; export * from './common.ts'; @@ -441,7 +442,7 @@ export interface GatewayReadyDispatchData { /** * Contains `id` and `flags` * - * See https://discord.com/developers/docs/topics/oauth2#application-object + * See https://discord.com/developers/docs/resources/application#application-object */ application: Pick; } @@ -734,9 +735,10 @@ export type GatewayGuildMemberUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#guild-member-update */ -export type GatewayGuildMemberUpdateDispatchData = Omit & +export type GatewayGuildMemberUpdateDispatchData = Omit & Partial> & - Required> & { + Required> & + Nullable> & { /** * The id of the guild */ @@ -1375,7 +1377,7 @@ export interface GatewayIdentifyData { /** * Presence structure for initial presence information * - * See https://discord.com/developers/docs/topics/gateway#update-status + * See https://discord.com/developers/docs/topics/gateway#update-presence */ presence?: GatewayPresenceUpdateData; /** @@ -1504,7 +1506,7 @@ export interface GatewayVoiceStateUpdateData { } /** - * https://discord.com/developers/docs/topics/gateway#update-status + * https://discord.com/developers/docs/topics/gateway#update-presence */ export interface GatewayUpdatePresence { op: GatewayOpcodes.PresenceUpdate; @@ -1512,7 +1514,7 @@ export interface GatewayUpdatePresence { } /** - * https://discord.com/developers/docs/topics/gateway#update-status-gateway-status-update-structure + * https://discord.com/developers/docs/topics/gateway#update-presence-gateway-presence-update-structure */ export interface GatewayPresenceUpdateData { /** @@ -1528,7 +1530,7 @@ export interface GatewayPresenceUpdateData { /** * The user's new status * - * See https://discord.com/developers/docs/topics/gateway#update-status-status-types + * See https://discord.com/developers/docs/topics/gateway#update-presence-status-types */ status: PresenceUpdateStatus; /** diff --git a/deno/gateway/v9.ts b/deno/gateway/v9.ts index 26c03dbf..f98280c8 100644 --- a/deno/gateway/v9.ts +++ b/deno/gateway/v9.ts @@ -28,6 +28,7 @@ import type { InviteTargetType, PresenceUpdateStatus, } from '../payloads/v9/mod.ts'; +import type { Nullable } from '../utils/internals.ts'; export * from './common.ts'; @@ -451,7 +452,7 @@ export interface GatewayReadyDispatchData { /** * Contains `id` and `flags` * - * See https://discord.com/developers/docs/topics/oauth2#application-object + * See https://discord.com/developers/docs/resources/application#application-object */ application: Pick; } @@ -744,9 +745,10 @@ export type GatewayGuildMemberUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#guild-member-update */ -export type GatewayGuildMemberUpdateDispatchData = Omit & +export type GatewayGuildMemberUpdateDispatchData = Omit & Partial> & - Required> & { + Required> & + Nullable> & { /** * The id of the guild */ @@ -1464,7 +1466,7 @@ export interface GatewayIdentifyData { /** * Presence structure for initial presence information * - * See https://discord.com/developers/docs/topics/gateway#update-status + * See https://discord.com/developers/docs/topics/gateway#update-presence */ presence?: GatewayPresenceUpdateData; /** @@ -1601,7 +1603,7 @@ export interface GatewayUpdatePresence { } /** - * https://discord.com/developers/docs/topics/gateway#update-status-gateway-status-update-structure + * https://discord.com/developers/docs/topics/gateway#update-presence-gateway-presence-update-structure */ export interface GatewayPresenceUpdateData { /** @@ -1617,7 +1619,7 @@ export interface GatewayPresenceUpdateData { /** * The user's new status * - * See https://discord.com/developers/docs/topics/gateway#update-status-status-types + * See https://discord.com/developers/docs/topics/gateway#update-presence-status-types */ status: PresenceUpdateStatus; /** diff --git a/deno/payloads/v8/_interactions/base.ts b/deno/payloads/v8/_interactions/base.ts index c411bf84..0608200c 100644 --- a/deno/payloads/v8/_interactions/base.ts +++ b/deno/payloads/v8/_interactions/base.ts @@ -1,8 +1,8 @@ -import { Permissions, Snowflake } from '../../../globals.ts'; -import { InteractionType } from '../../v8.ts'; -import { APIMessage } from '../channel.ts'; -import { APIGuildMember } from '../guild.ts'; -import { APIUser } from '../user.ts'; +import type { Permissions, Snowflake } from '../../../globals.ts'; +import type { InteractionType } from '../../v8.ts'; +import type { APIMessage } from '../channel.ts'; +import type { APIGuildMember } from '../guild.ts'; +import type { APIUser } from '../user.ts'; /** * https://discord.com/developers/docs/interactions/slash-commands#message-interaction-object-message-interaction-structure diff --git a/deno/payloads/v8/_interactions/messageComponents.ts b/deno/payloads/v8/_interactions/messageComponents.ts index c6032be5..d6f62305 100644 --- a/deno/payloads/v8/_interactions/messageComponents.ts +++ b/deno/payloads/v8/_interactions/messageComponents.ts @@ -1,6 +1,6 @@ -import { ComponentType } from '../channel.ts'; -import { APIBaseInteraction, InteractionType } from '../interactions.ts'; -import { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts'; +import type { ComponentType } from '../channel.ts'; +import type { APIBaseInteraction, InteractionType } from '../interactions.ts'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts'; export type APIMessageComponentInteraction = APIBaseInteraction< InteractionType.MessageComponent, diff --git a/deno/payloads/v8/_interactions/responses.ts b/deno/payloads/v8/_interactions/responses.ts index 3a36dda6..fe47b6f9 100644 --- a/deno/payloads/v8/_interactions/responses.ts +++ b/deno/payloads/v8/_interactions/responses.ts @@ -1,5 +1,5 @@ -import { MessageFlags } from '../mod.ts'; -import { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v8.ts'; +import type { MessageFlags } from '../mod.ts'; +import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v8.ts'; /** * https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type diff --git a/deno/payloads/v8/_interactions/slashCommands.ts b/deno/payloads/v8/_interactions/slashCommands.ts index ee80d3ec..1cf8c2fd 100644 --- a/deno/payloads/v8/_interactions/slashCommands.ts +++ b/deno/payloads/v8/_interactions/slashCommands.ts @@ -1,9 +1,9 @@ -import { APIRole, APIUser } from '../mod.ts'; -import { Permissions, Snowflake } from '../../../globals.ts'; -import { APIPartialChannel } from '../channel.ts'; -import { APIGuildMember } from '../guild.ts'; -import { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts'; -import { InteractionType } from './responses.ts'; +import type { APIRole, APIUser } from '../mod.ts'; +import type { Permissions, Snowflake } from '../../../globals.ts'; +import type { APIPartialChannel } from '../channel.ts'; +import type { APIGuildMember } from '../guild.ts'; +import type { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts'; +import type { InteractionType } from './responses.ts'; /** * https://discord.com/developers/docs/interactions/slash-commands#application-command-object diff --git a/deno/payloads/v8/application.ts b/deno/payloads/v8/application.ts new file mode 100644 index 00000000..891d6102 --- /dev/null +++ b/deno/payloads/v8/application.ts @@ -0,0 +1,109 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/application + */ + +import type { Snowflake } from '../../globals.ts'; +import type { APITeam } from './teams.ts'; +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/resources/application#application-object + */ +export interface APIApplication { + /** + * The id of the app + */ + id: Snowflake; + /** + * The name of the app + */ + name: string; + /** + * The icon hash of the app + */ + icon: string | null; + /** + * The description of the app + */ + description: string; + /** + * An array of rpc origin urls, if rpc is enabled + */ + rpc_origins?: string[]; + /** + * When `false` only app owner can join the app's bot to guilds + */ + bot_public: boolean; + /** + * When `true` the app's bot will only join upon completion of the full oauth2 code grant flow + */ + bot_require_code_grant: boolean; + /** + * The url of the application's terms of service + */ + terms_of_service_url?: string; + /** + * The url of the application's privacy policy + */ + privacy_policy_url?: string; + /** + * Partial user object containing info on the owner of the application + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + owner?: APIUser; + /** + * If this application is a game sold on Discord, this field will be the summary field for the store page + * of its primary sku + */ + summary: string; + /** + * The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function + * + * See https://discord.com/developers/docs/game-sdk/applications#get-ticket + */ + verify_key: string; + /** + * The team this application belongs to + * + * See https://discord.com/developers/docs/topics/teams#data-models-team-object + */ + team: APITeam | null; + /** + * If this application is a game sold on Discord, this field will be the guild to which it has been linked + */ + guild_id?: Snowflake; + /** + * If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists + */ + primary_sku_id?: Snowflake; + /** + * If this application is a game sold on Discord, this field will be the URL slug that links to the store page + */ + slug?: string; + /** + * If this application is a game sold on Discord, this field will be the hash of the image on store embeds + */ + cover_image?: string; + /** + * The application's public flags + * + * See https://discord.com/developers/docs/resources/application#application-object-application-flags + */ + flags: ApplicationFlags; +} + +/** + * https://discord.com/developers/docs/resources/application#application-object-application-flags + */ +export enum ApplicationFlags { + ManagedEmoji = 1 << 2, + GroupDMCreate = 1 << 4, + RPCHasConnected = 1 << 11, + GatewayPresence = 1 << 12, + GatewayPresenceLimited = 1 << 13, + GatewayGuildMembers = 1 << 14, + GatewayGuildMembersLimited = 1 << 15, + VerificationPendingGuildLimit = 1 << 16, + Embedded = 1 << 17, +} diff --git a/deno/payloads/v8/channel.ts b/deno/payloads/v8/channel.ts index dbf1db71..3588db9b 100644 --- a/deno/payloads/v8/channel.ts +++ b/deno/payloads/v8/channel.ts @@ -6,7 +6,7 @@ import type { Permissions, Snowflake } from '../../globals.ts'; import type { APIPartialEmoji } from './emoji.ts'; import type { APIGuildMember } from './guild.ts'; import type { APIMessageInteraction } from './interactions.ts'; -import type { APIApplication } from './oauth2.ts'; +import type { APIApplication } from './application.ts'; import type { APIRole } from './permissions.ts'; import type { APISticker, APIStickerItem } from './sticker.ts'; import type { APIUser } from './user.ts'; @@ -560,7 +560,7 @@ export interface APIEmbed { /** * Description of embed * - * Length limit: 2048 characters + * Length limit: 4096 characters */ description?: string; /** diff --git a/deno/payloads/v8/guild.ts b/deno/payloads/v8/guild.ts index df657183..c6346d8a 100644 --- a/deno/payloads/v8/guild.ts +++ b/deno/payloads/v8/guild.ts @@ -246,7 +246,7 @@ export interface APIGuild extends APIPartialGuild { */ presences?: GatewayPresenceUpdate[]; /** - * The maximum number of presences for the guild (the default value, currently 25000, is in effect when `null` is returned) + * The maximum number of presences for the guild (`null` is always returned, apart from the largest of guilds) */ max_presences?: number | null; /** diff --git a/deno/payloads/v8/interactions.ts b/deno/payloads/v8/interactions.ts index 8480b7ce..bdb64400 100644 --- a/deno/payloads/v8/interactions.ts +++ b/deno/payloads/v8/interactions.ts @@ -1,9 +1,9 @@ -import { +import type { APIMessageComponentDMInteraction, APIMessageComponentGuildInteraction, APIMessageComponentInteraction, } from './_interactions/messageComponents.ts'; -import { +import type { APIApplicationCommandDMInteraction, APIApplicationCommandGuildInteraction, APIApplicationCommandInteraction, diff --git a/deno/payloads/v8/invite.ts b/deno/payloads/v8/invite.ts index 9a939ecb..448533f7 100644 --- a/deno/payloads/v8/invite.ts +++ b/deno/payloads/v8/invite.ts @@ -4,7 +4,7 @@ import type { APIPartialChannel } from './channel.ts'; import type { APIPartialGuild } from './guild.ts'; -import type { APIApplication } from './oauth2.ts'; +import type { APIApplication } from './application.ts'; import type { APIInviteStageInstance } from './stageInstance.ts'; import type { APIUser } from './user.ts'; diff --git a/deno/payloads/v8/mod.ts b/deno/payloads/v8/mod.ts index 7fea7fba..35b759d4 100644 --- a/deno/payloads/v8/mod.ts +++ b/deno/payloads/v8/mod.ts @@ -1,3 +1,4 @@ +export * from './application.ts'; export * from './auditLog.ts'; export * from './channel.ts'; export * from './emoji.ts'; diff --git a/deno/payloads/v8/oauth2.ts b/deno/payloads/v8/oauth2.ts index e22704a6..970e68e4 100644 --- a/deno/payloads/v8/oauth2.ts +++ b/deno/payloads/v8/oauth2.ts @@ -2,107 +2,6 @@ * Types extracted from https://discord.com/developers/docs/topics/oauth2 */ -import type { Snowflake } from '../../globals.ts'; -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: Snowflake; - /** - * The name of the app - */ - name: string; - /** - * The icon hash of the app - */ - icon: string | null; - /** - * The description of the app - */ - description: string; - /** - * An array of rpc origin urls, if rpc is enabled - */ - rpc_origins?: string[]; - /** - * When `false` only app owner can join the app's bot to guilds - */ - bot_public: boolean; - /** - * When `true` the app's bot will only join upon completion of the full oauth2 code grant flow - */ - bot_require_code_grant: boolean; - /** - * The url of the application's terms of service - */ - terms_of_service_url?: string; - /** - * The url of the application's privacy policy - */ - privacy_policy_url?: string; - /** - * Partial user object containing info on the owner of the application - * - * See https://discord.com/developers/docs/resources/user#user-object - */ - owner?: APIUser; - /** - * If this application is a game sold on Discord, this field will be the summary field for the store page - * of its primary sku - */ - summary: string; - /** - * The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function - * - * See https://discord.com/developers/docs/game-sdk/applications#get-ticket - */ - verify_key: string; - /** - * The team this application belongs to - * - * See https://discord.com/developers/docs/topics/teams#data-models-team-object - */ - team: APITeam | null; - /** - * If this application is a game sold on Discord, this field will be the guild to which it has been linked - */ - guild_id?: Snowflake; - /** - * If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists - */ - primary_sku_id?: Snowflake; - /** - * If this application is a game sold on Discord, this field will be the URL slug that links to the store page - */ - slug?: string; - /** - * If this application is a game sold on Discord, this field will be the hash of the image on store embeds - */ - cover_image?: string; - /** - * The application's public flags - */ - flags: ApplicationFlags; -} - -export enum ApplicationFlags { - ManagedEmoji = 1 << 2, - GroupDMCreate = 1 << 4, - RPCHasConnected = 1 << 11, - GatewayPresence = 1 << 12, - GatewayPresenceLimited = 1 << 13, - GatewayGuildMembers = 1 << 14, - GatewayGuildMembersLimited = 1 << 15, - VerificationPendingGuildLimit = 1 << 16, - Embedded = 1 << 17, -} - export enum OAuth2Scopes { /** * For oauth2 bots, this puts the bot in the user's selected guild by default diff --git a/deno/payloads/v8/teams.ts b/deno/payloads/v8/teams.ts index 6a5b752a..e428e5e0 100644 --- a/deno/payloads/v8/teams.ts +++ b/deno/payloads/v8/teams.ts @@ -21,6 +21,10 @@ export interface APITeam { * The members of the team */ members: APITeamMember[]; + /** + * The name of the team + */ + name: string; /** * The user id of the current team owner */ diff --git a/deno/payloads/v8/webhook.ts b/deno/payloads/v8/webhook.ts index 2eb05935..7062a47c 100644 --- a/deno/payloads/v8/webhook.ts +++ b/deno/payloads/v8/webhook.ts @@ -72,4 +72,8 @@ export enum WebhookType { * Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels */ ChannelFollower, + /** + * Application webhooks are webhooks used with Interactions + */ + Application, } diff --git a/deno/payloads/v9/_interactions/base.ts b/deno/payloads/v9/_interactions/base.ts index 63c0a10c..c81a6f7f 100644 --- a/deno/payloads/v9/_interactions/base.ts +++ b/deno/payloads/v9/_interactions/base.ts @@ -1,8 +1,8 @@ -import { Permissions, Snowflake } from '../../../globals.ts'; -import { InteractionType } from '../../v9.ts'; -import { APIMessage } from '../channel.ts'; -import { APIGuildMember } from '../guild.ts'; -import { APIUser } from '../user.ts'; +import type { Permissions, Snowflake } from '../../../globals.ts'; +import type { InteractionType } from '../../v9.ts'; +import type { APIMessage } from '../channel.ts'; +import type { APIGuildMember } from '../guild.ts'; +import type { APIUser } from '../user.ts'; /** * https://discord.com/developers/docs/interactions/slash-commands#message-interaction-object-message-interaction-structure diff --git a/deno/payloads/v9/_interactions/messageComponents.ts b/deno/payloads/v9/_interactions/messageComponents.ts index c6032be5..d6f62305 100644 --- a/deno/payloads/v9/_interactions/messageComponents.ts +++ b/deno/payloads/v9/_interactions/messageComponents.ts @@ -1,6 +1,6 @@ -import { ComponentType } from '../channel.ts'; -import { APIBaseInteraction, InteractionType } from '../interactions.ts'; -import { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts'; +import type { ComponentType } from '../channel.ts'; +import type { APIBaseInteraction, InteractionType } from '../interactions.ts'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts'; export type APIMessageComponentInteraction = APIBaseInteraction< InteractionType.MessageComponent, diff --git a/deno/payloads/v9/_interactions/responses.ts b/deno/payloads/v9/_interactions/responses.ts index 5b34a070..ef4bab61 100644 --- a/deno/payloads/v9/_interactions/responses.ts +++ b/deno/payloads/v9/_interactions/responses.ts @@ -1,5 +1,5 @@ -import { MessageFlags } from '../mod.ts'; -import { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9.ts'; +import type { MessageFlags } from '../mod.ts'; +import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9.ts'; /** * https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type diff --git a/deno/payloads/v9/_interactions/slashCommands.ts b/deno/payloads/v9/_interactions/slashCommands.ts index ee80d3ec..1cf8c2fd 100644 --- a/deno/payloads/v9/_interactions/slashCommands.ts +++ b/deno/payloads/v9/_interactions/slashCommands.ts @@ -1,9 +1,9 @@ -import { APIRole, APIUser } from '../mod.ts'; -import { Permissions, Snowflake } from '../../../globals.ts'; -import { APIPartialChannel } from '../channel.ts'; -import { APIGuildMember } from '../guild.ts'; -import { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts'; -import { InteractionType } from './responses.ts'; +import type { APIRole, APIUser } from '../mod.ts'; +import type { Permissions, Snowflake } from '../../../globals.ts'; +import type { APIPartialChannel } from '../channel.ts'; +import type { APIGuildMember } from '../guild.ts'; +import type { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts'; +import type { InteractionType } from './responses.ts'; /** * https://discord.com/developers/docs/interactions/slash-commands#application-command-object diff --git a/deno/payloads/v9/application.ts b/deno/payloads/v9/application.ts new file mode 100644 index 00000000..891d6102 --- /dev/null +++ b/deno/payloads/v9/application.ts @@ -0,0 +1,109 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/application + */ + +import type { Snowflake } from '../../globals.ts'; +import type { APITeam } from './teams.ts'; +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/resources/application#application-object + */ +export interface APIApplication { + /** + * The id of the app + */ + id: Snowflake; + /** + * The name of the app + */ + name: string; + /** + * The icon hash of the app + */ + icon: string | null; + /** + * The description of the app + */ + description: string; + /** + * An array of rpc origin urls, if rpc is enabled + */ + rpc_origins?: string[]; + /** + * When `false` only app owner can join the app's bot to guilds + */ + bot_public: boolean; + /** + * When `true` the app's bot will only join upon completion of the full oauth2 code grant flow + */ + bot_require_code_grant: boolean; + /** + * The url of the application's terms of service + */ + terms_of_service_url?: string; + /** + * The url of the application's privacy policy + */ + privacy_policy_url?: string; + /** + * Partial user object containing info on the owner of the application + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + owner?: APIUser; + /** + * If this application is a game sold on Discord, this field will be the summary field for the store page + * of its primary sku + */ + summary: string; + /** + * The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function + * + * See https://discord.com/developers/docs/game-sdk/applications#get-ticket + */ + verify_key: string; + /** + * The team this application belongs to + * + * See https://discord.com/developers/docs/topics/teams#data-models-team-object + */ + team: APITeam | null; + /** + * If this application is a game sold on Discord, this field will be the guild to which it has been linked + */ + guild_id?: Snowflake; + /** + * If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists + */ + primary_sku_id?: Snowflake; + /** + * If this application is a game sold on Discord, this field will be the URL slug that links to the store page + */ + slug?: string; + /** + * If this application is a game sold on Discord, this field will be the hash of the image on store embeds + */ + cover_image?: string; + /** + * The application's public flags + * + * See https://discord.com/developers/docs/resources/application#application-object-application-flags + */ + flags: ApplicationFlags; +} + +/** + * https://discord.com/developers/docs/resources/application#application-object-application-flags + */ +export enum ApplicationFlags { + ManagedEmoji = 1 << 2, + GroupDMCreate = 1 << 4, + RPCHasConnected = 1 << 11, + GatewayPresence = 1 << 12, + GatewayPresenceLimited = 1 << 13, + GatewayGuildMembers = 1 << 14, + GatewayGuildMembersLimited = 1 << 15, + VerificationPendingGuildLimit = 1 << 16, + Embedded = 1 << 17, +} diff --git a/deno/payloads/v9/channel.ts b/deno/payloads/v9/channel.ts index 79e003ca..8fb4f451 100644 --- a/deno/payloads/v9/channel.ts +++ b/deno/payloads/v9/channel.ts @@ -6,7 +6,7 @@ import type { Permissions, Snowflake } from '../../globals.ts'; import type { APIPartialEmoji } from './emoji.ts'; import type { APIGuildMember } from './guild.ts'; import type { APIMessageInteraction } from './interactions.ts'; -import type { APIApplication } from './oauth2.ts'; +import type { APIApplication } from './application.ts'; import type { APIRole } from './permissions.ts'; import type { APISticker, APIStickerItem } from './sticker.ts'; import type { APIUser } from './user.ts'; @@ -680,7 +680,7 @@ export interface APIEmbed { /** * Description of embed * - * Length limit: 2048 characters + * Length limit: 4096 characters */ description?: string; /** diff --git a/deno/payloads/v9/guild.ts b/deno/payloads/v9/guild.ts index b9ca1404..12d1ec7c 100644 --- a/deno/payloads/v9/guild.ts +++ b/deno/payloads/v9/guild.ts @@ -254,7 +254,7 @@ export interface APIGuild extends APIPartialGuild { */ presences?: GatewayPresenceUpdate[]; /** - * The maximum number of presences for the guild (the default value, currently 25000, is in effect when `null` is returned) + * The maximum number of presences for the guild (`null` is always returned, apart from the largest of guilds) */ max_presences?: number | null; /** diff --git a/deno/payloads/v9/interactions.ts b/deno/payloads/v9/interactions.ts index 8480b7ce..bdb64400 100644 --- a/deno/payloads/v9/interactions.ts +++ b/deno/payloads/v9/interactions.ts @@ -1,9 +1,9 @@ -import { +import type { APIMessageComponentDMInteraction, APIMessageComponentGuildInteraction, APIMessageComponentInteraction, } from './_interactions/messageComponents.ts'; -import { +import type { APIApplicationCommandDMInteraction, APIApplicationCommandGuildInteraction, APIApplicationCommandInteraction, diff --git a/deno/payloads/v9/invite.ts b/deno/payloads/v9/invite.ts index 9a939ecb..448533f7 100644 --- a/deno/payloads/v9/invite.ts +++ b/deno/payloads/v9/invite.ts @@ -4,7 +4,7 @@ import type { APIPartialChannel } from './channel.ts'; import type { APIPartialGuild } from './guild.ts'; -import type { APIApplication } from './oauth2.ts'; +import type { APIApplication } from './application.ts'; import type { APIInviteStageInstance } from './stageInstance.ts'; import type { APIUser } from './user.ts'; diff --git a/deno/payloads/v9/mod.ts b/deno/payloads/v9/mod.ts index 7fea7fba..35b759d4 100644 --- a/deno/payloads/v9/mod.ts +++ b/deno/payloads/v9/mod.ts @@ -1,3 +1,4 @@ +export * from './application.ts'; export * from './auditLog.ts'; export * from './channel.ts'; export * from './emoji.ts'; diff --git a/deno/payloads/v9/oauth2.ts b/deno/payloads/v9/oauth2.ts index e22704a6..970e68e4 100644 --- a/deno/payloads/v9/oauth2.ts +++ b/deno/payloads/v9/oauth2.ts @@ -2,107 +2,6 @@ * Types extracted from https://discord.com/developers/docs/topics/oauth2 */ -import type { Snowflake } from '../../globals.ts'; -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: Snowflake; - /** - * The name of the app - */ - name: string; - /** - * The icon hash of the app - */ - icon: string | null; - /** - * The description of the app - */ - description: string; - /** - * An array of rpc origin urls, if rpc is enabled - */ - rpc_origins?: string[]; - /** - * When `false` only app owner can join the app's bot to guilds - */ - bot_public: boolean; - /** - * When `true` the app's bot will only join upon completion of the full oauth2 code grant flow - */ - bot_require_code_grant: boolean; - /** - * The url of the application's terms of service - */ - terms_of_service_url?: string; - /** - * The url of the application's privacy policy - */ - privacy_policy_url?: string; - /** - * Partial user object containing info on the owner of the application - * - * See https://discord.com/developers/docs/resources/user#user-object - */ - owner?: APIUser; - /** - * If this application is a game sold on Discord, this field will be the summary field for the store page - * of its primary sku - */ - summary: string; - /** - * The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function - * - * See https://discord.com/developers/docs/game-sdk/applications#get-ticket - */ - verify_key: string; - /** - * The team this application belongs to - * - * See https://discord.com/developers/docs/topics/teams#data-models-team-object - */ - team: APITeam | null; - /** - * If this application is a game sold on Discord, this field will be the guild to which it has been linked - */ - guild_id?: Snowflake; - /** - * If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists - */ - primary_sku_id?: Snowflake; - /** - * If this application is a game sold on Discord, this field will be the URL slug that links to the store page - */ - slug?: string; - /** - * If this application is a game sold on Discord, this field will be the hash of the image on store embeds - */ - cover_image?: string; - /** - * The application's public flags - */ - flags: ApplicationFlags; -} - -export enum ApplicationFlags { - ManagedEmoji = 1 << 2, - GroupDMCreate = 1 << 4, - RPCHasConnected = 1 << 11, - GatewayPresence = 1 << 12, - GatewayPresenceLimited = 1 << 13, - GatewayGuildMembers = 1 << 14, - GatewayGuildMembersLimited = 1 << 15, - VerificationPendingGuildLimit = 1 << 16, - Embedded = 1 << 17, -} - export enum OAuth2Scopes { /** * For oauth2 bots, this puts the bot in the user's selected guild by default diff --git a/deno/payloads/v9/teams.ts b/deno/payloads/v9/teams.ts index 6a5b752a..e428e5e0 100644 --- a/deno/payloads/v9/teams.ts +++ b/deno/payloads/v9/teams.ts @@ -21,6 +21,10 @@ export interface APITeam { * The members of the team */ members: APITeamMember[]; + /** + * The name of the team + */ + name: string; /** * The user id of the current team owner */ diff --git a/deno/payloads/v9/webhook.ts b/deno/payloads/v9/webhook.ts index 2eb05935..7062a47c 100644 --- a/deno/payloads/v9/webhook.ts +++ b/deno/payloads/v9/webhook.ts @@ -72,4 +72,8 @@ export enum WebhookType { * Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels */ ChannelFollower, + /** + * Application webhooks are webhooks used with Interactions + */ + Application, } diff --git a/deno/rest/common.ts b/deno/rest/common.ts index fd0512f7..2f9ee1d8 100644 --- a/deno/rest/common.ts +++ b/deno/rest/common.ts @@ -19,6 +19,9 @@ export enum RESTJSONErrorCodes { UnknownUser, UnknownEmoji, UnknownWebhook, + UnknownWebhookService, + + UnknownSession = 10020, UnknownBan = 10026, UnknownSKU, @@ -27,30 +30,52 @@ export enum RESTJSONErrorCodes { UnknownBuild, UnknownLobby, UnknownBranch, + UnknownStoreDirectoryLayout, UnknownRedistributable = 10036, + UnknownGiftCode = 10038, + UnknownGuildTemplate = 10057, - UnknownSticker = 10060, + UnknownDiscoverableServerCategory = 10059, + UnknownSticker, UnknownInteraction = 10062, UnknownApplicationCommand, + UnknownApplicationCommandPermissions = 10066, + UnknownStageInstance, + UnknownGuildMemberVerificationForm, + UnknownGuildWelcomeScreen, + BotsCannotUseThisEndpoint = 20001, OnlyBotsCanUseThisEndpoint, + ExplicitContentCannotBeSentToTheDesiredRecipient = 20009, + + NotAuthorizedToPerformThisActionOnThisApplication = 20012, + + ActionCannotBePerformedDueToSlowmodeRateLimit = 20016, + + OnlyTheOwnerOfThisAccountCanPerformThisAction = 20018, + AnnouncementEditLimitExceeded = 20022, ChannelSendRateLimit = 20028, + StageTopicServerNameServerDescriptionOrChannelNamesContainDisallowedWords = 20031, + + GuildPremiumSubscriptionLevelTooLow = 20035, + MaximumNumberOfGuildsReached = 30001, MaximumNumberOfFriendsReached, MaximumNumberOfPinsReachedForTheChannel, - - MaximumNumberOfGuildRolesReached = 30005, + MaximumNumberOfRecipientsReached, + MaximumNumberOfGuildRolesReached, MaximumNumberOfWebhooksReached = 30007, + MaximumNumberOfEmojisReached, MaximumNumberOfReactionsReached = 30010, @@ -59,20 +84,33 @@ export enum RESTJSONErrorCodes { MaximumNumberOfAttachmentsInAMessageReached = 30015, MaximumNumberOfInvitesReached, + MaximumNumberOfAnimatedEmojisReached = 30018, + MaximumNumberOfServerMembersReached, + + MaximumNumberOfServerCategoriesReached = 30030, + GuildAlreadyHasTemplate = 30031, MaximumThreadParticipants = 30033, + MaximumNumberOfNonGuildMemberBansHasBeenExceeded = 30035, + + MaximumNumberOfBanFetchesHasBeenReached = 30037, + MaximumNumberOfStickersReached = 30039, Unauthorized = 40001, VerifyYourAccount, + OpeningDirectMessagesTooFast, RequestEntityTooLarge = 40005, FeatureTemporarilyDisabledServerSide, UserBannedFromThisGuild, - ThisMessageWasAlreadyCrossposted = 40033, + TargetUserIsNotConnectedToVoice = 40032, + ThisMessageWasAlreadyCrossposted, + + ApplicationCommandWithThatNameAlreadyExists = 40041, MissingAccess = 50001, InvalidAccountType, @@ -99,6 +137,7 @@ export enum RESTJSONErrorCodes { InvalidOAuth2AccessToken, InvalidWebhookToken = 50027, + InvalidRole, InvalidRecipients = 50033, OneOfTheMessagesProvidedWasTooOldForBulkDelete, @@ -110,6 +149,8 @@ export enum RESTJSONErrorCodes { FileUploadedExceedsMaximumSize = 50045, InvalidFileUploaded, + CannotSelfRedeemThisGift = 50070, + CannotDeleteChannelRequiredForCommunityGuilds = 50074, InvalidStickerSent = 50081, @@ -120,10 +161,14 @@ export enum RESTJSONErrorCodes { TwoFactorAuthenticationIsRequired = 60003, + NoUsersWithDiscordTagExist = 80004, + ReactionWasBlocked = 90001, APIResourceOverloaded = 130000, + TheStageIsAlreadyOpen = 150006, + ThreadAlreadyCreatedForMessage = 160004, ThreadLocked, MaximumActiveThreads, diff --git a/deno/rest/v8/channel.ts b/deno/rest/v8/channel.ts index 385fbf81..b26683e4 100644 --- a/deno/rest/v8/channel.ts +++ b/deno/rest/v8/channel.ts @@ -1,6 +1,8 @@ import type { Permissions, Snowflake } from '../../globals.ts'; import type { + APIActionRowComponent, APIAllowedMentions, + APIAttachment, APIChannel, APIEmbed, APIExtendedInvite, @@ -26,7 +28,7 @@ export type RESTGetAPIChannelResult = APIChannel; */ export interface RESTPatchAPIChannelJSONBody { /** - * 2-100 character channel name + * 1-100 character channel name * * Channel types: all */ @@ -200,6 +202,12 @@ export interface RESTPostAPIChannelMessageJSONBody { * See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure */ message_reference?: APIMessageReferenceSend; + /** + * The components to include with the message + * + * See https://discord.com/developers/docs/interactions/message-components#component-object + */ + components?: APIActionRowComponent[]; /** * IDs of up to 3 stickers in the server to send in the message * @@ -295,10 +303,15 @@ export interface RESTPatchAPIChannelMessageJSONBody { content?: string | null; /** * Embedded `rich` content (up to 6000 characters) + * + * See https://discord.com/developers/docs/resources/channel#embed-object */ - embeds?: APIEmbed[]; + embeds?: APIEmbed[] | null; /** * Embedded `rich` content + * + * See https://discord.com/developers/docs/resources/channel#embed-object + * @deprecated Use `embeds` instead */ embed?: APIEmbed | null; /** @@ -306,14 +319,50 @@ export interface RESTPatchAPIChannelMessageJSONBody { * * When specifying flags, ensure to include all previously set flags/bits * in addition to ones that you are modifying + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-flags */ flags?: MessageFlags | null; /** * Allowed mentions for the message + * + * See https://discord.com/developers/docs/resources/channel#allowed-mentions-object */ allowed_mentions?: APIAllowedMentions | null; + /** + * Attached files to keep + * + * See https://discord.com/developers/docs/resources/channel#attachment-object + */ + attachments?: APIAttachment[] | null; + /** + * The components to include with the message + * + * See https://discord.com/developers/docs/interactions/message-components#component-object + */ + components?: APIActionRowComponent[] | null; } +/** + * https://discord.com/developers/docs/resources/channel#edit-message + */ +export type RESTPatchAPIChannelMessageFormDataBody = + | { + /** + * JSON stringified message body + */ + payload_json?: string; + /** + * The file contents + */ + file: unknown; + } + | (RESTPatchAPIChannelMessageJSONBody & { + /** + * The file contents + */ + file: unknown; + }); /** * https://discord.com/developers/docs/resources/channel#edit-message */ diff --git a/deno/rest/v8/guild.ts b/deno/rest/v8/guild.ts index 7cb63a96..798253c2 100644 --- a/deno/rest/v8/guild.ts +++ b/deno/rest/v8/guild.ts @@ -20,6 +20,7 @@ import type { GuildVerificationLevel, GuildWidgetStyle, } from '../../payloads/v8/mod.ts'; +import type { Nullable } from '../../utils/internals.ts'; import type { RESTPutAPIChannelPermissionJSONBody } from './channel.ts'; export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionJSONBody { @@ -774,7 +775,3 @@ export interface RESTPatchAPIGuildWelcomeScreenJSONBody extends Nullable = { - [P in keyof T]: T[P] | null; -}; diff --git a/deno/rest/v8/webhook.ts b/deno/rest/v8/webhook.ts index 1c890647..6c87c7df 100644 --- a/deno/rest/v8/webhook.ts +++ b/deno/rest/v8/webhook.ts @@ -5,7 +5,9 @@ import type { APIEmbed, APIMessage, APIWebhook, + APIAttachment, } from '../../payloads/v8/mod.ts'; +import type { Nullable } from '../../utils/internals.ts'; /** * https://discord.com/developers/docs/resources/webhook#create-webhook @@ -115,14 +117,22 @@ export interface RESTPostAPIWebhookWithTokenJSONBody { tts?: boolean; /** * Embedded `rich` content + * + * See https://discord.com/developers/docs/resources/channel#embed-object */ embeds?: APIEmbed[]; /** * Allowed mentions for the message + * + * See https://discord.com/developers/docs/resources/channel#allowed-mentions-object */ allowed_mentions?: APIAllowedMentions; /** - * the components to include with the message + * The components to include with the message + * + * Requires an application-owned webhook + * + * See https://discord.com/developers/docs/interactions/message-components#component-object */ components?: APIActionRowComponent[]; } @@ -213,9 +223,17 @@ export type RESTPostAPIWebhookWithTokenGitHubWaitResult = APIMessage; /** * https://discord.com/developers/docs/resources/webhook#edit-webhook-message */ -export type RESTPatchAPIWebhookWithTokenMessageJSONBody = Nullable< - Pick ->; +export interface RESTPatchAPIWebhookWithTokenMessageJSONBody + extends Nullable< + Pick + > { + /** + * Attached files to keep + * + * See https://discord.com/developers/docs/resources/channel#attachment-object + */ + attachments?: APIAttachment[] | null; +} /** * https://discord.com/developers/docs/resources/webhook#edit-webhook-message @@ -252,7 +270,3 @@ export type RESTPatchAPIWebhookWithTokenMessageResult = APIMessage; * 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/deno/rest/v9/channel.ts b/deno/rest/v9/channel.ts index 02ebc9ef..210a1698 100644 --- a/deno/rest/v9/channel.ts +++ b/deno/rest/v9/channel.ts @@ -1,6 +1,8 @@ import type { Permissions, Snowflake } from '../../globals.ts'; import type { + APIActionRowComponent, APIAllowedMentions, + APIAttachment, APIChannel, APIEmbed, APIExtendedInvite, @@ -29,7 +31,7 @@ export type RESTGetAPIChannelResult = APIChannel; */ export interface RESTPatchAPIChannelJSONBody { /** - * 2-100 character channel name + * 1-100 character channel name * * Channel types: all */ @@ -228,6 +230,12 @@ export interface RESTPostAPIChannelMessageJSONBody { * See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure */ message_reference?: APIMessageReferenceSend; + /** + * The components to include with the message + * + * See https://discord.com/developers/docs/interactions/message-components#component-object + */ + components?: APIActionRowComponent[]; /** * IDs of up to 3 stickers in the server to send in the message * @@ -323,10 +331,14 @@ export interface RESTPatchAPIChannelMessageJSONBody { content?: string | null; /** * Embedded `rich` content (up to 6000 characters) + * + * See https://discord.com/developers/docs/resources/channel#embed-object */ - embeds?: APIEmbed[]; + embeds?: APIEmbed[] | null; /** * Embedded `rich` content + * + * See https://discord.com/developers/docs/resources/channel#embed-object * @deprecated Use `embeds` instead */ embed?: APIEmbed | null; @@ -335,14 +347,51 @@ export interface RESTPatchAPIChannelMessageJSONBody { * * When specifying flags, ensure to include all previously set flags/bits * in addition to ones that you are modifying + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-flags */ flags?: MessageFlags | null; /** * Allowed mentions for the message + * + * See https://discord.com/developers/docs/resources/channel#allowed-mentions-object */ allowed_mentions?: APIAllowedMentions | null; + /** + * Attached files to keep + * + * See https://discord.com/developers/docs/resources/channel#attachment-object + */ + attachments?: APIAttachment[] | null; + /** + * The components to include with the message + * + * See https://discord.com/developers/docs/interactions/message-components#component-object + */ + components?: APIActionRowComponent[] | null; } +/** + * https://discord.com/developers/docs/resources/channel#edit-message + */ +export type RESTPatchAPIChannelMessageFormDataBody = + | { + /** + * JSON stringified message body + */ + payload_json?: string; + /** + * The file contents + */ + file: unknown; + } + | (RESTPatchAPIChannelMessageJSONBody & { + /** + * The file contents + */ + file: unknown; + }); + /** * https://discord.com/developers/docs/resources/channel#edit-message */ @@ -523,7 +572,7 @@ export type RESTDeleteAPIChannelRecipientResult = unknown; */ export interface RESTPostAPIChannelMessagesThreadsJSONBody { /** - * 2-100 character thread name + * 1-100 character thread name */ name: string; /** diff --git a/deno/rest/v9/guild.ts b/deno/rest/v9/guild.ts index b0fc916f..c8496b30 100644 --- a/deno/rest/v9/guild.ts +++ b/deno/rest/v9/guild.ts @@ -20,6 +20,7 @@ import type { GuildVerificationLevel, GuildWidgetStyle, } from '../../payloads/v9/mod.ts'; +import type { Nullable } from '../../utils/internals.ts'; import type { RESTPutAPIChannelPermissionJSONBody } from './channel.ts'; export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionJSONBody { @@ -774,7 +775,3 @@ export interface RESTPatchAPIGuildWelcomeScreenJSONBody extends Nullable = { - [P in keyof T]: T[P] | null; -}; diff --git a/deno/rest/v9/webhook.ts b/deno/rest/v9/webhook.ts index b59ca100..cabecc7c 100644 --- a/deno/rest/v9/webhook.ts +++ b/deno/rest/v9/webhook.ts @@ -5,7 +5,9 @@ import type { APIEmbed, APIMessage, APIWebhook, + APIAttachment, } from '../../payloads/v9/mod.ts'; +import type { Nullable } from '../../utils/internals.ts'; /** * https://discord.com/developers/docs/resources/webhook#create-webhook @@ -115,18 +117,22 @@ export interface RESTPostAPIWebhookWithTokenJSONBody { tts?: boolean; /** * Embedded `rich` content + * + * See https://discord.com/developers/docs/resources/channel#embed-object */ embeds?: APIEmbed[]; /** * Allowed mentions for the message + * + * See https://discord.com/developers/docs/resources/channel#allowed-mentions-object */ allowed_mentions?: APIAllowedMentions; /** - * The thread to post this message in - */ - thread_id?: Snowflake; - /** - * the components to include with the message + * The components to include with the message + * + * Requires an application-owned webhook + * + * See https://discord.com/developers/docs/interactions/message-components#component-object */ components?: APIActionRowComponent[]; } @@ -163,6 +169,10 @@ export interface RESTPostAPIWebhookWithTokenQuery { * @default false */ wait?: boolean; + /** + * Send a message to the specified thread within a webhook's channel. The thread will automatically be unarchived. + */ + thread_id?: Snowflake; } /** @@ -217,9 +227,17 @@ export type RESTPostAPIWebhookWithTokenGitHubWaitResult = APIMessage; /** * https://discord.com/developers/docs/resources/webhook#edit-webhook-message */ -export type RESTPatchAPIWebhookWithTokenMessageJSONBody = Nullable< - Pick ->; +export interface RESTPatchAPIWebhookWithTokenMessageJSONBody + extends Nullable< + Pick + > { + /** + * Attached files to keep + * + * See https://discord.com/developers/docs/resources/channel#attachment-object + */ + attachments?: APIAttachment[] | null; +} /** * https://discord.com/developers/docs/resources/webhook#edit-webhook-message @@ -256,7 +274,3 @@ export type RESTPatchAPIWebhookWithTokenMessageResult = APIMessage; * 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/deno/utils/internals.ts b/deno/utils/internals.ts new file mode 100644 index 00000000..372bca8d --- /dev/null +++ b/deno/utils/internals.ts @@ -0,0 +1,3 @@ +export type Nullable = { + [P in keyof T]: T[P] | null; +}; diff --git a/gateway/v8.ts b/gateway/v8.ts index e24233b7..490087fb 100644 --- a/gateway/v8.ts +++ b/gateway/v8.ts @@ -25,6 +25,7 @@ import type { InviteTargetType, PresenceUpdateStatus, } from '../payloads/v8/index'; +import type { Nullable } from '../utils/internals'; export * from './common'; @@ -441,7 +442,7 @@ export interface GatewayReadyDispatchData { /** * Contains `id` and `flags` * - * See https://discord.com/developers/docs/topics/oauth2#application-object + * See https://discord.com/developers/docs/resources/application#application-object */ application: Pick; } @@ -734,9 +735,10 @@ export type GatewayGuildMemberUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#guild-member-update */ -export type GatewayGuildMemberUpdateDispatchData = Omit & +export type GatewayGuildMemberUpdateDispatchData = Omit & Partial> & - Required> & { + Required> & + Nullable> & { /** * The id of the guild */ @@ -1375,7 +1377,7 @@ export interface GatewayIdentifyData { /** * Presence structure for initial presence information * - * See https://discord.com/developers/docs/topics/gateway#update-status + * See https://discord.com/developers/docs/topics/gateway#update-presence */ presence?: GatewayPresenceUpdateData; /** @@ -1504,7 +1506,7 @@ export interface GatewayVoiceStateUpdateData { } /** - * https://discord.com/developers/docs/topics/gateway#update-status + * https://discord.com/developers/docs/topics/gateway#update-presence */ export interface GatewayUpdatePresence { op: GatewayOpcodes.PresenceUpdate; @@ -1512,7 +1514,7 @@ export interface GatewayUpdatePresence { } /** - * https://discord.com/developers/docs/topics/gateway#update-status-gateway-status-update-structure + * https://discord.com/developers/docs/topics/gateway#update-presence-gateway-presence-update-structure */ export interface GatewayPresenceUpdateData { /** @@ -1528,7 +1530,7 @@ export interface GatewayPresenceUpdateData { /** * The user's new status * - * See https://discord.com/developers/docs/topics/gateway#update-status-status-types + * See https://discord.com/developers/docs/topics/gateway#update-presence-status-types */ status: PresenceUpdateStatus; /** diff --git a/gateway/v9.ts b/gateway/v9.ts index 122744a4..f5a26e71 100644 --- a/gateway/v9.ts +++ b/gateway/v9.ts @@ -28,6 +28,7 @@ import type { InviteTargetType, PresenceUpdateStatus, } from '../payloads/v9/index'; +import type { Nullable } from '../utils/internals'; export * from './common'; @@ -451,7 +452,7 @@ export interface GatewayReadyDispatchData { /** * Contains `id` and `flags` * - * See https://discord.com/developers/docs/topics/oauth2#application-object + * See https://discord.com/developers/docs/resources/application#application-object */ application: Pick; } @@ -744,9 +745,10 @@ export type GatewayGuildMemberUpdateDispatch = DataPayload< /** * https://discord.com/developers/docs/topics/gateway#guild-member-update */ -export type GatewayGuildMemberUpdateDispatchData = Omit & +export type GatewayGuildMemberUpdateDispatchData = Omit & Partial> & - Required> & { + Required> & + Nullable> & { /** * The id of the guild */ @@ -1464,7 +1466,7 @@ export interface GatewayIdentifyData { /** * Presence structure for initial presence information * - * See https://discord.com/developers/docs/topics/gateway#update-status + * See https://discord.com/developers/docs/topics/gateway#update-presence */ presence?: GatewayPresenceUpdateData; /** @@ -1601,7 +1603,7 @@ export interface GatewayUpdatePresence { } /** - * https://discord.com/developers/docs/topics/gateway#update-status-gateway-status-update-structure + * https://discord.com/developers/docs/topics/gateway#update-presence-gateway-presence-update-structure */ export interface GatewayPresenceUpdateData { /** @@ -1617,7 +1619,7 @@ export interface GatewayPresenceUpdateData { /** * The user's new status * - * See https://discord.com/developers/docs/topics/gateway#update-status-status-types + * See https://discord.com/developers/docs/topics/gateway#update-presence-status-types */ status: PresenceUpdateStatus; /** diff --git a/payloads/v8/_interactions/base.ts b/payloads/v8/_interactions/base.ts index 855fe587..6b589a43 100644 --- a/payloads/v8/_interactions/base.ts +++ b/payloads/v8/_interactions/base.ts @@ -1,8 +1,8 @@ -import { Permissions, Snowflake } from '../../../globals'; -import { InteractionType } from '../../v8'; -import { APIMessage } from '../channel'; -import { APIGuildMember } from '../guild'; -import { APIUser } from '../user'; +import type { Permissions, Snowflake } from '../../../globals'; +import type { InteractionType } from '../../v8'; +import type { APIMessage } from '../channel'; +import type { APIGuildMember } from '../guild'; +import type { APIUser } from '../user'; /** * https://discord.com/developers/docs/interactions/slash-commands#message-interaction-object-message-interaction-structure diff --git a/payloads/v8/_interactions/messageComponents.ts b/payloads/v8/_interactions/messageComponents.ts index 1ef40dc5..ffac3dba 100644 --- a/payloads/v8/_interactions/messageComponents.ts +++ b/payloads/v8/_interactions/messageComponents.ts @@ -1,6 +1,6 @@ -import { ComponentType } from '../channel'; -import { APIBaseInteraction, InteractionType } from '../interactions'; -import { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base'; +import type { ComponentType } from '../channel'; +import type { APIBaseInteraction, InteractionType } from '../interactions'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base'; export type APIMessageComponentInteraction = APIBaseInteraction< InteractionType.MessageComponent, diff --git a/payloads/v8/_interactions/responses.ts b/payloads/v8/_interactions/responses.ts index 92fbfd20..76b0bf72 100644 --- a/payloads/v8/_interactions/responses.ts +++ b/payloads/v8/_interactions/responses.ts @@ -1,5 +1,5 @@ -import { MessageFlags } from '../index'; -import { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v8'; +import type { MessageFlags } from '../index'; +import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v8'; /** * https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type diff --git a/payloads/v8/_interactions/slashCommands.ts b/payloads/v8/_interactions/slashCommands.ts index b5b4d903..ab1083b9 100644 --- a/payloads/v8/_interactions/slashCommands.ts +++ b/payloads/v8/_interactions/slashCommands.ts @@ -1,9 +1,9 @@ -import { APIRole, APIUser } from '../index'; -import { Permissions, Snowflake } from '../../../globals'; -import { APIPartialChannel } from '../channel'; -import { APIGuildMember } from '../guild'; -import { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base'; -import { InteractionType } from './responses'; +import type { APIRole, APIUser } from '../index'; +import type { Permissions, Snowflake } from '../../../globals'; +import type { APIPartialChannel } from '../channel'; +import type { APIGuildMember } from '../guild'; +import type { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base'; +import type { InteractionType } from './responses'; /** * https://discord.com/developers/docs/interactions/slash-commands#application-command-object diff --git a/payloads/v8/application.ts b/payloads/v8/application.ts new file mode 100644 index 00000000..2a6eecc5 --- /dev/null +++ b/payloads/v8/application.ts @@ -0,0 +1,109 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/application + */ + +import type { Snowflake } from '../../globals'; +import type { APITeam } from './teams'; +import type { APIUser } from './user'; + +/** + * https://discord.com/developers/docs/resources/application#application-object + */ +export interface APIApplication { + /** + * The id of the app + */ + id: Snowflake; + /** + * The name of the app + */ + name: string; + /** + * The icon hash of the app + */ + icon: string | null; + /** + * The description of the app + */ + description: string; + /** + * An array of rpc origin urls, if rpc is enabled + */ + rpc_origins?: string[]; + /** + * When `false` only app owner can join the app's bot to guilds + */ + bot_public: boolean; + /** + * When `true` the app's bot will only join upon completion of the full oauth2 code grant flow + */ + bot_require_code_grant: boolean; + /** + * The url of the application's terms of service + */ + terms_of_service_url?: string; + /** + * The url of the application's privacy policy + */ + privacy_policy_url?: string; + /** + * Partial user object containing info on the owner of the application + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + owner?: APIUser; + /** + * If this application is a game sold on Discord, this field will be the summary field for the store page + * of its primary sku + */ + summary: string; + /** + * The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function + * + * See https://discord.com/developers/docs/game-sdk/applications#get-ticket + */ + verify_key: string; + /** + * The team this application belongs to + * + * See https://discord.com/developers/docs/topics/teams#data-models-team-object + */ + team: APITeam | null; + /** + * If this application is a game sold on Discord, this field will be the guild to which it has been linked + */ + guild_id?: Snowflake; + /** + * If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists + */ + primary_sku_id?: Snowflake; + /** + * If this application is a game sold on Discord, this field will be the URL slug that links to the store page + */ + slug?: string; + /** + * If this application is a game sold on Discord, this field will be the hash of the image on store embeds + */ + cover_image?: string; + /** + * The application's public flags + * + * See https://discord.com/developers/docs/resources/application#application-object-application-flags + */ + flags: ApplicationFlags; +} + +/** + * https://discord.com/developers/docs/resources/application#application-object-application-flags + */ +export const enum ApplicationFlags { + ManagedEmoji = 1 << 2, + GroupDMCreate = 1 << 4, + RPCHasConnected = 1 << 11, + GatewayPresence = 1 << 12, + GatewayPresenceLimited = 1 << 13, + GatewayGuildMembers = 1 << 14, + GatewayGuildMembersLimited = 1 << 15, + VerificationPendingGuildLimit = 1 << 16, + Embedded = 1 << 17, +} diff --git a/payloads/v8/channel.ts b/payloads/v8/channel.ts index 1b2ae7e7..bd83bd5c 100644 --- a/payloads/v8/channel.ts +++ b/payloads/v8/channel.ts @@ -6,7 +6,7 @@ import type { Permissions, Snowflake } from '../../globals'; import type { APIPartialEmoji } from './emoji'; import type { APIGuildMember } from './guild'; import type { APIMessageInteraction } from './interactions'; -import type { APIApplication } from './oauth2'; +import type { APIApplication } from './application'; import type { APIRole } from './permissions'; import type { APISticker, APIStickerItem } from './sticker'; import type { APIUser } from './user'; @@ -560,7 +560,7 @@ export interface APIEmbed { /** * Description of embed * - * Length limit: 2048 characters + * Length limit: 4096 characters */ description?: string; /** diff --git a/payloads/v8/guild.ts b/payloads/v8/guild.ts index ae34242e..4df68aa4 100644 --- a/payloads/v8/guild.ts +++ b/payloads/v8/guild.ts @@ -246,7 +246,7 @@ export interface APIGuild extends APIPartialGuild { */ presences?: GatewayPresenceUpdate[]; /** - * The maximum number of presences for the guild (the default value, currently 25000, is in effect when `null` is returned) + * The maximum number of presences for the guild (`null` is always returned, apart from the largest of guilds) */ max_presences?: number | null; /** diff --git a/payloads/v8/index.ts b/payloads/v8/index.ts index 5adfe5d8..b5a3c9e0 100644 --- a/payloads/v8/index.ts +++ b/payloads/v8/index.ts @@ -1,3 +1,4 @@ +export * from './application'; export * from './auditLog'; export * from './channel'; export * from './emoji'; diff --git a/payloads/v8/interactions.ts b/payloads/v8/interactions.ts index 56c77d4b..53998b7e 100644 --- a/payloads/v8/interactions.ts +++ b/payloads/v8/interactions.ts @@ -1,9 +1,9 @@ -import { +import type { APIMessageComponentDMInteraction, APIMessageComponentGuildInteraction, APIMessageComponentInteraction, } from './_interactions/messageComponents'; -import { +import type { APIApplicationCommandDMInteraction, APIApplicationCommandGuildInteraction, APIApplicationCommandInteraction, diff --git a/payloads/v8/invite.ts b/payloads/v8/invite.ts index 87b5b2ec..b026338f 100644 --- a/payloads/v8/invite.ts +++ b/payloads/v8/invite.ts @@ -4,7 +4,7 @@ import type { APIPartialChannel } from './channel'; import type { APIPartialGuild } from './guild'; -import type { APIApplication } from './oauth2'; +import type { APIApplication } from './application'; import type { APIInviteStageInstance } from './stageInstance'; import type { APIUser } from './user'; diff --git a/payloads/v8/oauth2.ts b/payloads/v8/oauth2.ts index f5f0d676..61f5af54 100644 --- a/payloads/v8/oauth2.ts +++ b/payloads/v8/oauth2.ts @@ -2,107 +2,6 @@ * Types extracted from https://discord.com/developers/docs/topics/oauth2 */ -import type { Snowflake } from '../../globals'; -import type { APITeam } from './teams'; -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: Snowflake; - /** - * The name of the app - */ - name: string; - /** - * The icon hash of the app - */ - icon: string | null; - /** - * The description of the app - */ - description: string; - /** - * An array of rpc origin urls, if rpc is enabled - */ - rpc_origins?: string[]; - /** - * When `false` only app owner can join the app's bot to guilds - */ - bot_public: boolean; - /** - * When `true` the app's bot will only join upon completion of the full oauth2 code grant flow - */ - bot_require_code_grant: boolean; - /** - * The url of the application's terms of service - */ - terms_of_service_url?: string; - /** - * The url of the application's privacy policy - */ - privacy_policy_url?: string; - /** - * Partial user object containing info on the owner of the application - * - * See https://discord.com/developers/docs/resources/user#user-object - */ - owner?: APIUser; - /** - * If this application is a game sold on Discord, this field will be the summary field for the store page - * of its primary sku - */ - summary: string; - /** - * The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function - * - * See https://discord.com/developers/docs/game-sdk/applications#get-ticket - */ - verify_key: string; - /** - * The team this application belongs to - * - * See https://discord.com/developers/docs/topics/teams#data-models-team-object - */ - team: APITeam | null; - /** - * If this application is a game sold on Discord, this field will be the guild to which it has been linked - */ - guild_id?: Snowflake; - /** - * If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists - */ - primary_sku_id?: Snowflake; - /** - * If this application is a game sold on Discord, this field will be the URL slug that links to the store page - */ - slug?: string; - /** - * If this application is a game sold on Discord, this field will be the hash of the image on store embeds - */ - cover_image?: string; - /** - * The application's public flags - */ - flags: ApplicationFlags; -} - -export const enum ApplicationFlags { - ManagedEmoji = 1 << 2, - GroupDMCreate = 1 << 4, - RPCHasConnected = 1 << 11, - GatewayPresence = 1 << 12, - GatewayPresenceLimited = 1 << 13, - GatewayGuildMembers = 1 << 14, - GatewayGuildMembersLimited = 1 << 15, - VerificationPendingGuildLimit = 1 << 16, - Embedded = 1 << 17, -} - export const enum OAuth2Scopes { /** * For oauth2 bots, this puts the bot in the user's selected guild by default diff --git a/payloads/v8/teams.ts b/payloads/v8/teams.ts index cadf539b..704abc95 100644 --- a/payloads/v8/teams.ts +++ b/payloads/v8/teams.ts @@ -21,6 +21,10 @@ export interface APITeam { * The members of the team */ members: APITeamMember[]; + /** + * The name of the team + */ + name: string; /** * The user id of the current team owner */ diff --git a/payloads/v8/webhook.ts b/payloads/v8/webhook.ts index b63549d7..12a56ef0 100644 --- a/payloads/v8/webhook.ts +++ b/payloads/v8/webhook.ts @@ -72,4 +72,8 @@ export const enum WebhookType { * Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels */ ChannelFollower, + /** + * Application webhooks are webhooks used with Interactions + */ + Application, } diff --git a/payloads/v9/_interactions/base.ts b/payloads/v9/_interactions/base.ts index 4286a265..3fa7a107 100644 --- a/payloads/v9/_interactions/base.ts +++ b/payloads/v9/_interactions/base.ts @@ -1,8 +1,8 @@ -import { Permissions, Snowflake } from '../../../globals'; -import { InteractionType } from '../../v9'; -import { APIMessage } from '../channel'; -import { APIGuildMember } from '../guild'; -import { APIUser } from '../user'; +import type { Permissions, Snowflake } from '../../../globals'; +import type { InteractionType } from '../../v9'; +import type { APIMessage } from '../channel'; +import type { APIGuildMember } from '../guild'; +import type { APIUser } from '../user'; /** * https://discord.com/developers/docs/interactions/slash-commands#message-interaction-object-message-interaction-structure diff --git a/payloads/v9/_interactions/messageComponents.ts b/payloads/v9/_interactions/messageComponents.ts index 1ef40dc5..ffac3dba 100644 --- a/payloads/v9/_interactions/messageComponents.ts +++ b/payloads/v9/_interactions/messageComponents.ts @@ -1,6 +1,6 @@ -import { ComponentType } from '../channel'; -import { APIBaseInteraction, InteractionType } from '../interactions'; -import { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base'; +import type { ComponentType } from '../channel'; +import type { APIBaseInteraction, InteractionType } from '../interactions'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base'; export type APIMessageComponentInteraction = APIBaseInteraction< InteractionType.MessageComponent, diff --git a/payloads/v9/_interactions/responses.ts b/payloads/v9/_interactions/responses.ts index 55b45130..cdfe37d1 100644 --- a/payloads/v9/_interactions/responses.ts +++ b/payloads/v9/_interactions/responses.ts @@ -1,5 +1,5 @@ -import { MessageFlags } from '../index'; -import { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9'; +import type { MessageFlags } from '../index'; +import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9'; /** * https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type diff --git a/payloads/v9/_interactions/slashCommands.ts b/payloads/v9/_interactions/slashCommands.ts index b5b4d903..ab1083b9 100644 --- a/payloads/v9/_interactions/slashCommands.ts +++ b/payloads/v9/_interactions/slashCommands.ts @@ -1,9 +1,9 @@ -import { APIRole, APIUser } from '../index'; -import { Permissions, Snowflake } from '../../../globals'; -import { APIPartialChannel } from '../channel'; -import { APIGuildMember } from '../guild'; -import { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base'; -import { InteractionType } from './responses'; +import type { APIRole, APIUser } from '../index'; +import type { Permissions, Snowflake } from '../../../globals'; +import type { APIPartialChannel } from '../channel'; +import type { APIGuildMember } from '../guild'; +import type { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base'; +import type { InteractionType } from './responses'; /** * https://discord.com/developers/docs/interactions/slash-commands#application-command-object diff --git a/payloads/v9/application.ts b/payloads/v9/application.ts new file mode 100644 index 00000000..2a6eecc5 --- /dev/null +++ b/payloads/v9/application.ts @@ -0,0 +1,109 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/application + */ + +import type { Snowflake } from '../../globals'; +import type { APITeam } from './teams'; +import type { APIUser } from './user'; + +/** + * https://discord.com/developers/docs/resources/application#application-object + */ +export interface APIApplication { + /** + * The id of the app + */ + id: Snowflake; + /** + * The name of the app + */ + name: string; + /** + * The icon hash of the app + */ + icon: string | null; + /** + * The description of the app + */ + description: string; + /** + * An array of rpc origin urls, if rpc is enabled + */ + rpc_origins?: string[]; + /** + * When `false` only app owner can join the app's bot to guilds + */ + bot_public: boolean; + /** + * When `true` the app's bot will only join upon completion of the full oauth2 code grant flow + */ + bot_require_code_grant: boolean; + /** + * The url of the application's terms of service + */ + terms_of_service_url?: string; + /** + * The url of the application's privacy policy + */ + privacy_policy_url?: string; + /** + * Partial user object containing info on the owner of the application + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + owner?: APIUser; + /** + * If this application is a game sold on Discord, this field will be the summary field for the store page + * of its primary sku + */ + summary: string; + /** + * The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function + * + * See https://discord.com/developers/docs/game-sdk/applications#get-ticket + */ + verify_key: string; + /** + * The team this application belongs to + * + * See https://discord.com/developers/docs/topics/teams#data-models-team-object + */ + team: APITeam | null; + /** + * If this application is a game sold on Discord, this field will be the guild to which it has been linked + */ + guild_id?: Snowflake; + /** + * If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists + */ + primary_sku_id?: Snowflake; + /** + * If this application is a game sold on Discord, this field will be the URL slug that links to the store page + */ + slug?: string; + /** + * If this application is a game sold on Discord, this field will be the hash of the image on store embeds + */ + cover_image?: string; + /** + * The application's public flags + * + * See https://discord.com/developers/docs/resources/application#application-object-application-flags + */ + flags: ApplicationFlags; +} + +/** + * https://discord.com/developers/docs/resources/application#application-object-application-flags + */ +export const enum ApplicationFlags { + ManagedEmoji = 1 << 2, + GroupDMCreate = 1 << 4, + RPCHasConnected = 1 << 11, + GatewayPresence = 1 << 12, + GatewayPresenceLimited = 1 << 13, + GatewayGuildMembers = 1 << 14, + GatewayGuildMembersLimited = 1 << 15, + VerificationPendingGuildLimit = 1 << 16, + Embedded = 1 << 17, +} diff --git a/payloads/v9/channel.ts b/payloads/v9/channel.ts index 2eb9fbc6..5e55d725 100644 --- a/payloads/v9/channel.ts +++ b/payloads/v9/channel.ts @@ -6,7 +6,7 @@ import type { Permissions, Snowflake } from '../../globals'; import type { APIPartialEmoji } from './emoji'; import type { APIGuildMember } from './guild'; import type { APIMessageInteraction } from './interactions'; -import type { APIApplication } from './oauth2'; +import type { APIApplication } from './application'; import type { APIRole } from './permissions'; import type { APISticker, APIStickerItem } from './sticker'; import type { APIUser } from './user'; @@ -680,7 +680,7 @@ export interface APIEmbed { /** * Description of embed * - * Length limit: 2048 characters + * Length limit: 4096 characters */ description?: string; /** diff --git a/payloads/v9/guild.ts b/payloads/v9/guild.ts index 4f9c65ef..da066431 100644 --- a/payloads/v9/guild.ts +++ b/payloads/v9/guild.ts @@ -254,7 +254,7 @@ export interface APIGuild extends APIPartialGuild { */ presences?: GatewayPresenceUpdate[]; /** - * The maximum number of presences for the guild (the default value, currently 25000, is in effect when `null` is returned) + * The maximum number of presences for the guild (`null` is always returned, apart from the largest of guilds) */ max_presences?: number | null; /** diff --git a/payloads/v9/index.ts b/payloads/v9/index.ts index 5adfe5d8..b5a3c9e0 100644 --- a/payloads/v9/index.ts +++ b/payloads/v9/index.ts @@ -1,3 +1,4 @@ +export * from './application'; export * from './auditLog'; export * from './channel'; export * from './emoji'; diff --git a/payloads/v9/interactions.ts b/payloads/v9/interactions.ts index 56c77d4b..53998b7e 100644 --- a/payloads/v9/interactions.ts +++ b/payloads/v9/interactions.ts @@ -1,9 +1,9 @@ -import { +import type { APIMessageComponentDMInteraction, APIMessageComponentGuildInteraction, APIMessageComponentInteraction, } from './_interactions/messageComponents'; -import { +import type { APIApplicationCommandDMInteraction, APIApplicationCommandGuildInteraction, APIApplicationCommandInteraction, diff --git a/payloads/v9/invite.ts b/payloads/v9/invite.ts index 87b5b2ec..b026338f 100644 --- a/payloads/v9/invite.ts +++ b/payloads/v9/invite.ts @@ -4,7 +4,7 @@ import type { APIPartialChannel } from './channel'; import type { APIPartialGuild } from './guild'; -import type { APIApplication } from './oauth2'; +import type { APIApplication } from './application'; import type { APIInviteStageInstance } from './stageInstance'; import type { APIUser } from './user'; diff --git a/payloads/v9/oauth2.ts b/payloads/v9/oauth2.ts index f5f0d676..61f5af54 100644 --- a/payloads/v9/oauth2.ts +++ b/payloads/v9/oauth2.ts @@ -2,107 +2,6 @@ * Types extracted from https://discord.com/developers/docs/topics/oauth2 */ -import type { Snowflake } from '../../globals'; -import type { APITeam } from './teams'; -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: Snowflake; - /** - * The name of the app - */ - name: string; - /** - * The icon hash of the app - */ - icon: string | null; - /** - * The description of the app - */ - description: string; - /** - * An array of rpc origin urls, if rpc is enabled - */ - rpc_origins?: string[]; - /** - * When `false` only app owner can join the app's bot to guilds - */ - bot_public: boolean; - /** - * When `true` the app's bot will only join upon completion of the full oauth2 code grant flow - */ - bot_require_code_grant: boolean; - /** - * The url of the application's terms of service - */ - terms_of_service_url?: string; - /** - * The url of the application's privacy policy - */ - privacy_policy_url?: string; - /** - * Partial user object containing info on the owner of the application - * - * See https://discord.com/developers/docs/resources/user#user-object - */ - owner?: APIUser; - /** - * If this application is a game sold on Discord, this field will be the summary field for the store page - * of its primary sku - */ - summary: string; - /** - * The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function - * - * See https://discord.com/developers/docs/game-sdk/applications#get-ticket - */ - verify_key: string; - /** - * The team this application belongs to - * - * See https://discord.com/developers/docs/topics/teams#data-models-team-object - */ - team: APITeam | null; - /** - * If this application is a game sold on Discord, this field will be the guild to which it has been linked - */ - guild_id?: Snowflake; - /** - * If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists - */ - primary_sku_id?: Snowflake; - /** - * If this application is a game sold on Discord, this field will be the URL slug that links to the store page - */ - slug?: string; - /** - * If this application is a game sold on Discord, this field will be the hash of the image on store embeds - */ - cover_image?: string; - /** - * The application's public flags - */ - flags: ApplicationFlags; -} - -export const enum ApplicationFlags { - ManagedEmoji = 1 << 2, - GroupDMCreate = 1 << 4, - RPCHasConnected = 1 << 11, - GatewayPresence = 1 << 12, - GatewayPresenceLimited = 1 << 13, - GatewayGuildMembers = 1 << 14, - GatewayGuildMembersLimited = 1 << 15, - VerificationPendingGuildLimit = 1 << 16, - Embedded = 1 << 17, -} - export const enum OAuth2Scopes { /** * For oauth2 bots, this puts the bot in the user's selected guild by default diff --git a/payloads/v9/teams.ts b/payloads/v9/teams.ts index cadf539b..704abc95 100644 --- a/payloads/v9/teams.ts +++ b/payloads/v9/teams.ts @@ -21,6 +21,10 @@ export interface APITeam { * The members of the team */ members: APITeamMember[]; + /** + * The name of the team + */ + name: string; /** * The user id of the current team owner */ diff --git a/payloads/v9/webhook.ts b/payloads/v9/webhook.ts index b63549d7..12a56ef0 100644 --- a/payloads/v9/webhook.ts +++ b/payloads/v9/webhook.ts @@ -72,4 +72,8 @@ export const enum WebhookType { * Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels */ ChannelFollower, + /** + * Application webhooks are webhooks used with Interactions + */ + Application, } diff --git a/rest/common.ts b/rest/common.ts index 12cfc5fc..62e9dcb2 100644 --- a/rest/common.ts +++ b/rest/common.ts @@ -19,6 +19,9 @@ export const enum RESTJSONErrorCodes { UnknownUser, UnknownEmoji, UnknownWebhook, + UnknownWebhookService, + + UnknownSession = 10020, UnknownBan = 10026, UnknownSKU, @@ -27,30 +30,52 @@ export const enum RESTJSONErrorCodes { UnknownBuild, UnknownLobby, UnknownBranch, + UnknownStoreDirectoryLayout, UnknownRedistributable = 10036, + UnknownGiftCode = 10038, + UnknownGuildTemplate = 10057, - UnknownSticker = 10060, + UnknownDiscoverableServerCategory = 10059, + UnknownSticker, UnknownInteraction = 10062, UnknownApplicationCommand, + UnknownApplicationCommandPermissions = 10066, + UnknownStageInstance, + UnknownGuildMemberVerificationForm, + UnknownGuildWelcomeScreen, + BotsCannotUseThisEndpoint = 20001, OnlyBotsCanUseThisEndpoint, + ExplicitContentCannotBeSentToTheDesiredRecipient = 20009, + + NotAuthorizedToPerformThisActionOnThisApplication = 20012, + + ActionCannotBePerformedDueToSlowmodeRateLimit = 20016, + + OnlyTheOwnerOfThisAccountCanPerformThisAction = 20018, + AnnouncementEditLimitExceeded = 20022, ChannelSendRateLimit = 20028, + StageTopicServerNameServerDescriptionOrChannelNamesContainDisallowedWords = 20031, + + GuildPremiumSubscriptionLevelTooLow = 20035, + MaximumNumberOfGuildsReached = 30001, MaximumNumberOfFriendsReached, MaximumNumberOfPinsReachedForTheChannel, - - MaximumNumberOfGuildRolesReached = 30005, + MaximumNumberOfRecipientsReached, + MaximumNumberOfGuildRolesReached, MaximumNumberOfWebhooksReached = 30007, + MaximumNumberOfEmojisReached, MaximumNumberOfReactionsReached = 30010, @@ -59,20 +84,33 @@ export const enum RESTJSONErrorCodes { MaximumNumberOfAttachmentsInAMessageReached = 30015, MaximumNumberOfInvitesReached, + MaximumNumberOfAnimatedEmojisReached = 30018, + MaximumNumberOfServerMembersReached, + + MaximumNumberOfServerCategoriesReached = 30030, + GuildAlreadyHasTemplate = 30031, MaximumThreadParticipants = 30033, + MaximumNumberOfNonGuildMemberBansHasBeenExceeded = 30035, + + MaximumNumberOfBanFetchesHasBeenReached = 30037, + MaximumNumberOfStickersReached = 30039, Unauthorized = 40001, VerifyYourAccount, + OpeningDirectMessagesTooFast, RequestEntityTooLarge = 40005, FeatureTemporarilyDisabledServerSide, UserBannedFromThisGuild, - ThisMessageWasAlreadyCrossposted = 40033, + TargetUserIsNotConnectedToVoice = 40032, + ThisMessageWasAlreadyCrossposted, + + ApplicationCommandWithThatNameAlreadyExists = 40041, MissingAccess = 50001, InvalidAccountType, @@ -99,6 +137,7 @@ export const enum RESTJSONErrorCodes { InvalidOAuth2AccessToken, InvalidWebhookToken = 50027, + InvalidRole, InvalidRecipients = 50033, OneOfTheMessagesProvidedWasTooOldForBulkDelete, @@ -110,6 +149,8 @@ export const enum RESTJSONErrorCodes { FileUploadedExceedsMaximumSize = 50045, InvalidFileUploaded, + CannotSelfRedeemThisGift = 50070, + CannotDeleteChannelRequiredForCommunityGuilds = 50074, InvalidStickerSent = 50081, @@ -120,10 +161,14 @@ export const enum RESTJSONErrorCodes { TwoFactorAuthenticationIsRequired = 60003, + NoUsersWithDiscordTagExist = 80004, + ReactionWasBlocked = 90001, APIResourceOverloaded = 130000, + TheStageIsAlreadyOpen = 150006, + ThreadAlreadyCreatedForMessage = 160004, ThreadLocked, MaximumActiveThreads, diff --git a/rest/v8/channel.ts b/rest/v8/channel.ts index 66004527..5b621a14 100644 --- a/rest/v8/channel.ts +++ b/rest/v8/channel.ts @@ -1,6 +1,8 @@ import type { Permissions, Snowflake } from '../../globals'; import type { + APIActionRowComponent, APIAllowedMentions, + APIAttachment, APIChannel, APIEmbed, APIExtendedInvite, @@ -26,7 +28,7 @@ export type RESTGetAPIChannelResult = APIChannel; */ export interface RESTPatchAPIChannelJSONBody { /** - * 2-100 character channel name + * 1-100 character channel name * * Channel types: all */ @@ -200,6 +202,12 @@ export interface RESTPostAPIChannelMessageJSONBody { * See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure */ message_reference?: APIMessageReferenceSend; + /** + * The components to include with the message + * + * See https://discord.com/developers/docs/interactions/message-components#component-object + */ + components?: APIActionRowComponent[]; /** * IDs of up to 3 stickers in the server to send in the message * @@ -295,10 +303,15 @@ export interface RESTPatchAPIChannelMessageJSONBody { content?: string | null; /** * Embedded `rich` content (up to 6000 characters) + * + * See https://discord.com/developers/docs/resources/channel#embed-object */ - embeds?: APIEmbed[]; + embeds?: APIEmbed[] | null; /** * Embedded `rich` content + * + * See https://discord.com/developers/docs/resources/channel#embed-object + * @deprecated Use `embeds` instead */ embed?: APIEmbed | null; /** @@ -306,14 +319,50 @@ export interface RESTPatchAPIChannelMessageJSONBody { * * When specifying flags, ensure to include all previously set flags/bits * in addition to ones that you are modifying + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-flags */ flags?: MessageFlags | null; /** * Allowed mentions for the message + * + * See https://discord.com/developers/docs/resources/channel#allowed-mentions-object */ allowed_mentions?: APIAllowedMentions | null; + /** + * Attached files to keep + * + * See https://discord.com/developers/docs/resources/channel#attachment-object + */ + attachments?: APIAttachment[] | null; + /** + * The components to include with the message + * + * See https://discord.com/developers/docs/interactions/message-components#component-object + */ + components?: APIActionRowComponent[] | null; } +/** + * https://discord.com/developers/docs/resources/channel#edit-message + */ +export type RESTPatchAPIChannelMessageFormDataBody = + | { + /** + * JSON stringified message body + */ + payload_json?: string; + /** + * The file contents + */ + file: unknown; + } + | (RESTPatchAPIChannelMessageJSONBody & { + /** + * The file contents + */ + file: unknown; + }); /** * https://discord.com/developers/docs/resources/channel#edit-message */ diff --git a/rest/v8/guild.ts b/rest/v8/guild.ts index b3522f3a..fa2ab4e8 100644 --- a/rest/v8/guild.ts +++ b/rest/v8/guild.ts @@ -20,6 +20,7 @@ import type { GuildVerificationLevel, GuildWidgetStyle, } from '../../payloads/v8/index'; +import type { Nullable } from '../../utils/internals'; import type { RESTPutAPIChannelPermissionJSONBody } from './channel'; export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionJSONBody { @@ -774,7 +775,3 @@ export interface RESTPatchAPIGuildWelcomeScreenJSONBody extends Nullable = { - [P in keyof T]: T[P] | null; -}; diff --git a/rest/v8/webhook.ts b/rest/v8/webhook.ts index 45d33168..d8741be6 100644 --- a/rest/v8/webhook.ts +++ b/rest/v8/webhook.ts @@ -5,7 +5,9 @@ import type { APIEmbed, APIMessage, APIWebhook, + APIAttachment, } from '../../payloads/v8/index'; +import type { Nullable } from '../../utils/internals'; /** * https://discord.com/developers/docs/resources/webhook#create-webhook @@ -115,14 +117,22 @@ export interface RESTPostAPIWebhookWithTokenJSONBody { tts?: boolean; /** * Embedded `rich` content + * + * See https://discord.com/developers/docs/resources/channel#embed-object */ embeds?: APIEmbed[]; /** * Allowed mentions for the message + * + * See https://discord.com/developers/docs/resources/channel#allowed-mentions-object */ allowed_mentions?: APIAllowedMentions; /** - * the components to include with the message + * The components to include with the message + * + * Requires an application-owned webhook + * + * See https://discord.com/developers/docs/interactions/message-components#component-object */ components?: APIActionRowComponent[]; } @@ -213,9 +223,17 @@ export type RESTPostAPIWebhookWithTokenGitHubWaitResult = APIMessage; /** * https://discord.com/developers/docs/resources/webhook#edit-webhook-message */ -export type RESTPatchAPIWebhookWithTokenMessageJSONBody = Nullable< - Pick ->; +export interface RESTPatchAPIWebhookWithTokenMessageJSONBody + extends Nullable< + Pick + > { + /** + * Attached files to keep + * + * See https://discord.com/developers/docs/resources/channel#attachment-object + */ + attachments?: APIAttachment[] | null; +} /** * https://discord.com/developers/docs/resources/webhook#edit-webhook-message @@ -252,7 +270,3 @@ export type RESTPatchAPIWebhookWithTokenMessageResult = APIMessage; * 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/rest/v9/channel.ts b/rest/v9/channel.ts index 75eb91db..b93b160d 100644 --- a/rest/v9/channel.ts +++ b/rest/v9/channel.ts @@ -1,6 +1,8 @@ import type { Permissions, Snowflake } from '../../globals'; import type { + APIActionRowComponent, APIAllowedMentions, + APIAttachment, APIChannel, APIEmbed, APIExtendedInvite, @@ -29,7 +31,7 @@ export type RESTGetAPIChannelResult = APIChannel; */ export interface RESTPatchAPIChannelJSONBody { /** - * 2-100 character channel name + * 1-100 character channel name * * Channel types: all */ @@ -228,6 +230,12 @@ export interface RESTPostAPIChannelMessageJSONBody { * See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure */ message_reference?: APIMessageReferenceSend; + /** + * The components to include with the message + * + * See https://discord.com/developers/docs/interactions/message-components#component-object + */ + components?: APIActionRowComponent[]; /** * IDs of up to 3 stickers in the server to send in the message * @@ -323,10 +331,14 @@ export interface RESTPatchAPIChannelMessageJSONBody { content?: string | null; /** * Embedded `rich` content (up to 6000 characters) + * + * See https://discord.com/developers/docs/resources/channel#embed-object */ - embeds?: APIEmbed[]; + embeds?: APIEmbed[] | null; /** * Embedded `rich` content + * + * See https://discord.com/developers/docs/resources/channel#embed-object * @deprecated Use `embeds` instead */ embed?: APIEmbed | null; @@ -335,14 +347,51 @@ export interface RESTPatchAPIChannelMessageJSONBody { * * When specifying flags, ensure to include all previously set flags/bits * in addition to ones that you are modifying + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-flags */ flags?: MessageFlags | null; /** * Allowed mentions for the message + * + * See https://discord.com/developers/docs/resources/channel#allowed-mentions-object */ allowed_mentions?: APIAllowedMentions | null; + /** + * Attached files to keep + * + * See https://discord.com/developers/docs/resources/channel#attachment-object + */ + attachments?: APIAttachment[] | null; + /** + * The components to include with the message + * + * See https://discord.com/developers/docs/interactions/message-components#component-object + */ + components?: APIActionRowComponent[] | null; } +/** + * https://discord.com/developers/docs/resources/channel#edit-message + */ +export type RESTPatchAPIChannelMessageFormDataBody = + | { + /** + * JSON stringified message body + */ + payload_json?: string; + /** + * The file contents + */ + file: unknown; + } + | (RESTPatchAPIChannelMessageJSONBody & { + /** + * The file contents + */ + file: unknown; + }); + /** * https://discord.com/developers/docs/resources/channel#edit-message */ @@ -523,7 +572,7 @@ export type RESTDeleteAPIChannelRecipientResult = unknown; */ export interface RESTPostAPIChannelMessagesThreadsJSONBody { /** - * 2-100 character thread name + * 1-100 character thread name */ name: string; /** diff --git a/rest/v9/guild.ts b/rest/v9/guild.ts index abc1ed72..f566fccd 100644 --- a/rest/v9/guild.ts +++ b/rest/v9/guild.ts @@ -20,6 +20,7 @@ import type { GuildVerificationLevel, GuildWidgetStyle, } from '../../payloads/v9/index'; +import type { Nullable } from '../../utils/internals'; import type { RESTPutAPIChannelPermissionJSONBody } from './channel'; export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionJSONBody { @@ -774,7 +775,3 @@ export interface RESTPatchAPIGuildWelcomeScreenJSONBody extends Nullable = { - [P in keyof T]: T[P] | null; -}; diff --git a/rest/v9/webhook.ts b/rest/v9/webhook.ts index 8a453be0..3c5187af 100644 --- a/rest/v9/webhook.ts +++ b/rest/v9/webhook.ts @@ -5,7 +5,9 @@ import type { APIEmbed, APIMessage, APIWebhook, + APIAttachment, } from '../../payloads/v9/index'; +import type { Nullable } from '../../utils/internals'; /** * https://discord.com/developers/docs/resources/webhook#create-webhook @@ -115,18 +117,22 @@ export interface RESTPostAPIWebhookWithTokenJSONBody { tts?: boolean; /** * Embedded `rich` content + * + * See https://discord.com/developers/docs/resources/channel#embed-object */ embeds?: APIEmbed[]; /** * Allowed mentions for the message + * + * See https://discord.com/developers/docs/resources/channel#allowed-mentions-object */ allowed_mentions?: APIAllowedMentions; /** - * The thread to post this message in - */ - thread_id?: Snowflake; - /** - * the components to include with the message + * The components to include with the message + * + * Requires an application-owned webhook + * + * See https://discord.com/developers/docs/interactions/message-components#component-object */ components?: APIActionRowComponent[]; } @@ -163,6 +169,10 @@ export interface RESTPostAPIWebhookWithTokenQuery { * @default false */ wait?: boolean; + /** + * Send a message to the specified thread within a webhook's channel. The thread will automatically be unarchived. + */ + thread_id?: Snowflake; } /** @@ -217,9 +227,17 @@ export type RESTPostAPIWebhookWithTokenGitHubWaitResult = APIMessage; /** * https://discord.com/developers/docs/resources/webhook#edit-webhook-message */ -export type RESTPatchAPIWebhookWithTokenMessageJSONBody = Nullable< - Pick ->; +export interface RESTPatchAPIWebhookWithTokenMessageJSONBody + extends Nullable< + Pick + > { + /** + * Attached files to keep + * + * See https://discord.com/developers/docs/resources/channel#attachment-object + */ + attachments?: APIAttachment[] | null; +} /** * https://discord.com/developers/docs/resources/webhook#edit-webhook-message @@ -256,7 +274,3 @@ export type RESTPatchAPIWebhookWithTokenMessageResult = APIMessage; * 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/tsconfig.json b/tsconfig.json index c5cdb8c9..26eb69d7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "noUnusedLocals": true, "removeComments": false, "target": "ES2020", - "importsNotUsedAsValues": "remove", + "importsNotUsedAsValues": "error", "strictNullChecks": true, "preserveConstEnums": true }, diff --git a/utils/internals.ts b/utils/internals.ts new file mode 100644 index 00000000..372bca8d --- /dev/null +++ b/utils/internals.ts @@ -0,0 +1,3 @@ +export type Nullable = { + [P in keyof T]: T[P] | null; +};