From 1c640ad72be4582bb32f659924d009c6d97b77ea Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 12 Jun 2021 02:33:11 -0400 Subject: [PATCH] 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 --- discord/ui/button.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/discord/ui/button.py b/discord/ui/button.py index 7dccfd156..741b262c9 100644 --- a/discord/ui/button.py +++ b/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,