Discord: a way to ignore messages outside `respondToChannelIds`

Open
#1,180 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript
Domain
api, backend

Research direction

Start in packages/adapter-discord/src/index.ts, following the linked message handling and thread creation paths for direct and forwarded Gateway messages. Check how respondToChannelIds is used and where child threads and DMs are handled. Done means the proposed option prevents messages outside the configured channels from creating threads or reaching processMessage in both paths, while DMs and existing behavior remain intact.

Written by the indexing model from the issue text.

Description

Problem Statement

A Discord bot that should only work in one channel still answers mentions everywhere else in the server. respondToChannelIds (which I added in #715) only adds channels where every message counts as a mention. A mention in any other channel still counts as a mention, and the adapter creates a Discord thread on that message before any handler runs. Filtering in onNewMention is too late, because the thread is already there.

With respondToChannelIds: ["allowed"] on 4.45.0, a forwarded Gateway mention in other fires onNewMention and calls POST /channels/other/messages/<id>/threads, the same as a mention in allowed.

Proposed Solution

A separate option, so respondToChannelIds keeps its meaning for current users. For example ignoreOtherChannels: true: the adapter drops guild messages whose parent channel isn't in respondToChannelIds, and their child threads, before it creates a thread or calls processMessage. It applies to both the direct and the forwarded Gateway paths. DMs keep working.

Alternatives Considered

A shouldHandleMessage(message) hook that runs before thread creation. It's more flexible, but a channel allowlist covers the case I have.

Use Case
import { createDiscordAdapter } from "@chat-adapter/discord";

const discord = createDiscordAdapter({
  respondToChannelIds: [process.env.SUPPORT_CHANNEL_ID!],
  ignoreOtherChannels: true,
});
Priority

Nice to have

Contribution
  • I am willing to help implement this feature
Additional Context

Chat SDK 4.45.0, Node.js 24.21.0. We run this as a patch on the adapter today.

Dominant language
TypeScript
Stars
2.5k
Forks
355
Avg merge
2d 15h
Merged PRs (30d)
42

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vercel/chat

All issues in vercel/chat

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.