Validation can be made smarter for some checks, like length of strings, etc; take for example the following:
Guid id = ... ;
return cx ( $ "<button customId='my-awesome-custom-id-{ id } ' label='foo' />") ;
The type Guid has a known length for its ToString() function, this could be taken into account with the validations.
It would also be good to ensure the following constraints are implemented and tested:
ActionRow
children: 5 (Button, Select (all))
Button
Container
children: >= 1 (ActionRow, File, MediaGallery, Section, Separator, TextDisplay)
File
Can only be a local file.
FileUpload
min_values: 0 <= 10 (int)
max_values: 1 <= 10 (int)
Label
text: 45 (string)
description: 100 (string)
component: 1 (TextInput, Select (all), FileUpload)
MediaGallery
items: 10 (MediaGalleryItem)
MediaGalleryItem
description: 256 (string)
Can be either local file or an URL.
Select
placeholder: 150 (string)
min_values: 0 <= len(options) <= 25 (int)
max_values: 1 <= len(options) <= 25 (int)
default_values: min_values <= max_values (list[Snowflake])
channel_types: 0 <= 25 (list[ChannelType])
options: 25 (list[SelectOption])
SelectOption
label: 100 (string)
value: 100 (string)
description: 100 (string)
Section
accessory: 1 (Button, Thumbnail)
children: 1 <= 3 (TextDisplay)
Separator
Only a top-level component
TextInput
label: 45 (string)
placeholder: 100 (string)
min_length: 0 <= 4000 (int)
max_length: 1 <= 4000 (int)
value/default: 4000 (string)
TextDisplay
content: 1 <= 4000 (total in one message) (string)
Thumbnail
description: 256 (string)
Can be either local file or an URL.
custom_id: 100 (string)
id: 0 <= 2_147_483_647 (int)
LayoutView: 40 (including all nested) (ActionRow, Container, File, MediaGallery, Section, Separator, TextDisplay)
Modal: 5 (top level) (Label, TextDisplay)
View: 25 (top level) (Button, Select (all))
Reactions are currently unavailable
Validation can be made smarter for some checks, like length of strings, etc; take for example the following:
The type
Guidhas a known length for itsToString()function, this could be taken into account with the validations.It would also be good to ensure the following constraints are implemented and tested:
ActionRow
Button
Container
File
FileUpload
Label
MediaGallery
Select
SelectOption
Section
Separator
TextInput
TextDisplay
Thumbnail
custom_id: 100 (string)
id: 0 <= 2_147_483_647 (int)
LayoutView: 40 (including all nested) (ActionRow, Container, File, MediaGallery, Section, Separator, TextDisplay)
Modal: 5 (top level) (Label, TextDisplay)
View: 25 (top level) (Button, Select (all))