feat: Add ComponentLimits and EmbedLimits enums for constraint defini…#3217
feat: Add ComponentLimits and EmbedLimits enums for constraint defini…#3217Lumabots wants to merge 9 commits intoPycord-Development:masterfrom
Conversation
…tions Co-authored-by: Copilot <copilot@github.com>
|
Thanks for opening this pull request! This pull request can be checked-out with: git fetch origin pull/3217/head:pr-3217
git checkout pr-3217This pull request can be installed with: pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3217/head |
…enums Co-authored-by: Copilot <copilot@github.com>
Paillat-dev
left a comment
There was a problem hiding this comment.
Not sure, do we actually want these ? Seems like a pain to maintain. Or was this discussed already and I missed it ?
|
I don't mind this, but can we at least use it in the library? We hardcode all the limits currently, and just having these enums without doing anything with them does seem unnecessary. Also, maybe we shouldn't document the limits in the docs? It's easier to change the enum values when needed, and users can read it/use it from there. I think it's unlikely that users will first see it in the docs. |
|
well inside py-cord we dont even check for limit, so its not even hardcoded (except in the docs but i dont think we can change that) |
| failed = 3 | ||
|
|
||
|
|
||
| class ComponentLimits(Enum): |
There was a problem hiding this comment.
This is missing:
-
CheckboxGroup
- min_values: 0 <= 10
- max_values: 1 <= 10
- options: 10
-
FileUpload
- min_values: 0 <= 10
- max_values: 1 <= 10
-
RadioGroup
- options: 10
-
Select
- default_values: min_values <= max_values (??)
- channel_types: 0 <= 25
-
CheckboxGroupOption, RadioGroupOption
- label: 100
- value: 100
- description: 100
-
Modal: 5
Also, View (5) vs DesignerView (40)
There was a problem hiding this comment.
i used the command component limits on py-cord, that's why..., im gonna add those
There was a problem hiding this comment.
also what do you mean by Also, View (5) vs DesignerView (40) ?
There was a problem hiding this comment.
You currently only documented the limit for DesignerView / messages with the cv2 flag.
I'm not sure how you would differentiate between those
There was a problem hiding this comment.
what are the difference between the 2 that i should take into account (appart from rows that i didnt add)
There was a problem hiding this comment.
View only supports up to 5 ActionRows
DesignerView is CV2
Oh yeah, not for embeds… we could do that.. |
|
i put that now for the next commit, i dont know so much what to put for min values for file as |
…ation Co-authored-by: Copilot <copilot@github.com>
|
for row, i didnt edit it as its not very clear to me, we did put row should be betwee, 5 and 1, but isnt that only for View and not designer view ? but row property in select doesnt make any difference betwee, those 2 |
…tion Co-authored-by: Copilot <copilot@github.com>
|
for the enum.rst, im waiting until we decided where to move on |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds centralized enums for Discord UI/embed constraints and replaces scattered “magic number” validation with references to these limits.
Changes:
- Introduced
ComponentLimitsandEmbedLimitsenums to hold Discord API constraint values. - Updated multiple UI components (views, selects, modals, inputs, etc.) to validate using
ComponentLimits. - Documented the new enums and added a changelog entry.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/api/enums.rst | Documents the newly added constraint enums. |
| discord/enums.py | Defines ComponentLimits and EmbedLimits enums and exports them. |
| discord/components.py | Updates select option validation to use ComponentLimits. |
| discord/ui/view.py | Uses ComponentLimits for view child-count validation. |
| discord/ui/select.py | Replaces select validation constants with ComponentLimits. |
| discord/ui/modal.py | Uses ComponentLimits for modal title length and row count validation. |
| discord/ui/input_text.py | Replaces text input validation constants with ComponentLimits. |
| discord/ui/button.py | Replaces button label/custom_id length checks with ComponentLimits. |
| discord/ui/media_gallery.py | Replaces media gallery item count checks with ComponentLimits. |
| discord/ui/checkbox.py | Replaces checkbox custom_id length check with ComponentLimits. |
| discord/ui/checkbox_group.py | Replaces checkbox-group option/value constraints with ComponentLimits. |
| discord/ui/radio_group.py | Replaces radio-group limits with ComponentLimits. |
| discord/ui/file_upload.py | Replaces file upload min/max constraints with ComponentLimits. |
| discord/ui/label.py | Minor cleanup of exception strings/imports while keeping behavior. |
| CHANGELOG.md | Mentions the addition of the new constraint enums. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…input text min/max length, and select min/max values Co-authored-by: Copilot <copilot@github.com>
…tions
Caution
Feature freeze is active, as described by our Release Schedule.
Summary
Information
examples, ...).
Checklist
type: ignorecomments were used, a comment is also left explaining why.