From c055fd32bbe5c68b144a7ac938b911035eb6d3e1 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 15 Jun 2024 07:46:36 -0400 Subject: [PATCH] Fix ui.Button providing a custom_id for premium buttons --- discord/ui/button.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/discord/ui/button.py b/discord/ui/button.py index f986b078b..43bd3a8b0 100644 --- a/discord/ui/button.py +++ b/discord/ui/button.py @@ -107,11 +107,15 @@ class Button(Item[V]): sku_id: Optional[int] = None, ): super().__init__() - if custom_id is not None and url is not None: - raise TypeError('cannot mix both url and custom_id with Button') + if custom_id is not None and (url is not None or sku_id is not None): + raise TypeError('cannot mix both url or sku_id and custom_id with Button') + if url is not None and sku_id is not None: + raise TypeError('cannot mix both url and sku_id') + + requires_custom_id = url is None and sku_id is None self._provided_custom_id = custom_id is not None - if url is None and custom_id is None: + if requires_custom_id and custom_id is None: custom_id = os.urandom(16).hex() if custom_id is not None and not isinstance(custom_id, str):