fix: make data required in autocomplete interaction and add separate dm/guild types (#322)

This commit is contained in:
Almeida
2022-02-11 21:44:28 +00:00
committed by GitHub
parent f88727bd80
commit 7abeb2e039
9 changed files with 137 additions and 12 deletions

View File

@@ -1,6 +1,30 @@
import type { APIBaseInteraction, APIChatInputApplicationCommandInteractionData, InteractionType } from '../mod.ts';
import type {
APIBaseInteraction,
APIChatInputApplicationCommandInteractionData,
APIDMInteractionWrapper,
APIGuildInteractionWrapper,
InteractionType,
} from '../mod.ts';
export type APIApplicationCommandAutocompleteInteraction = APIBaseInteraction<
InteractionType.ApplicationCommandAutocomplete,
APIChatInputApplicationCommandInteractionData
>;
> &
Required<
Pick<
APIBaseInteraction<InteractionType.ApplicationCommandAutocomplete, APIChatInputApplicationCommandInteractionData>,
'data'
>
>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIApplicationCommandAutocompleteDMInteraction =
APIDMInteractionWrapper<APIApplicationCommandAutocompleteInteraction>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIApplicationCommandAutocompleteGuildInteraction =
APIGuildInteractionWrapper<APIApplicationCommandAutocompleteInteraction>;

View File

@@ -9,7 +9,11 @@ import type {
APIApplicationCommandGuildInteraction,
APIApplicationCommandInteraction,
} from './_interactions/applicationCommands.ts';
import type { APIApplicationCommandAutocompleteInteraction } from './_interactions/autocomplete.ts';
import type {
APIApplicationCommandAutocompleteDMInteraction,
APIApplicationCommandAutocompleteGuildInteraction,
APIApplicationCommandAutocompleteInteraction,
} from './_interactions/autocomplete.ts';
import type {
APIModalSubmitDMInteraction,
APIModalSubmitGuildInteraction,
@@ -39,6 +43,7 @@ export type APIInteraction =
export type APIDMInteraction =
| APIApplicationCommandDMInteraction
| APIMessageComponentDMInteraction
| APIApplicationCommandAutocompleteDMInteraction
| APIModalSubmitDMInteraction;
/**
@@ -47,4 +52,5 @@ export type APIDMInteraction =
export type APIGuildInteraction =
| APIApplicationCommandGuildInteraction
| APIMessageComponentGuildInteraction
| APIApplicationCommandAutocompleteGuildInteraction
| APIModalSubmitGuildInteraction;

View File

@@ -1,6 +1,30 @@
import type { APIBaseInteraction, APIChatInputApplicationCommandInteractionData, InteractionType } from '../mod.ts';
import type {
APIBaseInteraction,
APIChatInputApplicationCommandInteractionData,
APIDMInteractionWrapper,
APIGuildInteractionWrapper,
InteractionType,
} from '../mod.ts';
export type APIApplicationCommandAutocompleteInteraction = APIBaseInteraction<
InteractionType.ApplicationCommandAutocomplete,
APIChatInputApplicationCommandInteractionData
>;
> &
Required<
Pick<
APIBaseInteraction<InteractionType.ApplicationCommandAutocomplete, APIChatInputApplicationCommandInteractionData>,
'data'
>
>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIApplicationCommandAutocompleteDMInteraction =
APIDMInteractionWrapper<APIApplicationCommandAutocompleteInteraction>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIApplicationCommandAutocompleteGuildInteraction =
APIGuildInteractionWrapper<APIApplicationCommandAutocompleteInteraction>;

View File

@@ -9,7 +9,11 @@ import type {
APIApplicationCommandGuildInteraction,
APIApplicationCommandInteraction,
} from './_interactions/applicationCommands.ts';
import type { APIApplicationCommandAutocompleteInteraction } from './_interactions/autocomplete.ts';
import type {
APIApplicationCommandAutocompleteDMInteraction,
APIApplicationCommandAutocompleteGuildInteraction,
APIApplicationCommandAutocompleteInteraction,
} from './_interactions/autocomplete.ts';
import type {
APIModalSubmitDMInteraction,
APIModalSubmitGuildInteraction,
@@ -39,6 +43,7 @@ export type APIInteraction =
export type APIDMInteraction =
| APIApplicationCommandDMInteraction
| APIMessageComponentDMInteraction
| APIApplicationCommandAutocompleteDMInteraction
| APIModalSubmitDMInteraction;
/**
@@ -47,4 +52,5 @@ export type APIDMInteraction =
export type APIGuildInteraction =
| APIApplicationCommandGuildInteraction
| APIMessageComponentGuildInteraction
| APIApplicationCommandAutocompleteGuildInteraction
| APIModalSubmitGuildInteraction;

View File

@@ -1,6 +1,30 @@
import type { APIBaseInteraction, APIChatInputApplicationCommandInteractionData, InteractionType } from '../index';
import type {
APIBaseInteraction,
APIChatInputApplicationCommandInteractionData,
APIDMInteractionWrapper,
APIGuildInteractionWrapper,
InteractionType,
} from '../index';
export type APIApplicationCommandAutocompleteInteraction = APIBaseInteraction<
InteractionType.ApplicationCommandAutocomplete,
APIChatInputApplicationCommandInteractionData
>;
> &
Required<
Pick<
APIBaseInteraction<InteractionType.ApplicationCommandAutocomplete, APIChatInputApplicationCommandInteractionData>,
'data'
>
>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIApplicationCommandAutocompleteDMInteraction =
APIDMInteractionWrapper<APIApplicationCommandAutocompleteInteraction>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIApplicationCommandAutocompleteGuildInteraction =
APIGuildInteractionWrapper<APIApplicationCommandAutocompleteInteraction>;

View File

@@ -9,7 +9,11 @@ import type {
APIApplicationCommandGuildInteraction,
APIApplicationCommandInteraction,
} from './_interactions/applicationCommands';
import type { APIApplicationCommandAutocompleteInteraction } from './_interactions/autocomplete';
import type {
APIApplicationCommandAutocompleteDMInteraction,
APIApplicationCommandAutocompleteGuildInteraction,
APIApplicationCommandAutocompleteInteraction,
} from './_interactions/autocomplete';
import type {
APIModalSubmitDMInteraction,
APIModalSubmitGuildInteraction,
@@ -39,6 +43,7 @@ export type APIInteraction =
export type APIDMInteraction =
| APIApplicationCommandDMInteraction
| APIMessageComponentDMInteraction
| APIApplicationCommandAutocompleteDMInteraction
| APIModalSubmitDMInteraction;
/**
@@ -47,4 +52,5 @@ export type APIDMInteraction =
export type APIGuildInteraction =
| APIApplicationCommandGuildInteraction
| APIMessageComponentGuildInteraction
| APIApplicationCommandAutocompleteGuildInteraction
| APIModalSubmitGuildInteraction;

View File

@@ -1,6 +1,30 @@
import type { APIBaseInteraction, APIChatInputApplicationCommandInteractionData, InteractionType } from '../index';
import type {
APIBaseInteraction,
APIChatInputApplicationCommandInteractionData,
APIDMInteractionWrapper,
APIGuildInteractionWrapper,
InteractionType,
} from '../index';
export type APIApplicationCommandAutocompleteInteraction = APIBaseInteraction<
InteractionType.ApplicationCommandAutocomplete,
APIChatInputApplicationCommandInteractionData
>;
> &
Required<
Pick<
APIBaseInteraction<InteractionType.ApplicationCommandAutocomplete, APIChatInputApplicationCommandInteractionData>,
'data'
>
>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIApplicationCommandAutocompleteDMInteraction =
APIDMInteractionWrapper<APIApplicationCommandAutocompleteInteraction>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIApplicationCommandAutocompleteGuildInteraction =
APIGuildInteractionWrapper<APIApplicationCommandAutocompleteInteraction>;

View File

@@ -9,7 +9,11 @@ import type {
APIApplicationCommandGuildInteraction,
APIApplicationCommandInteraction,
} from './_interactions/applicationCommands';
import type { APIApplicationCommandAutocompleteInteraction } from './_interactions/autocomplete';
import type {
APIApplicationCommandAutocompleteDMInteraction,
APIApplicationCommandAutocompleteGuildInteraction,
APIApplicationCommandAutocompleteInteraction,
} from './_interactions/autocomplete';
import type {
APIModalSubmitDMInteraction,
APIModalSubmitGuildInteraction,
@@ -39,6 +43,7 @@ export type APIInteraction =
export type APIDMInteraction =
| APIApplicationCommandDMInteraction
| APIMessageComponentDMInteraction
| APIApplicationCommandAutocompleteDMInteraction
| APIModalSubmitDMInteraction;
/**
@@ -47,4 +52,5 @@ export type APIDMInteraction =
export type APIGuildInteraction =
| APIApplicationCommandGuildInteraction
| APIMessageComponentGuildInteraction
| APIApplicationCommandAutocompleteGuildInteraction
| APIModalSubmitGuildInteraction;

View File

@@ -2,6 +2,7 @@ import { expectType } from 'tsd';
import {
APIApplicationCommandInteraction,
APIApplicationCommandInteractionData,
APIChatInputApplicationCommandInteractionData,
APIDMInteraction,
APIGuildInteraction,
APIInteraction,
@@ -38,6 +39,10 @@ if (interaction.type === InteractionType.MessageComponent) {
}
}
if (interaction.type === InteractionType.ApplicationCommandAutocomplete) {
expectType<APIChatInputApplicationCommandInteractionData>(interaction.data);
}
if (interaction.type === InteractionType.ModalSubmit) {
expectType<APIModalSubmission>(interaction.data);
}