First pass at supporting v8 API
This commit is contained in:
@@ -51,7 +51,7 @@ async def json_or_text(response):
|
||||
|
||||
|
||||
class Route:
|
||||
BASE = 'https://discord.com/api/v7'
|
||||
BASE = 'https://discord.com/api/v8'
|
||||
|
||||
def __init__(self, method, path, **parameters):
|
||||
self.path = path
|
||||
@@ -151,7 +151,6 @@ class HTTPClient:
|
||||
# header creation
|
||||
headers = {
|
||||
'User-Agent': self.user_agent,
|
||||
'X-Ratelimit-Precision': 'millisecond',
|
||||
}
|
||||
|
||||
if self.token is not None:
|
||||
@@ -450,7 +449,7 @@ class HTTPClient:
|
||||
return self.request(r, reason=reason)
|
||||
|
||||
def delete_messages(self, channel_id, message_ids, *, reason=None):
|
||||
r = Route('POST', '/channels/{channel_id}/messages/bulk_delete', channel_id=channel_id)
|
||||
r = Route('POST', '/channels/{channel_id}/messages/bulk-delete', channel_id=channel_id)
|
||||
payload = {
|
||||
'messages': message_ids,
|
||||
}
|
||||
@@ -1279,28 +1278,28 @@ class HTTPClient:
|
||||
def application_info(self):
|
||||
return self.request(Route('GET', '/oauth2/applications/@me'))
|
||||
|
||||
async def get_gateway(self, *, encoding='json', v=6, zlib=True):
|
||||
async def get_gateway(self, *, encoding='json', zlib=True):
|
||||
try:
|
||||
data = await self.request(Route('GET', '/gateway'))
|
||||
except HTTPException as exc:
|
||||
raise GatewayNotFound() from exc
|
||||
if zlib:
|
||||
value = '{0}?encoding={1}&v={2}&compress=zlib-stream'
|
||||
value = '{0}?encoding={1}&v=8&compress=zlib-stream'
|
||||
else:
|
||||
value = '{0}?encoding={1}&v={2}'
|
||||
return value.format(data['url'], encoding, v)
|
||||
value = '{0}?encoding={1}&v=8'
|
||||
return value.format(data['url'], encoding)
|
||||
|
||||
async def get_bot_gateway(self, *, encoding='json', v=6, zlib=True):
|
||||
async def get_bot_gateway(self, *, encoding='json', zlib=True):
|
||||
try:
|
||||
data = await self.request(Route('GET', '/gateway/bot'))
|
||||
except HTTPException as exc:
|
||||
raise GatewayNotFound() from exc
|
||||
|
||||
if zlib:
|
||||
value = '{0}?encoding={1}&v={2}&compress=zlib-stream'
|
||||
value = '{0}?encoding={1}&v=8&compress=zlib-stream'
|
||||
else:
|
||||
value = '{0}?encoding={1}&v={2}'
|
||||
return data['shards'], value.format(data['url'], encoding, v)
|
||||
value = '{0}?encoding={1}&v=8'
|
||||
return data['shards'], value.format(data['url'], encoding)
|
||||
|
||||
def get_user(self, user_id):
|
||||
return self.request(Route('GET', '/users/{user_id}', user_id=user_id))
|
||||
|
||||
Reference in New Issue
Block a user