Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: try to fix some rarely occurring bugs, fix wrong version in url #806

Merged
merged 2 commits into from May 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions interactions/api/http/client.py
Expand Up @@ -77,7 +77,11 @@ async def get_gateway(self) -> str:
url: Any = await self._req.request(
Route("GET", "/gateway")
) # typehinting Any because pycharm yells
return f'{url["url"]}?v=10&encoding=json'
try:
_url = f'{url["url"]}?v=10&encoding=json'
except TypeError: # seen a few times
_url = "wss://gateway.discord.gg?v=10&encoding=json"
return _url

async def get_bot_gateway(self) -> Tuple[int, str]:
"""
Expand All @@ -87,7 +91,11 @@ async def get_bot_gateway(self) -> Tuple[int, str]:
"""

data: Any = await self._req.request(Route("GET", "/gateway/bot"))
return data["shards"], f'{data["url"]}?v=9&encoding=json'
try:
_url = f'{data["url"]}?v=10&encoding=json'
except TypeError: # seen a few times
_url = "wss://gateway.discord.gg?v=10&encoding=json"
return data["shards"], _url

async def login(self) -> Optional[dict]:
"""
Expand Down