Skip to content

Commit 87eb06a

Browse files
feat: Select menus in modals, and other fixes (#96)
Co-authored-by: Justin Beckwith <[email protected]>
1 parent c6937b5 commit 87eb06a

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

src/components.ts

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export enum MessageComponentTypes {
1818
FILE = 13,
1919
SEPARATOR = 14,
2020
CONTAINER = 17,
21+
LABEL = 18,
2122
}
2223

2324
export type MessageComponent =
@@ -28,14 +29,15 @@ export type MessageComponent =
2829
| RoleSelect
2930
| MentionableSelect
3031
| ChannelSelect
31-
| InputText
32+
| TextInput
3233
| Section
3334
| TextDisplay
3435
| Thumbnail
3536
| MediaGallery
3637
| FileComponent
3738
| Separator
38-
| Container;
39+
| Container
40+
| Label;
3941

4042
export enum ButtonStyleTypes {
4143
PRIMARY = 1,
@@ -99,7 +101,7 @@ export type ActionRow = BaseComponent & {
99101
| RoleSelect
100102
| MentionableSelect
101103
| ChannelSelect
102-
| InputText
104+
| TextInput
103105
>;
104106
};
105107

@@ -118,6 +120,7 @@ export type SelectMenu<T extends SelectComponentType> = BaseComponent & {
118120
min_values?: number;
119121
max_values?: number;
120122
disabled?: boolean;
123+
required?: boolean;
121124
};
122125

123126
/**
@@ -164,31 +167,41 @@ export type ChannelSelect = SelectMenu<MessageComponentTypes.CHANNEL_SELECT> & {
164167
};
165168

166169
export enum ChannelTypes {
167-
DM = 1,
168-
GROUP_DM = 3,
169170
GUILD_TEXT = 0,
171+
DM = 1,
170172
GUILD_VOICE = 2,
173+
GROUP_DM = 3,
171174
GUILD_CATEGORY = 4,
172175
GUILD_ANNOUNCEMENT = 5,
173176
GUILD_STORE = 6,
177+
ANNOUNCEMENT_THREAD = 10,
178+
PUBLIC_THREAD = 11,
179+
PRIVATE_THREAD = 12,
180+
GUILD_STAGE_VOICE = 13,
181+
GUILD_DIRECTORY = 14,
182+
GUILD_FORUM = 15,
183+
GUILD_MEDIA = 16,
174184
}
175185

176186
/**
177187
* Text input component
178188
* @see {@link https://discord.com/developers/docs/components/reference#text-input}
179189
*/
180-
export type InputText = {
190+
export type TextInput = {
181191
type: MessageComponentTypes.INPUT_TEXT;
182192
custom_id: string;
183193
style: TextStyleTypes.SHORT | TextStyleTypes.PARAGRAPH;
184-
label: string;
194+
label?: string;
185195
min_length?: number;
186196
max_length?: number;
187197
required?: boolean;
188198
value?: string;
189199
placeholder?: string;
190200
};
191201

202+
/** @deprecated `InputText` has been renamed to `TextInput` */
203+
export type InputText = TextInput;
204+
192205
export enum TextStyleTypes {
193206
SHORT = 1,
194207
PARAGRAPH = 2,
@@ -288,6 +301,17 @@ export interface Container extends BaseComponent {
288301
spoiler?: boolean;
289302
}
290303

304+
/**
305+
* Label component
306+
* @see {@link https://discord.com/developers/docs/components/reference#label}
307+
*/
308+
export interface Label extends BaseComponent {
309+
type: MessageComponentTypes.LABEL;
310+
label: string;
311+
description?: string;
312+
component: StringSelect | TextInput;
313+
}
314+
291315
export interface UnfurledMediaItem {
292316
url: string;
293317
proxy_url?: string;

0 commit comments

Comments
 (0)