mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-07 10:22:59 +00:00
Parse gateway URL as an actual URL using yarl
Discord has changed the URL format to make it infeasible to edit it using basic string interpolation.
This commit is contained in:
@ -28,6 +28,7 @@ import asyncio
|
||||
import logging
|
||||
|
||||
import aiohttp
|
||||
import yarl
|
||||
|
||||
from .state import AutoShardedConnectionState
|
||||
from .client import Client
|
||||
@ -403,7 +404,7 @@ class AutoShardedClient(Client):
|
||||
"""Mapping[int, :class:`ShardInfo`]: Returns a mapping of shard IDs to their respective info object."""
|
||||
return {shard_id: ShardInfo(parent, self.shard_count) for shard_id, parent in self.__shards.items()}
|
||||
|
||||
async def launch_shard(self, gateway: str, shard_id: int, *, initial: bool = False) -> None:
|
||||
async def launch_shard(self, gateway: yarl.URL, shard_id: int, *, initial: bool = False) -> None:
|
||||
try:
|
||||
coro = DiscordWebSocket.from_client(self, initial=initial, gateway=gateway, shard_id=shard_id)
|
||||
ws = await asyncio.wait_for(coro, timeout=180.0)
|
||||
@ -422,9 +423,10 @@ class AutoShardedClient(Client):
|
||||
|
||||
if self.shard_count is None:
|
||||
self.shard_count: int
|
||||
self.shard_count, gateway = await self.http.get_bot_gateway()
|
||||
self.shard_count, gateway_url = await self.http.get_bot_gateway()
|
||||
gateway = yarl.URL(gateway_url)
|
||||
else:
|
||||
gateway = await self.http.get_gateway()
|
||||
gateway = DiscordWebSocket.DEFAULT_GATEWAY
|
||||
|
||||
self._connection.shard_count = self.shard_count
|
||||
|
||||
|
Reference in New Issue
Block a user