Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 26 additions & 2 deletions deno/payloads/v8/_interactions/autocomplete.ts
Original file line number Diff line number Diff line change
@@ -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>;
8 changes: 7 additions & 1 deletion deno/payloads/v8/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -39,6 +43,7 @@ export type APIInteraction =
export type APIDMInteraction =
| APIApplicationCommandDMInteraction
| APIMessageComponentDMInteraction
| APIApplicationCommandAutocompleteDMInteraction
| APIModalSubmitDMInteraction;

/**
Expand All @@ -47,4 +52,5 @@ export type APIDMInteraction =
export type APIGuildInteraction =
| APIApplicationCommandGuildInteraction
| APIMessageComponentGuildInteraction
| APIApplicationCommandAutocompleteGuildInteraction
| APIModalSubmitGuildInteraction;
28 changes: 26 additions & 2 deletions deno/payloads/v9/_interactions/autocomplete.ts
Original file line number Diff line number Diff line change
@@ -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>;
8 changes: 7 additions & 1 deletion deno/payloads/v9/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -39,6 +43,7 @@ export type APIInteraction =
export type APIDMInteraction =
| APIApplicationCommandDMInteraction
| APIMessageComponentDMInteraction
| APIApplicationCommandAutocompleteDMInteraction
| APIModalSubmitDMInteraction;

/**
Expand All @@ -47,4 +52,5 @@ export type APIDMInteraction =
export type APIGuildInteraction =
| APIApplicationCommandGuildInteraction
| APIMessageComponentGuildInteraction
| APIApplicationCommandAutocompleteGuildInteraction
| APIModalSubmitGuildInteraction;
28 changes: 26 additions & 2 deletions payloads/v8/_interactions/autocomplete.ts
Original file line number Diff line number Diff line change
@@ -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>;
8 changes: 7 additions & 1 deletion payloads/v8/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -39,6 +43,7 @@ export type APIInteraction =
export type APIDMInteraction =
| APIApplicationCommandDMInteraction
| APIMessageComponentDMInteraction
| APIApplicationCommandAutocompleteDMInteraction
| APIModalSubmitDMInteraction;

/**
Expand All @@ -47,4 +52,5 @@ export type APIDMInteraction =
export type APIGuildInteraction =
| APIApplicationCommandGuildInteraction
| APIMessageComponentGuildInteraction
| APIApplicationCommandAutocompleteGuildInteraction
| APIModalSubmitGuildInteraction;
28 changes: 26 additions & 2 deletions payloads/v9/_interactions/autocomplete.ts
Original file line number Diff line number Diff line change
@@ -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>;
8 changes: 7 additions & 1 deletion payloads/v9/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -39,6 +43,7 @@ export type APIInteraction =
export type APIDMInteraction =
| APIApplicationCommandDMInteraction
| APIMessageComponentDMInteraction
| APIApplicationCommandAutocompleteDMInteraction
| APIModalSubmitDMInteraction;

/**
Expand All @@ -47,4 +52,5 @@ export type APIDMInteraction =
export type APIGuildInteraction =
| APIApplicationCommandGuildInteraction
| APIMessageComponentGuildInteraction
| APIApplicationCommandAutocompleteGuildInteraction
| APIModalSubmitGuildInteraction;
5 changes: 5 additions & 0 deletions tests/v9/interactions.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expectType } from 'tsd';
import {
APIApplicationCommandInteraction,
APIApplicationCommandInteractionData,
APIChatInputApplicationCommandInteractionData,
APIDMInteraction,
APIGuildInteraction,
APIInteraction,
Expand Down Expand Up @@ -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);
}
Expand Down