fix(discord): force-fetch channels to prevent stale cache "not allowlisted" errors#1373
Closed
matt-landers wants to merge 1 commit intoanthropics:mainfrom
Closed
fix(discord): force-fetch channels to prevent stale cache "not allowlisted" errors#1373matt-landers wants to merge 1 commit intoanthropics:mainfrom
matt-landers wants to merge 1 commit intoanthropics:mainfrom
Conversation
…sted errors
Discord.js channel cache can return partial objects after idle, causing fetchAllowedChannel to fail even when the channel is correctly configured. Using { force: true } bypasses the cache, and handling partial channels ensures properties like recipientId and type are always populated.
Fixes anthropics#983
|
Thanks for your interest! This repo only accepts contributions from Anthropic team members. If you'd like to submit a plugin to the marketplace, please submit your plugin here. |
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
Fixes intermittent
channel X is not allowlistederrors caused by stale Discord.js channel cache. Relates to #983.After idle time or permission approval flows,
client.channels.fetch(id)can return partial/stale channel objects where properties likerecipientIdare null or incorrect, causingfetchAllowedChannelto reject valid channels.Changes
fetchTextChannel: Handle partial channels by callingch.fetch()whench.partialis truefetchAllowedChannel: Useclient.channels.fetch(id, { force: true })to bypass the Discord.js cache entirely, ensuring a fresh channel object on every outbound gate checkHow to reproduce
allowFromTesting
Verified fix on a live Discord group channel that was consistently failing after idle and after permission approvals. After applying { force: true }, replies work reliably regardless of cache state.