forked from Rin0530/220613_ServerlessBot
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathutil.ts
More file actions
38 lines (32 loc) · 1.11 KB
/
util.ts
File metadata and controls
38 lines (32 loc) · 1.11 KB
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
import {
InteractionType,
ComponentTypes
} from "./@types/types.ts"
import {
ActionRows,
ApplicationCommandInteraction,
Buttons,
Interaction,
MessageComponent,
MessageComponentInteraction,
SelectMenu,
TextInput
} from "./@types/index.d.ts"
export function isCommand(value:Interaction): value is ApplicationCommandInteraction {
return value.type == InteractionType.APPLICATION_COMMAND && 'data' in value;
}
export function isMessage(value:Interaction): value is MessageComponentInteraction {
return value.type == InteractionType.MESSAGE_COMPONENT && 'message' in value;
}
export function isActionRows(value:MessageComponent): value is ActionRows {
return value.type == ComponentTypes.ActionRows;
}
export function isButtons(value:MessageComponent): value is Buttons {
return value.type == ComponentTypes.Button;
}
export function isSelectMenu(value:MessageComponent): value is SelectMenu {
return value.type == ComponentTypes.SelectMenu
}
export function isTextInput(value:MessageComponent): value is TextInput {
return value.type == ComponentTypes.TextInput
}