Simplifies latency property getter logic
Refactors the conditional check to use getattr with a default value, reducing code complexity while maintaining the same functionality
This commit is contained in:
parent
592653cccd
commit
071e01cd87
@ -415,9 +415,8 @@ class Client:
|
||||
@property
|
||||
def latency_ms(self) -> Optional[float]:
|
||||
"""Returns the gateway latency in milliseconds, or ``None`` if unavailable."""
|
||||
if self._gateway and self._gateway.latency_ms is not None:
|
||||
return round(self._gateway.latency_ms, 2)
|
||||
return None
|
||||
latency = getattr(self._gateway, "latency_ms", None)
|
||||
return round(latency, 2) if latency is not None else None
|
||||
|
||||
async def wait_until_ready(self) -> None:
|
||||
"""|coro|
|
||||
|
Loading…
x
Reference in New Issue
Block a user