Skip to content

Dev#11447

Closed
Dijnie wants to merge 4 commits intodiscordjs:mainfrom
Dijnie:dev
Closed

Dev#11447
Dijnie wants to merge 4 commits intodiscordjs:mainfrom
Dijnie:dev

Conversation

@Dijnie
Copy link

@Dijnie Dijnie commented Mar 10, 2026

No description provided.

tidvn added 4 commits March 10, 2026 12:36
…pabilities)

Phase 1 of discord.js selfbot port. Creates foundational modules:
- SuperProperties: browser fingerprint for X-Super-Properties header and gateway IDENTIFY
- BrowserHeaders: Chrome-like Sec-CH-UA, Sec-Fetch-*, Discord locale/timezone headers
- Capabilities: gateway bitfield (22525) matching discord.py-self defaults
- Build number fetching via cordapi.dolfi.es API with hardcoded fallback
API returns {client: {build_number}} not {properties: {client_build_number}}.
Verified: fetches build number 507841 successfully.
- authPrefix defaults to '' (raw token, no "Bot " prefix)
- User-Agent defaults to Chrome UA from SuperProperties
- All requests include browser headers (Sec-CH-UA, X-Super-Properties, etc.)
- SuperProperties added to RESTOptions for shared fingerprinting
- RequestHeaders interface allows arbitrary browser headers
Phase 3 — Gateway:
- Rewrite IDENTIFY payload to user-style (capabilities, super_properties, client_state, presence) — no intents, no shard array
- Change fetchGatewayInformation return type from /gateway/bot to /gateway
- Add UserIdentifyData and UserPresenceData interfaces for type safety
- Default to single shard, remove session_start_limit dependency

Phase 4 — Client Integration:
- Remove intents requirement from Client constructor (capabilities used instead)
- Switch gateway endpoint from Routes.gatewayBot() to Routes.gateway()
- Simplify login() — no more "Bot " prefix stripping
- Make Client options parameter optional
- Remove ShardClientUtil, set this.shard = null
- Remove dead fetchRecommendedShardCount and unused imports
@vercel
Copy link

vercel bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
discord-js Skipped Skipped Mar 10, 2026 7:03am
discord-js-guide Skipped Skipped Mar 10, 2026 7:03am

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fe0eae55-1ed3-4d63-a1e4-42d4e3ed14d7

📥 Commits

Reviewing files that changed from the base of the PR and between f3942a6 and 35d97a5.

📒 Files selected for processing (17)
  • packages/discord.js/src/client/Client.js
  • packages/discord.js/src/index.js
  • packages/discord.js/src/sharding/ShardingManager.js
  • packages/discord.js/src/util/Options.js
  • packages/discord.js/src/util/Util.js
  • packages/rest/src/lib/REST.ts
  • packages/rest/src/lib/utils/browser-headers.ts
  • packages/rest/src/lib/utils/constants.ts
  • packages/rest/src/lib/utils/super-properties.ts
  • packages/rest/src/lib/utils/types.ts
  • packages/rest/src/shared.ts
  • packages/ws/src/index.ts
  • packages/ws/src/strategies/context/IContextFetchingStrategy.ts
  • packages/ws/src/utils/capabilities.ts
  • packages/ws/src/utils/constants.ts
  • packages/ws/src/ws/WebSocketManager.ts
  • packages/ws/src/ws/WebSocketShard.ts

📝 Walkthrough

Walkthrough

This pull request removes sharding support from the discord.js client, introduces browser-fingerprinting headers via SuperProperties in the REST layer, and refactors the WebSocket layer to support user accounts through a new capabilities system. The client constructor now defaults to an empty options object, gateway fetches return only a URL, and identify payloads are restructured without intents or shard information.

Changes

Cohort / File(s) Summary
Client Sharding Removal
packages/discord.js/src/client/Client.js, packages/discord.js/src/index.js, packages/discord.js/src/sharding/ShardingManager.js
Removes GatewayIntentBits, ShardClientUtil usage; shard property now always null. Auto-shard calculation removed; throws error when amount is 'auto'. Removes fetchRecommendedShardCount from public exports.
Options & Utilities
packages/discord.js/src/util/Options.js, packages/discord.js/src/util/Util.js
Adds default online presence to ClientOptions. Removes fetchRecommendedShardCount function and userAgentAppendix composition. Simplifies option validation by removing explicit intents and presence checks.
REST Browser Fingerprinting
packages/rest/src/lib/REST.ts, packages/rest/src/lib/utils/browser-headers.ts, packages/rest/src/lib/utils/super-properties.ts, packages/rest/src/lib/utils/constants.ts, packages/rest/src/lib/utils/types.ts, packages/rest/src/shared.ts
Introduces SuperProperties class for constructing user-agent and browser headers with base64 encoding and build-number fetching. Adds generateBrowserHeaders utility. Updates REST request headers to merge browser fingerprinting when superProperties is available. Changes authPrefix default from 'Bot' to empty string. Exports new browser and super-properties utilities.
WebSocket Capabilities System
packages/ws/src/index.ts, packages/ws/src/utils/capabilities.ts, packages/ws/src/strategies/context/IContextFetchingStrategy.ts, packages/ws/src/utils/constants.ts
Introduces CapabilityFlags enum and Capabilities class for bitfield operations. Adds UserPresenceData and UserIdentifyData interfaces for user-style identify payloads. Replaces intents with capabilities throughout. Updates default presence to online state and identify properties to use SuperProperties. Removes intents from fetching strategy options.
WebSocket Manager & Shard Simplification
packages/ws/src/ws/WebSocketManager.ts, packages/ws/src/ws/WebSocketShard.ts
Simplifies gateway information fetch to return only \{ url: string \}; removes shard count calculation and session_start_limit validation. Removes GatewayIntentBits, GatewayIdentifyData, and related bot-specific types. Updates identify payload to UserIdentifyData without shard array or intents. Relaxes token handling to allow overwriting. Defaults to single shard if shardIds not provided.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant REST
    participant SuperProperties
    participant Gateway
    participant WebSocketManager
    
    Client->>REST: Create request with token
    REST->>SuperProperties: generate browser headers (if superProperties available)
    SuperProperties-->>REST: browserHeaders (Accept, User-Agent, X-Super-Properties, etc.)
    REST->>REST: merge browserHeaders into request.headers
    REST->>REST: set Authorization header (authPrefix + token or just token)
    REST->>Gateway: send request with browser fingerprinting
    Gateway-->>REST: response
    REST-->>Client: return data
    
    Client->>WebSocketManager: connect()
    WebSocketManager->>Gateway: fetchGatewayInformation()
    Gateway-->>WebSocketManager: { url: string }
    WebSocketManager->>WebSocketManager: getShardIds (default to 1 shard)
    WebSocketManager->>WebSocketManager: spawn shards
    WebSocketManager->>WebSocketManager: identify with UserIdentifyData (capabilities, presence, no intents)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@discordjs discordjs locked and limited conversation to collaborators Mar 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Denied

Development

Successfully merging this pull request may close these issues.

2 participants