File tree 1 file changed +8
-5
lines changed
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 1
1
import type { ModalSubmitInteraction , TextInputStyle } from 'discord.js'
2
2
3
3
interface TextInput {
4
- label : string
4
+ label ? : string
5
5
style : keyof typeof TextInputStyle
6
6
maxLength ?: number
7
7
minLength ?: number
@@ -12,16 +12,19 @@ interface TextInput {
12
12
13
13
export type ModalInputs = Record < string , TextInput >
14
14
15
+ type InputValue < T extends TextInput > = T [ 'required' ] extends false
16
+ ? string | null
17
+ : string
18
+
15
19
export interface ModalConfig < T extends ModalInputs = ModalInputs > {
16
20
id ?: string
17
21
title : string
18
22
inputs ?: T
19
23
}
20
24
21
- export type ParsedInputs < T extends ModalInputs = ModalInputs > = Record <
22
- { [ K in keyof T ] : K } [ keyof T ] ,
23
- string
24
- >
25
+ export type ParsedInputs < T extends ModalInputs = ModalInputs > = {
26
+ [ K in keyof T ] : InputValue < T [ K ] >
27
+ }
25
28
26
29
interface ModalContext < T extends ModalInputs = ModalInputs > {
27
30
inputs : ParsedInputs < T >
You can’t perform that action at this time.
0 commit comments