mirror of
https://github.com/discordeno/discordeno.git
synced 2026-05-21 02:40:08 +00:00
Parse Gateway Identify and Resume Urls (#2502)
* parse gateway and resume Urls #2475 * fix params * deno fmt * convert version to string
This commit is contained in:
@@ -8,12 +8,14 @@ export async function connect(shard: Shard): Promise<void> {
|
||||
}
|
||||
shard.events.connecting?.(shard);
|
||||
|
||||
let url = shard.gatewayConfig.url;
|
||||
let url = new URL(shard.gatewayConfig.url);
|
||||
// If not connecting to a proxy but directly to discord need to handle resuming
|
||||
if (url === "wss://gateway.discord.gg") {
|
||||
url = `${
|
||||
shard.state === ShardState.Resuming ? shard.resumeGatewayUrl : shard.gatewayConfig.url
|
||||
}/?v=${shard.gatewayConfig.version}&encoding=json`;
|
||||
if (url.origin === "wss://gateway.discord.gg") {
|
||||
if (shard.state === ShardState.Resuming) {
|
||||
url = new URL(shard.resumeGatewayUrl);
|
||||
}
|
||||
url.searchParams.set("v", shard.gatewayConfig.version.toString());
|
||||
url.searchParams.set("encoding", "json");
|
||||
}
|
||||
|
||||
const socket = new WebSocket(url);
|
||||
|
||||
Reference in New Issue
Block a user