Browse Source

Lazily create Button custom_ids in decorator interface

The previous code would make two separate instances share the custom_id
which might have been undesirable behaviour
pull/7056/head
Rapptz 4 years ago
parent
commit
1c640ad72b
  1. 2
      discord/ui/button.py

2
discord/ui/button.py

@ -267,11 +267,9 @@ def button(
"""
def decorator(func: ItemCallbackType) -> ItemCallbackType:
nonlocal custom_id
if not inspect.iscoroutinefunction(func):
raise TypeError('button function must be a coroutine function')
custom_id = custom_id or os.urandom(32).hex()
func.__discord_ui_model_type__ = Button
func.__discord_ui_model_kwargs__ = {
'style': style,

Loading…
Cancel
Save