mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
feat: use globally available WebSocket client in runtimes that have it (#10042)
This commit is contained in:
@@ -7,7 +7,7 @@ import { URLSearchParams } from 'node:url';
|
|||||||
import { TextDecoder } from 'node:util';
|
import { TextDecoder } from 'node:util';
|
||||||
import { inflate } from 'node:zlib';
|
import { inflate } from 'node:zlib';
|
||||||
import { Collection } from '@discordjs/collection';
|
import { Collection } from '@discordjs/collection';
|
||||||
import { lazy } from '@discordjs/util';
|
import { lazy, shouldUseGlobalFetchAndWebSocket } from '@discordjs/util';
|
||||||
import { AsyncQueue } from '@sapphire/async-queue';
|
import { AsyncQueue } from '@sapphire/async-queue';
|
||||||
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
||||||
import {
|
import {
|
||||||
@@ -80,11 +80,9 @@ export interface SendRateLimitState {
|
|||||||
resetAt: number;
|
resetAt: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(vladfrangu): enable this once https://github.com/oven-sh/bun/issues/3392 is solved
|
const WebSocketConstructor: typeof WebSocket = shouldUseGlobalFetchAndWebSocket()
|
||||||
// const WebSocketConstructor: typeof WebSocket = shouldUseGlobalFetchAndWebSocket()
|
? (globalThis as any).WebSocket
|
||||||
// ? (globalThis as any).WebSocket
|
: WebSocket;
|
||||||
// : WebSocket;
|
|
||||||
const WebSocketConstructor: typeof WebSocket = WebSocket;
|
|
||||||
|
|
||||||
export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
|
export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
|
||||||
private connection: WebSocket | null = null;
|
private connection: WebSocket | null = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user