Skip to content

Commit d328728

Browse files
LumabotsCopilot
andcommitted
fix: Update component limits for thumbnail and gallery descriptions, input text min/max length, and select min/max values
Co-authored-by: Copilot <copilot@github.com>
1 parent acc6001 commit d328728

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

discord/components.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ class Thumbnail(Component):
10031003
media: :class:`UnfurledMediaItem`
10041004
The component's underlying media object.
10051005
description: Optional[:class:`str`]
1006-
The thumbnail's description, up to 1024 characters.
1006+
The thumbnail's description, up to 256 characters.
10071007
spoiler: Optional[:class:`bool`]
10081008
Whether the thumbnail has the spoiler overlay.
10091009
"""
@@ -1052,7 +1052,7 @@ class MediaGalleryItem:
10521052
url: :class:`str`
10531053
The URL of this gallery item. This can either be an arbitrary URL or an ``attachment://`` URL to work with local files.
10541054
description: Optional[:class:`str`]
1055-
The gallery item's description, up to 1024 characters.
1055+
The gallery item's description, up to 256 characters.
10561056
spoiler: Optional[:class:`bool`]
10571057
Whether the gallery item is a spoiler.
10581058
"""

discord/ui/input_text.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,18 @@ def __init__(
106106
f"label must be {ComponentLimits.text_input_label_max.value} characters or fewer"
107107
)
108108
if min_length and (
109-
min_length < ComponentLimits.text_input_min_length_max.value
110-
or min_length > ComponentLimits.text_input_max_length_max.value
109+
min_length < ComponentLimits.text_input_min_length_min.value
110+
or min_length > ComponentLimits.text_input_min_length_max.value
111111
):
112112
raise ValueError(
113-
f"min_length must be between {ComponentLimits.text_input_min_length_max.value} and {ComponentLimits.text_input_max_length_max.value}"
113+
f"min_length must be between {ComponentLimits.text_input_min_length_min.value} and {ComponentLimits.text_input_min_length_max.value}"
114114
)
115115
if max_length and (
116-
max_length < ComponentLimits.text_input_min_length_max.value
116+
max_length < ComponentLimits.text_input_max_length_min.value
117117
or max_length > ComponentLimits.text_input_max_length_max.value
118118
):
119119
raise ValueError(
120-
f"max_length must be between {ComponentLimits.text_input_min_length_max.value} and {ComponentLimits.text_input_max_length_max.value}"
120+
f"max_length must be between {ComponentLimits.text_input_max_length_min.value} and {ComponentLimits.text_input_max_length_max.value}"
121121
)
122122
if value and len(str(value)) > ComponentLimits.text_input_max_length_max.value:
123123
raise ValueError(
@@ -249,11 +249,11 @@ def min_length(self, value: int | None):
249249
f"min_length must be None or int not {value.__class__.__name__}"
250250
) # type: ignore
251251
if value and (
252-
value < ComponentLimits.text_input_min_length_max.value
253-
or value > ComponentLimits.text_input_max_length_max.value
252+
value < ComponentLimits.text_input_min_length_min.value
253+
or value > ComponentLimits.text_input_min_length_max.value
254254
):
255255
raise ValueError(
256-
f"min_length must be between {ComponentLimits.text_input_min_length_max.value} and {ComponentLimits.text_input_max_length_max.value}"
256+
f"min_length must be between {ComponentLimits.text_input_min_length_min.value} and {ComponentLimits.text_input_min_length_max.value}"
257257
)
258258
self.underlying.min_length = value
259259

@@ -269,7 +269,7 @@ def max_length(self, value: int | None):
269269
f"max_length must be None or int not {value.__class__.__name__}"
270270
) # type: ignore
271271
if value and (
272-
value <= ComponentLimits.text_input_max_length_min.value
272+
value < ComponentLimits.text_input_max_length_min.value
273273
or value > ComponentLimits.text_input_max_length_max.value
274274
):
275275
raise ValueError(

discord/ui/select.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,18 +266,18 @@ def __init__(
266266
self._selected_values: list[str] = []
267267
self._interaction: Interaction | None = None
268268
if (
269-
min_values < ComponentLimits.select_min_value_min
270-
or min_values > ComponentLimits.select_min_value_max
269+
min_values < ComponentLimits.select_min_value_min.value
270+
or min_values > ComponentLimits.select_min_value_max.value
271271
):
272272
raise ValueError(
273-
f"min_values must be between {ComponentLimits.select_min_value_min} and {ComponentLimits.select_min_value_max}"
273+
f"min_values must be between {ComponentLimits.select_min_value_min.value} and {ComponentLimits.select_min_value_max.value}"
274274
)
275275
if (
276-
max_values < ComponentLimits.select_max_value_min
277-
or max_values > ComponentLimits.select_max_value_max
276+
max_values < ComponentLimits.select_max_value_min.value
277+
or max_values > ComponentLimits.select_max_value_max.value
278278
):
279279
raise ValueError(
280-
f"max_values must be between {ComponentLimits.select_max_value_min} and {ComponentLimits.select_max_value_max}"
280+
f"max_values must be between {ComponentLimits.select_max_value_min.value} and {ComponentLimits.select_max_value_max.value}"
281281
)
282282
if (
283283
placeholder
@@ -685,7 +685,7 @@ def append_option(self, option: SelectOption) -> Self:
685685
if self.underlying.type is not ComponentType.string_select:
686686
raise Exception("options can only be set on string selects")
687687

688-
if len(self.underlying.options) > ComponentLimits.select_options_max.value:
688+
if len(self.underlying.options) >= ComponentLimits.select_options_max.value:
689689
raise ValueError("maximum number of options already provided")
690690

691691
self.underlying.options.append(option)

0 commit comments

Comments
 (0)