Skip to content

feat: Add ComponentLimits and EmbedLimits enums for constraint defini…#3217

Open
Lumabots wants to merge 9 commits intoPycord-Development:masterfrom
Lumabots:enum-limit
Open

feat: Add ComponentLimits and EmbedLimits enums for constraint defini…#3217
Lumabots wants to merge 9 commits intoPycord-Development:masterfrom
Lumabots:enum-limit

Conversation

@Lumabots
Copy link
Copy Markdown
Contributor

…tions

Caution

Feature freeze is active, as described by our Release Schedule.

Summary

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.
  • AI Usage has been disclosed.
    • If AI has been used, I understand fully what the code does

…tions

Co-authored-by: Copilot <copilot@github.com>
@Lumabots Lumabots requested review from a team April 29, 2026 06:32
@github-project-automation github-project-automation Bot moved this to Todo in Pycord Apr 29, 2026
@pycord-app
Copy link
Copy Markdown

pycord-app Bot commented Apr 29, 2026

Thanks for opening this pull request!
Please make sure you have read the Contributing Guidelines and Code of Conduct.

This pull request can be checked-out with:

git fetch origin pull/3217/head:pr-3217
git checkout pr-3217

This 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>
@Lumabots Lumabots requested a review from a team as a code owner April 29, 2026 06:33
@Lumabots Lumabots requested review from a team, Icebluewolf and Soheab April 29, 2026 06:33
Copy link
Copy Markdown
Member

@Paillat-dev Paillat-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, do we actually want these ? Seems like a pain to maintain. Or was this discussed already and I missed it ?

Comment thread discord/enums.py
@Lumabots Lumabots added this to the 2.8.1 milestone Apr 29, 2026
@Soheab
Copy link
Copy Markdown
Contributor

Soheab commented Apr 29, 2026

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.

@Lumabots
Copy link
Copy Markdown
Contributor Author

Lumabots commented Apr 29, 2026

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)
for embed, for component it will be useful and i will make the change

Comment thread discord/enums.py
failed = 3


class ComponentLimits(Enum):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i used the command component limits on py-cord, that's why..., im gonna add those

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also what do you mean by Also, View (5) vs DesignerView (40) ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You currently only documented the limit for DesignerView / messages with the cv2 flag.

I'm not sure how you would differentiate between those

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are the difference between the 2 that i should take into account (appart from rows that i didnt add)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View only supports up to 5 ActionRows
DesignerView is CV2

@Soheab
Copy link
Copy Markdown
Contributor

Soheab commented Apr 29, 2026

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)

for embed, for component it will be useful and i will make the change

Oh yeah, not for embeds… we could do that..

@Lumabots
Copy link
Copy Markdown
Contributor Author

i put that now for the next commit, i dont know so much what to put for min values for file as


min_values?* | integer | Minimum number of items that must be uploaded (defaults to 1); min 0 (see note), max 10
* min_values must be either omitted or at least 1 if required is omitted or true.

@Lumabots Lumabots requested a review from a team April 29, 2026 14:24
@Lumabots
Copy link
Copy Markdown
Contributor Author

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>
@Lumabots
Copy link
Copy Markdown
Contributor Author

for the enum.rst, im waiting until we decided where to move on

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ComponentLimits and EmbedLimits enums 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.

Comment thread discord/ui/select.py
Comment thread discord/ui/input_text.py
Comment thread discord/ui/input_text.py
Comment thread discord/ui/select.py Outdated
Comment thread docs/api/enums.rst
Comment thread discord/enums.py
…input text min/max length, and select min/max values

Co-authored-by: Copilot <copilot@github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants