Skip to content

Commit ba286c9

Browse files
committed
feat: modals input can be null if not required
1 parent 081cdd6 commit ba286c9

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/types/modals.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ModalSubmitInteraction, TextInputStyle } from 'discord.js'
22

33
interface TextInput {
4-
label: string
4+
label?: string
55
style: keyof typeof TextInputStyle
66
maxLength?: number
77
minLength?: number
@@ -12,16 +12,19 @@ interface TextInput {
1212

1313
export type ModalInputs = Record<string, TextInput>
1414

15+
type InputValue<T extends TextInput> = T['required'] extends false
16+
? string | null
17+
: string
18+
1519
export interface ModalConfig<T extends ModalInputs = ModalInputs> {
1620
id?: string
1721
title: string
1822
inputs?: T
1923
}
2024

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+
}
2528

2629
interface ModalContext<T extends ModalInputs = ModalInputs> {
2730
inputs: ParsedInputs<T>

0 commit comments

Comments
 (0)