Skip to content

Add fetchGatewayInformation to ws 1.x #11071

@Digital39999

Description

@Digital39999

Which package is this bug report for?

discord.js

Issue description

When passing custom WebSocket options to the Client constructor, the ws property is currently typed to only allow large_threshold, version, buildStrategy, and buildIdentifyThrottler.
Even though WebSocketManager internally supports these options, the typings in ClientOptions block their use and specifically overrides fetchGatewayInformation.

I have tried to go around that in #11070 before realization that this should already be supported in different way, would've directly made pr for that, but I have no clue where/how WebSocketOptions are generated.

Issue location: Client.js lines 166–167

Code sample

const client = new Client({
	intents: [
		GatewayIntentBits.Guilds,
		GatewayIntentBits.GuildMessages,
		GatewayIntentBits.MessageContent,
	],
	ws: {
		// 'fetchGatewayInformation' does not exist in type 'WebSocketOptions'.
		fetchGatewayInformation: () => {
			return {
				url: 'wss://gateway.discord.gg',
			};
		},
	},
});

Versions

  • discord.js 14.22.1
  • Node.js 22.12.0
  • TypeScript 5.1.6

Issue priority

Medium (should be fixed soon)

Which partials do you have configured?

Not applicable

Which gateway intents are you subscribing to?

Not applicable

I have tested this issue on a development release

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions