Skip to content

Commit d9c8691

Browse files
committed
feat: Update file upload limits and add new constraints in enums
1 parent 4e315b1 commit d9c8691

3 files changed

Lines changed: 72 additions & 11 deletions

File tree

discord/enums.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,8 @@ class ComponentLimits(Enum):
12811281

12821282
# FileUpload constraints
12831283
file_upload_min_files = 0
1284-
file_upload_max_files = 10
1284+
file_upload_max_files_max = 10
1285+
file_upload_max_values_min = 1
12851286

12861287
# Modal constraints
12871288
modal_title_max = 45

discord/ui/file_upload.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,17 @@ def __init__(
8080
super().__init__()
8181
if min_values and (
8282
min_values < ComponentLimits.file_upload_min_files.value
83-
or min_values > ComponentLimits.file_upload_max_files.value
83+
or min_values > ComponentLimits.file_upload_max_files_max.value
8484
):
8585
raise ValueError(
86-
f"min_values must be between {ComponentLimits.file_upload_min_files.value} and {ComponentLimits.file_upload_max_files.value}"
86+
f"min_values must be between {ComponentLimits.file_upload_min_files.value} and {ComponentLimits.file_upload_max_files_max.value}"
8787
)
8888
if max_values and (
89-
max_values < ComponentLimits.file_upload_min_files.value
90-
or max_values > ComponentLimits.file_upload_max_files.value
89+
max_values < ComponentLimits.file_upload_max_values_min.value
90+
or max_values > ComponentLimits.file_upload_max_files_max.value
9191
):
9292
raise ValueError(
93-
f"max_values must be between {ComponentLimits.file_upload_min_files.value} and {ComponentLimits.file_upload_max_files.value}"
93+
f"max_values must be between {ComponentLimits.file_upload_max_values_min.value} and {ComponentLimits.file_upload_max_files_max.value}"
9494
)
9595
if custom_id is not None and not isinstance(custom_id, str):
9696
raise TypeError(
@@ -155,10 +155,10 @@ def min_values(self, value: int | None):
155155
) # type: ignore
156156
if value and (
157157
value < ComponentLimits.file_upload_min_files.value
158-
or value > ComponentLimits.file_upload_max_files.value
158+
or value > ComponentLimits.file_upload_max_files_max.value
159159
):
160160
raise ValueError(
161-
f"min_values must be between {ComponentLimits.file_upload_min_files.value} and {ComponentLimits.file_upload_max_files.value}"
161+
f"min_values must be between {ComponentLimits.file_upload_min_files.value} and {ComponentLimits.file_upload_max_files_max.value}"
162162
)
163163
self.underlying.min_values = value
164164

@@ -174,11 +174,11 @@ def max_values(self, value: int | None):
174174
f"max_values must be None or int not {value.__class__.__name__}"
175175
) # type: ignore
176176
if value and (
177-
value < ComponentLimits.file_upload_min_files.value
178-
or value > ComponentLimits.file_upload_max_files.value
177+
value < ComponentLimits.file_upload_max_values_min.value
178+
or value > ComponentLimits.file_upload_max_files_max.value
179179
):
180180
raise ValueError(
181-
f"max_values must be between {ComponentLimits.file_upload_min_files.value} and {ComponentLimits.file_upload_max_files.value}"
181+
f"max_values must be between {ComponentLimits.file_upload_max_values_min.value} and {ComponentLimits.file_upload_max_files_max.value}"
182182
)
183183
self.underlying.max_values = value
184184

docs/api/enums.rst

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,10 +2720,18 @@ of :class:`enum.Enum`.
27202720

27212721
The maximum length of a select placeholder (150).
27222722

2723+
.. attribute:: select_min_value_min
2724+
2725+
The minimum value for select's minimum value constraint (0).
2726+
27232727
.. attribute:: select_min_value_max
27242728

27252729
The maximum value for select's minimum value constraint (25).
27262730

2731+
.. attribute:: select_max_value_min
2732+
2733+
The minimum value for select's maximum value constraint (1).
2734+
27272735
.. attribute:: select_max_value_max
27282736

27292737
The maximum value for select's maximum value constraint (25).
@@ -2732,6 +2740,10 @@ of :class:`enum.Enum`.
27322740

27332741
The maximum number of options in a select menu (25).
27342742

2743+
.. attribute:: select_default_values_max
2744+
2745+
The maximum number of default values in a select menu (25).
2746+
27352747
.. attribute:: select_option_label_max
27362748

27372749
The maximum length of a select option label (100).
@@ -2768,6 +2780,10 @@ of :class:`enum.Enum`.
27682780

27692781
The maximum length of a TextInput placeholder (100).
27702782

2783+
.. attribute:: text_input_min_length_min
2784+
2785+
The minimum value for TextInput's minimum length (0).
2786+
27712787
.. attribute:: text_input_min_length_max
27722788

27732789
The maximum value for TextInput's minimum length (4000).
@@ -2796,6 +2812,50 @@ of :class:`enum.Enum`.
27962812

27972813
The maximum length of a custom ID (100).
27982814

2815+
.. attribute:: radio_options_max
2816+
2817+
The maximum number of options in a RadioGroup (10).
2818+
2819+
.. attribute:: checkbox_options_max
2820+
2821+
The maximum number of options in a CheckboxGroup (10).
2822+
2823+
.. attribute:: checkbox_min_values_min
2824+
2825+
The minimum value for checkbox's minimum value constraint (0).
2826+
2827+
.. attribute:: checkbox_min_values_max
2828+
2829+
The maximum value for checkbox's minimum value constraint (10).
2830+
2831+
.. attribute:: checkbox_max_values_min
2832+
2833+
The minimum value for checkbox's maximum value constraint (1).
2834+
2835+
.. attribute:: checkbox_max_values_max
2836+
2837+
The maximum value for checkbox's maximum value constraint (10).
2838+
2839+
.. attribute:: file_upload_min_files
2840+
2841+
The minimum number of files that can be uploaded (0).
2842+
2843+
.. attribute:: file_upload_max_files_max
2844+
2845+
The maximum number of files that can be uploaded (10).
2846+
2847+
.. attribute:: file_upload_max_values_min
2848+
2849+
The minimum value for file upload's maximum value constraint (1).
2850+
2851+
.. attribute:: modal_title_max
2852+
2853+
The maximum length of a modal title (45).
2854+
2855+
.. attribute:: modal_rows_max
2856+
2857+
The maximum number of rows in a modal (5).
2858+
27992859
.. class:: EmbedLimits
28002860

28012861
Represents the limits for Discord embeds.

0 commit comments

Comments
 (0)