-
-
Notifications
You must be signed in to change notification settings - Fork 493
feat: Add ComponentLimits and EmbedLimits enums for constraint defini… #3217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Lumabots
wants to merge
11
commits into
Pycord-Development:master
Choose a base branch
from
Lumabots:enum-limit
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
529f9d5
feat: Add ComponentLimits and EmbedLimits enums for constraint defini…
Lumabots 24d7f69
Merge branch 'master' into enum-limit
Lumabots 4069993
fix: Update changelog to include `ComponentLimits` and `EmbedLimits` …
Lumabots ff6e8e8
feat: Add ComponentLimits and EmbedLimits classes with detailed const…
Lumabots e91d7d9
feat: Integrate ComponentLimits into UI components for enhanced valid…
Lumabots ec89add
refactor: Improve error messages for component limits in UI elements
Lumabots c03ba1a
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] acc6001
feat: Update ComponentLimits for text input and checkbox group valida…
Lumabots d328728
fix: Update component limits for thumbnail and gallery descriptions, …
Lumabots 4c6ae48
Merge branch 'master' into enum-limit
Lumabots c3291f5
Merge branch 'master' into enum-limit
Lumabots File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -88,6 +88,8 @@ | |||||
| "SelectDefaultValueType", | ||||||
| "ApplicationEventWebhookStatus", | ||||||
| "InviteTargetUsersJobStatusCode", | ||||||
| "ComponentLimits", | ||||||
| "EmbedLimits", | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
|
|
@@ -96,21 +98,17 @@ def _create_value_cls(name, comparable): | |||||
| cls.__repr__ = lambda self: f"<{name}.{self.name}: {self.value!r}>" | ||||||
| cls.__str__ = lambda self: f"{name}.{self.name}" | ||||||
| if comparable: | ||||||
| cls.__le__ = ( | ||||||
| lambda self, other: isinstance(other, self.__class__) | ||||||
| and self.value <= other.value | ||||||
| cls.__le__ = lambda self, other: ( | ||||||
| isinstance(other, self.__class__) and self.value <= other.value | ||||||
| ) | ||||||
| cls.__ge__ = ( | ||||||
| lambda self, other: isinstance(other, self.__class__) | ||||||
| and self.value >= other.value | ||||||
| cls.__ge__ = lambda self, other: ( | ||||||
| isinstance(other, self.__class__) and self.value >= other.value | ||||||
| ) | ||||||
| cls.__lt__ = ( | ||||||
| lambda self, other: isinstance(other, self.__class__) | ||||||
| and self.value < other.value | ||||||
| cls.__lt__ = lambda self, other: ( | ||||||
| isinstance(other, self.__class__) and self.value < other.value | ||||||
| ) | ||||||
| cls.__gt__ = ( | ||||||
| lambda self, other: isinstance(other, self.__class__) | ||||||
| and self.value > other.value | ||||||
| cls.__gt__ = lambda self, other: ( | ||||||
| isinstance(other, self.__class__) and self.value > other.value | ||||||
| ) | ||||||
| return cls | ||||||
|
|
||||||
|
|
@@ -1212,6 +1210,83 @@ class InviteTargetUsersJobStatusCode(Enum): | |||||
| failed = 3 | ||||||
|
|
||||||
|
|
||||||
| class ComponentLimits(Enum): | ||||||
|
Lumabots marked this conversation as resolved.
|
||||||
| # View constraints | ||||||
| view_children_max = 40 | ||||||
|
|
||||||
| # ActionRow constraints | ||||||
| action_row_children_max = 5 | ||||||
|
|
||||||
| # Button constraints | ||||||
| button_label_max = 80 | ||||||
|
|
||||||
| # Container constraints | ||||||
| container_children_max = float("inf") # No limit | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only non-int member of the enum, which makes it inconsistent with all other members.
Suggested change
|
||||||
|
|
||||||
| # MediaGallery constraints | ||||||
| media_gallery_items_min = 1 | ||||||
| media_gallery_items_max = 10 | ||||||
|
|
||||||
| # MediaGalleryItem constraints | ||||||
| media_gallery_item_description_max = 256 | ||||||
|
Lumabots marked this conversation as resolved.
|
||||||
|
|
||||||
| # Select constraints | ||||||
| select_placeholder_max = 150 | ||||||
| select_min_value_max = 25 | ||||||
| select_max_value_max = 25 | ||||||
|
Comment on lines
+1235
to
+1238
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are not yet documented in |
||||||
| select_options_max = 25 | ||||||
|
|
||||||
| # Select option constraints | ||||||
| select_option_label_max = 100 | ||||||
| select_option_value_max = 100 | ||||||
| select_option_description_max = 100 | ||||||
|
|
||||||
| # Section constraints | ||||||
| section_accessory_max = 1 | ||||||
| section_children_min = 1 | ||||||
| section_children_max = 3 | ||||||
|
|
||||||
| # TextInput constraints | ||||||
| text_input_max_count = 5 | ||||||
| text_input_label_max = 45 | ||||||
| text_input_placeholder_max = 100 | ||||||
| text_input_min_length_max = 4000 | ||||||
| text_input_max_length_max = 4000 | ||||||
| text_input_value_max = 4000 | ||||||
|
|
||||||
| # TextDisplay constraints | ||||||
| text_display_content_max = 4000 | ||||||
|
|
||||||
| # Thumbnail constraints | ||||||
| thumbnail_description_max = 256 | ||||||
|
|
||||||
| # Custom ID constraints | ||||||
| custom_id_min = 1 | ||||||
| custom_id_max = 100 | ||||||
|
|
||||||
|
|
||||||
| class EmbedLimits(Enum): | ||||||
| # Embed field constraints | ||||||
| fields_max = 25 | ||||||
|
|
||||||
| # Field title/name constraints | ||||||
| field_name_max = 256 | ||||||
|
|
||||||
| # Field value constraints | ||||||
| field_value_max = 1024 | ||||||
|
|
||||||
| # Embed description constraints | ||||||
| description_max = 4096 | ||||||
|
|
||||||
| # Embed footer constraints | ||||||
| footer_text_max = 2048 | ||||||
|
|
||||||
| # Embed author constraints | ||||||
| author_name_max = 256 | ||||||
| title_max = 256 | ||||||
| total_max = 6000 | ||||||
|
|
||||||
|
|
||||||
| T = TypeVar("T") | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.