|
|
@ -105,7 +105,7 @@ class HTTPClient: |
|
|
|
if self.__session.closed: |
|
|
|
self.__session = aiohttp.ClientSession(connector=self.connector, loop=self.loop) |
|
|
|
|
|
|
|
async def request(self, route, *, files=None, header_bypass_delay=None, **kwargs): |
|
|
|
async def request(self, route, *, files=None, **kwargs): |
|
|
|
bucket = route.bucket |
|
|
|
method = route.method |
|
|
|
url = route.url |
|
|
@ -119,6 +119,7 @@ class HTTPClient: |
|
|
|
# header creation |
|
|
|
headers = { |
|
|
|
'User-Agent': self.user_agent, |
|
|
|
'X-Ratelimit-Precision': 'millisecond', |
|
|
|
} |
|
|
|
|
|
|
|
if self.token is not None: |
|
|
@ -165,11 +166,7 @@ class HTTPClient: |
|
|
|
remaining = r.headers.get('X-Ratelimit-Remaining') |
|
|
|
if remaining == '0' and r.status != 429: |
|
|
|
# we've depleted our current bucket |
|
|
|
if header_bypass_delay is None: |
|
|
|
delta = utils._parse_ratelimit_header(r) |
|
|
|
else: |
|
|
|
delta = header_bypass_delay |
|
|
|
|
|
|
|
delta = utils._parse_ratelimit_header(r) |
|
|
|
log.debug('A rate limit bucket has been exhausted (bucket: %s, retry: %s).', bucket, delta) |
|
|
|
maybe_lock.defer() |
|
|
|
self.loop.call_later(delta, lock.release) |
|
|
@ -383,17 +380,17 @@ class HTTPClient: |
|
|
|
def add_reaction(self, channel_id, message_id, emoji): |
|
|
|
r = Route('PUT', '/channels/{channel_id}/messages/{message_id}/reactions/{emoji}/@me', |
|
|
|
channel_id=channel_id, message_id=message_id, emoji=emoji) |
|
|
|
return self.request(r, header_bypass_delay=0.25) |
|
|
|
return self.request(r) |
|
|
|
|
|
|
|
def remove_reaction(self, channel_id, message_id, emoji, member_id): |
|
|
|
r = Route('DELETE', '/channels/{channel_id}/messages/{message_id}/reactions/{emoji}/{member_id}', |
|
|
|
channel_id=channel_id, message_id=message_id, member_id=member_id, emoji=emoji) |
|
|
|
return self.request(r, header_bypass_delay=0.25) |
|
|
|
return self.request(r) |
|
|
|
|
|
|
|
def remove_own_reaction(self, channel_id, message_id, emoji): |
|
|
|
r = Route('DELETE', '/channels/{channel_id}/messages/{message_id}/reactions/{emoji}/@me', |
|
|
|
channel_id=channel_id, message_id=message_id, emoji=emoji) |
|
|
|
return self.request(r, header_bypass_delay=0.25) |
|
|
|
return self.request(r) |
|
|
|
|
|
|
|
def get_reaction_users(self, channel_id, message_id, emoji, limit, after=None): |
|
|
|
r = Route('GET', '/channels/{channel_id}/messages/{message_id}/reactions/{emoji}', |
|
|
|