From ffcd95d597a5d1c5b3ea072cd1dfb44f079de4b7 Mon Sep 17 00:00:00 2001 From: Advaith Date: Sat, 27 Mar 2021 15:40:52 -0700 Subject: [PATCH] fix(APIInteractionResponse): `data` should not always be present (#100) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- deno/v8/payloads/interactions.ts | 25 +++++++++++-------------- v8/payloads/interactions.ts | 25 +++++++++++-------------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/deno/v8/payloads/interactions.ts b/deno/v8/payloads/interactions.ts index ebefe610..000981f9 100644 --- a/deno/v8/payloads/interactions.ts +++ b/deno/v8/payloads/interactions.ts @@ -238,14 +238,19 @@ export type APIInteractionResponse = | APIInteractionResponseChannelMessageWithSource | APIInteractionResponseDeferredChannelMessageWithSource; -export type APIInteractionResponsePong = InteractionResponsePayload; +export interface APIInteractionResponsePong { + type: InteractionResponseType.Pong; +} -export type APIInteractionResponseChannelMessageWithSource = InteractionResponsePayload< - InteractionResponseType.ChannelMessageWithSource, - true ->; +export interface APIInteractionResponseChannelMessageWithSource { + type: InteractionResponseType.ChannelMessageWithSource; + data: APIInteractionApplicationCommandCallbackData; +} -export type APIInteractionResponseDeferredChannelMessageWithSource = InteractionResponsePayload; +export interface APIInteractionResponseDeferredChannelMessageWithSource { + type: InteractionResponseType.DeferredChannelMessageWithSource; + data?: Pick; +} /** * https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionresponsetype @@ -295,14 +300,6 @@ export interface APIMessageInteraction { user: APIUser; } -/** - * @internal - */ -interface InteractionResponsePayload { - type: T; - data: D extends true ? APIInteractionApplicationCommandCallbackData : never; -} - /** * @internal */ diff --git a/v8/payloads/interactions.ts b/v8/payloads/interactions.ts index 63ffcbf9..a5d8be20 100644 --- a/v8/payloads/interactions.ts +++ b/v8/payloads/interactions.ts @@ -238,14 +238,19 @@ export type APIInteractionResponse = | APIInteractionResponseChannelMessageWithSource | APIInteractionResponseDeferredChannelMessageWithSource; -export type APIInteractionResponsePong = InteractionResponsePayload; +export interface APIInteractionResponsePong { + type: InteractionResponseType.Pong; +} -export type APIInteractionResponseChannelMessageWithSource = InteractionResponsePayload< - InteractionResponseType.ChannelMessageWithSource, - true ->; +export interface APIInteractionResponseChannelMessageWithSource { + type: InteractionResponseType.ChannelMessageWithSource; + data: APIInteractionApplicationCommandCallbackData; +} -export type APIInteractionResponseDeferredChannelMessageWithSource = InteractionResponsePayload; +export interface APIInteractionResponseDeferredChannelMessageWithSource { + type: InteractionResponseType.DeferredChannelMessageWithSource; + data?: Pick; +} /** * https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionresponsetype @@ -295,14 +300,6 @@ export interface APIMessageInteraction { user: APIUser; } -/** - * @internal - */ -interface InteractionResponsePayload { - type: T; - data: D extends true ? APIInteractionApplicationCommandCallbackData : never; -} - /** * @internal */