mirror of
https://github.com/yawaflua/Flask-Discord.git
synced 2026-02-04 10:14:15 +02:00
Make use of the check response.wait_for_status() and then return json response
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import cachetools
|
import cachetools
|
||||||
import requests
|
import requests
|
||||||
import typing
|
import typing
|
||||||
import json
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
from . import configs
|
from . import configs
|
||||||
@@ -179,10 +178,12 @@ class DiscordOAuth2HttpClient(abc.ABC):
|
|||||||
raise exceptions.RateLimited(response.json(), response.headers)
|
raise exceptions.RateLimited(response.json(), response.headers)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return response.json()
|
response.raise_for_status()
|
||||||
except json.JSONDecodeError:
|
except requests.HTTPError:
|
||||||
return response.text
|
return response.text
|
||||||
|
|
||||||
|
return response.json()
|
||||||
|
|
||||||
def bot_request(self, route: str, method="GET", **kwargs) -> typing.Union[dict, str]:
|
def bot_request(self, route: str, method="GET", **kwargs) -> typing.Union[dict, str]:
|
||||||
"""Make HTTP request to specified endpoint with bot token as authorization headers.
|
"""Make HTTP request to specified endpoint with bot token as authorization headers.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user