Skip to content

fix(discord): add Partials.Channel to gateway client for DM support#128

Merged
haydenbleasel merged 4 commits intovercel:mainfrom
iamtraction:patch-1
Mar 1, 2026
Merged

fix(discord): add Partials.Channel to gateway client for DM support#128
haydenbleasel merged 4 commits intovercel:mainfrom
iamtraction:patch-1

Conversation

@iamtraction
Copy link
Contributor

The Discord adapter's runGatewayListener creates a discord.js Client with GatewayIntentBits.DirectMessages but without Partials.Channel. discord.js requires this partial to receive DM events. Without it, DM MessageCreate events are silently dropped.

The gateway client requests DirectMessages intent but doesn't include `Partials.Channel`, which discord.js requires to emit DM events. Without it, all DM `MessageCreate` events are silently dropped.

Signed-off-by: TRACTION <19631364+iamtraction@users.noreply.github.com>
@vercel
Copy link
Contributor

vercel bot commented Feb 27, 2026

@iamtraction is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@haydenbleasel
Copy link
Member

Investigated this and can confirm the fix is correct. Here's the evidence:

The mechanism (discord.js v14 source)

MessageCreate.js does this when a message arrives:

const channel = this.getChannel({ id: data.channel_id, ... });
if (channel) {
  // ... emit Events.MessageCreate
}

Action.js's getPayload (which getChannel calls) does:

getPayload(data, manager, id, partialType, cache) {
  return this.client.options.partials.includes(partialType)
    ? manager._add(data, cache)    // Partials.Channel enabled → construct channel
    : manager.cache.get(id);       // Not enabled → lookup cache (returns undefined for DMs)
}

Discord's API stopped sending CHANNEL_CREATE for DM channels, so they're never in the cache. Without Partials.Channel, getPayload returns undefined, the if (channel) check fails, and the event is silently dropped — no error, no warning.

Maintainer confirmation

  • discord.js#5516monbrey (discord.js team): "The v8 Discord API/gateway does not emit CHANNEL_CREATE for DM Channels. As a result, they don't exist in discord.js cache and messages won't emit for them. Enabling the CHANNEL partial should fix the issue."

  • discord.js#7699monbrey: "DM channels don't fire the channelCreate event which means they don't get placed in the discord.js cache. As the channel is uncached, messageCreate events for it won't fire unless you enable the Channel partial also."

  • discord.js#7487kyranet (discord.js team) in the design roadmap: "Discord stopped sending us DM channels during the READY dispatch... if somebody wanted to receive messages from DMs, not only they would need to specify the intent, but they would need to find out that a second step is needed: specifying Partials.Channels."

TL;DR

Both GatewayIntentBits.DirectMessages and Partials.Channel are required. The current code has the intent but not the partial, so DM events are silently dropped at runtime. Types and builds pass fine because it's a runtime cache lookup issue, not a type error. Fix is correct and minimal.

@vercel
Copy link
Contributor

vercel bot commented Mar 1, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
chat Ignored Ignored Open in v0 Mar 1, 2026 2:56am

@haydenbleasel
Copy link
Member

Thanks @iamtraction great catch 🙏

@haydenbleasel haydenbleasel merged commit 1a37385 into vercel:main Mar 1, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants