Skip to content

Commit

Permalink
Fix ui.Button providing a custom_id for premium buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapptz committed Jun 15, 2024
1 parent be9edf8 commit c055fd3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions discord/ui/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,15 @@ def __init__(
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):
Expand Down

0 comments on commit c055fd3

Please sign in to comment.