aboutsummaryrefslogtreecommitdiff
path: root/discord/client.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-08-15 23:41:11 -0400
committerRapptz <[email protected]>2017-08-15 23:41:11 -0400
commit0f7482ed6e2bced618e1eb4979dcd450a6fb3afa (patch)
treeed1891205859868080c8ef6cff90ff61cd052fb3 /discord/client.py
parentRemove reason keyword argument from message deletion. (diff)
downloaddiscord.py-0f7482ed6e2bced618e1eb4979dcd450a6fb3afa.tar.xz
discord.py-0f7482ed6e2bced618e1eb4979dcd450a6fb3afa.zip
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.
Diffstat (limited to 'discord/client.py')
-rw-r--r--discord/client.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/discord/client.py b/discord/client.py
index f21417c3..4d719a4b 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -173,6 +173,15 @@ class Client:
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."""
return self._connection.user