Add a way to check if the websocket is rate limited.
This is mainly for low level decision making for utilities that need to know whether to fetch a member by HTTP or to query through the websocket. The library already does this trick in some places so it's only fair that end users possess the same ability as well.
This commit is contained in:
@ -282,6 +282,18 @@ class Client:
|
||||
ws = self.ws
|
||||
return float('nan') if not ws else ws.latency
|
||||
|
||||
def is_ws_ratelimited(self):
|
||||
""":class:`bool`: Whether the websocket is currently rate limited.
|
||||
|
||||
This can be useful to know when deciding whether you should query members
|
||||
using HTTP or via the gateway.
|
||||
|
||||
.. versionadded:: 1.6
|
||||
"""
|
||||
if self.ws:
|
||||
return self.ws.is_ratelimited()
|
||||
return False
|
||||
|
||||
@property
|
||||
def user(self):
|
||||
"""Optional[:class:`.ClientUser`]: Represents the connected client. ``None`` if not logged in."""
|
||||
|
Reference in New Issue
Block a user