diff --git a/pyrogram/client/methods/decorators/on_disconnect.py b/pyrogram/client/methods/decorators/on_disconnect.py index 4bc593e3..a639471b 100644 --- a/pyrogram/client/methods/decorators/on_disconnect.py +++ b/pyrogram/client/methods/decorators/on_disconnect.py @@ -28,7 +28,11 @@ class OnDisconnect(BaseClient): """ def decorator(func): - self.add_handler(pyrogram.DisconnectHandler(func)) - return func + handler = pyrogram.DisconnectHandler(func) + + if self is not None: + self.add_handler(handler) + + return handler return decorator