From 9677dada1fbe22f495146ed3ea32dff774b7d047 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 24 Aug 2025 09:41:49 -0400 Subject: [PATCH] Fix Modal not raising when hitting the 5 item limit --- discord/ui/modal.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/discord/ui/modal.py b/discord/ui/modal.py index 4a58dcc06..c85719a9b 100644 --- a/discord/ui/modal.py +++ b/discord/ui/modal.py @@ -235,3 +235,8 @@ class Modal(BaseView): } return payload + + def add_item(self, item: Item[Any]) -> Self: + if len(self._children) >= 5: + raise ValueError('maximum number of children exceeded (5)') + return super().add_item(item)