fix(discord): handle DMs via raw gateway events#87
Open
claylevering wants to merge 1 commit into
Open
Conversation
discord.js v14 does not reliably emit messageCreate for DMs even with Partials.Channel and Partials.Message enabled. The raw gateway event fires correctly, so DMs are now processed directly from the raw event while guild messages continue through the standard messageCreate handler. - Add Partials.Channel and Partials.Message to Client options - Add raw gateway listener for DM MESSAGE_CREATE events - Skip DMs in messageCreate handler (handled by raw listener) - Update DM test to use triggerRawDM helper - Add Partials to discord.js test mock Tested with discord.js 14.26.2 on a live bot — confirmed raw events arrive for DMs while messageCreate does not. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
messageCreatefor DMs even withPartials.ChannelandPartials.MessageenabledMESSAGE_CREATEevent fires correctly for DMs, so DMs are now processed directly from the raw eventmessageCreatehandler (unaffected)What changed
Partials.ChannelandPartials.Messageto Client optionsMESSAGE_CREATEevents (noguild_id)messageCreatehandler now skips DMs (if (!message.guild) return) to avoid double-processingtriggerRawDMhelper instead oftriggerMessagePartialsto discord.js test mockHow it was found
Confirmed on a live bot running discord.js 14.26.2:
packet.t === 'MESSAGE_CREATE'with noguild_id)messageCreatenever fires for DMs, even with Partials enabledmessageCreateTest plan
🤖 Generated with Claude Code