-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
interactions.test-d.ts
51 lines (40 loc) · 1.62 KB
/
interactions.test-d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { expectType } from 'tsd';
import {
APIApplicationCommandInteraction,
APIApplicationCommandInteractionData,
APIDMInteraction,
APIGuildInteraction,
APIInteraction,
APIInteractionGuildMember,
APIMessageComponentInteraction,
APIModalSubmission,
APIUser,
ComponentType,
InteractionType,
} from '../../v9';
declare const interaction: APIInteraction;
if (interaction.type === InteractionType.ApplicationCommand) {
expectType<APIApplicationCommandInteraction>(interaction);
const { data } = interaction;
expectType<APIApplicationCommandInteractionData>(data);
}
if (interaction.type === InteractionType.MessageComponent) {
expectType<APIMessageComponentInteraction>(interaction);
const { data } = interaction;
if (data.component_type === ComponentType.Button) {
// TODO: For some reason, tsd yields a `Parameter type APIMessageButtonInteractionData is not identical to argument type APIMessageButtonInteractionData.` error
// expectType<APIMessageButtonInteractionData>(data);
}
if (data.component_type === ComponentType.SelectMenu) {
// TODO: for some reason, tsd yields a `Parameter type APIMessageSelectMenuInteractionData is not identical to argument type APIMessageSelectMenuInteractionData.` error
// expectType<APIMessageSelectMenuInteractionData>(data);
expectType<string[]>(data.values);
}
}
if (interaction.type === InteractionType.ModalSubmit) {
expectType<APIModalSubmission>(interaction.data);
}
declare const dmInteraction: APIDMInteraction;
expectType<APIUser>(dmInteraction.user);
declare const guildInteraction: APIGuildInteraction;
expectType<APIInteractionGuildMember>(guildInteraction.member);