Add Client.latency, AutoShardedClient.latency and latencies.
This should allow an easier way to query the Discord protocol gateway latency, defined by the difference HEARTBEAT_ACK between and the last sent HEARTBEAT.
This commit is contained in:
@ -172,6 +172,15 @@ class Client:
|
||||
return m.group(1)
|
||||
return invite
|
||||
|
||||
@property
|
||||
def latency(self):
|
||||
"""float: Measures latency between a HEARTBEAT and a HEARTBEAT_ACK in seconds.
|
||||
|
||||
This could be referred to as the Discord WebSocket protocol latency.
|
||||
"""
|
||||
ws = self.ws
|
||||
return float('nan') if not ws else ws.latency
|
||||
|
||||
@property
|
||||
def user(self):
|
||||
"""Optional[:class:`ClientUser`]: Represents the connected client. None if not logged in."""
|
||||
|
Reference in New Issue
Block a user