Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
529f9d5
feat: Add ComponentLimits and EmbedLimits enums for constraint defini…
Lumabots Apr 29, 2026
24d7f69
Merge branch 'master' into enum-limit
Lumabots Apr 29, 2026
4069993
fix: Update changelog to include `ComponentLimits` and `EmbedLimits` …
Lumabots Apr 29, 2026
ff6e8e8
feat: Add ComponentLimits and EmbedLimits classes with detailed const…
Lumabots Apr 29, 2026
e91d7d9
feat: Integrate ComponentLimits into UI components for enhanced valid…
Lumabots Apr 29, 2026
ec89add
refactor: Improve error messages for component limits in UI elements
Lumabots Apr 29, 2026
c03ba1a
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 29, 2026
acc6001
feat: Update ComponentLimits for text input and checkbox group valida…
Lumabots Apr 29, 2026
d328728
fix: Update component limits for thumbnail and gallery descriptions, …
Lumabots Apr 29, 2026
4c6ae48
Merge branch 'master' into enum-limit
Lumabots May 7, 2026
c3291f5
Merge branch 'master' into enum-limit
Lumabots May 9, 2026
6fe7a57
Update discord/enums.py
Lumabots May 14, 2026
6048caa
Update discord/ui/select.py
Lumabots May 14, 2026
4e315b1
Merge branch 'master' into enum-limit
Lumabots May 14, 2026
d9c8691
feat: Update file upload limits and add new constraints in enums
Lumabots May 14, 2026
6bdb292
Refactor component limits and embed limits
Lumabots May 22, 2026
fd91d93
Merge branch 'master' into enum-limit
Lumabots May 22, 2026
f6feacc
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 22, 2026
9118c0c
fix(changelog): remove merge conflict markers from changelog
Lumabots May 22, 2026
a2fcb95
Update enums.rst
Lumabots May 22, 2026
37b2af4
feat: add strict type checking configuration for basedpyright
Lumabots May 22, 2026
d1b03f6
Merge branch 'enum-limit' of https://github.com/Lumabots/pycord into …
Lumabots May 22, 2026
6b38959
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 22, 2026
236386a
Extract ComponentLimits to ui.constant
Lumabots May 23, 2026
8495bb2
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ These changes are available on the `master` branch, but have not yet been releas

- Support for **Python 3.14**.
([#2948](https://github.com/Pycord-Development/pycord/pull/2948))
- Added `ComponentLimits` and `EmbedLimits` enums for Discord API constraints.
([#3217](https://github.com/Pycord-Development/pycord/pull/3217))

### Changed

Expand Down
99 changes: 87 additions & 12 deletions discord/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
"SelectDefaultValueType",
"ApplicationEventWebhookStatus",
"InviteTargetUsersJobStatusCode",
"ComponentLimits",
"EmbedLimits",
)


Expand All @@ -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

Expand Down Expand Up @@ -1212,6 +1210,83 @@ class InviteTargetUsersJobStatusCode(Enum):
failed = 3


class ComponentLimits(Enum):
Comment thread
Lumabots marked this conversation as resolved.
Outdated
Comment thread
Lumabots marked this conversation as resolved.
Outdated
# 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
Comment thread
Lumabots marked this conversation as resolved.
Outdated

# MediaGallery constraints
media_gallery_items_min = 1
media_gallery_items_max = 10

# MediaGalleryItem constraints
media_gallery_item_description_max = 256
Comment thread
Lumabots marked this conversation as resolved.
Outdated

# Select constraints
select_placeholder_max = 150
select_min_value_max = 25
select_max_value_max = 25
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")


Expand Down
156 changes: 156 additions & 0 deletions docs/api/enums.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2682,6 +2682,162 @@ of :class:`enum.Enum`.
.. attribute:: disabled_by_discord
The application webhook is disabled by Discord.

.. class:: ComponentLimits

Represents the limits for various Discord UI components.

.. versionadded:: 2.8.1

.. attribute:: view_children_max

The maximum number of children a View can have (40).

.. attribute:: action_row_children_max

The maximum number of children an ActionRow can have (5).

.. attribute:: button_label_max

The maximum length of a button label (80).

.. attribute:: container_children_max

The maximum number of children a Container can have (no limit).

.. attribute:: media_gallery_items_min

The minimum number of items in a MediaGallery (1).

.. attribute:: media_gallery_items_max

The maximum number of items in a MediaGallery (10).

.. attribute:: media_gallery_item_description_max

The maximum length of a MediaGalleryItem description (256).

.. attribute:: select_placeholder_max

The maximum length of a select placeholder (150).

.. attribute:: select_min_value_max

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

.. attribute:: select_max_value_max

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

.. attribute:: select_options_max

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

.. attribute:: select_option_label_max

The maximum length of a select option label (100).

.. attribute:: select_option_value_max

The maximum length of a select option value (100).

.. attribute:: select_option_description_max

The maximum length of a select option description (100).

.. attribute:: section_accessory_max

The maximum number of accessories in a Section (1).

.. attribute:: section_children_min

The minimum number of children in a Section (1).

.. attribute:: section_children_max

The maximum number of children in a Section (3).

.. attribute:: text_input_max_count

The maximum number of TextInputs in a modal (5).

.. attribute:: text_input_label_max

The maximum length of a TextInput label (45).

.. attribute:: text_input_placeholder_max

The maximum length of a TextInput placeholder (100).

.. attribute:: text_input_min_length_max

The maximum value for TextInput's minimum length (4000).

.. attribute:: text_input_max_length_max

The maximum value for TextInput's maximum length (4000).

.. attribute:: text_input_value_max

The maximum length of a TextInput value (4000).

.. attribute:: text_display_content_max

The maximum length of TextDisplay content (4000).

.. attribute:: thumbnail_description_max

The maximum length of a Thumbnail description (256).

.. attribute:: custom_id_min

The minimum length of a custom ID (1).

.. attribute:: custom_id_max

The maximum length of a custom ID (100).

.. class:: EmbedLimits

Represents the limits for Discord embeds.
Comment thread
Lumabots marked this conversation as resolved.
Outdated

.. note::

The sum of all characters in an embed must be ≤ 6000.

.. versionadded:: 2.8.1

.. attribute:: fields_max

The maximum number of embed fields (25).

.. attribute:: field_name_max

The maximum length of a field name/title (256).

.. attribute:: field_value_max

The maximum length of a field value (1024).

.. attribute:: description_max

The maximum length of an embed description (4096).

.. attribute:: footer_text_max

The maximum length of an embed footer text (2048).

.. attribute:: author_name_max

The maximum length of an embed author name (256).

.. attribute:: title_max

The maximum length of an embed title (256).

.. attribute:: total_max

The maximum total character limit for an entire embed (6000).

.. class:: TeamRole
Represents a app team role.

Expand Down
Loading