anthropics / anthropics/claude-plugins-official

Discord plugin: DM channel rejected by fetchAllowedChannel despite correct access.json

オープン
#3,294 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
36.3k
フォーク
4.1k
平均マージ
2日 14時間
マージ済み PR(30日)
539

説明

## Bug

`download_attachment` and `reply` both fail with `channel is not allowlisted — add via /discord:access` when targeting a DM channel, even though:

1. The DM channel's `recipientId` (verified via Discord API: type 1, recipient matches) **is** in `access.json` → `allowFrom`
2. The channel was also listed in `groups` (removed it to test — same result either way)
3. Plugin reloaded (`/reload-plugins`) — same result
4. Plugin confirmed at latest version (0.0.4)

## Expected behavior

`fetchAllowedChannel()` in `server.ts` (line 403–412) should:
1. Fetch the channel
2. See `ch.type === ChannelType.DM`
3. Check `access.allowFrom.includes(ch.recipientId)` → true
4. Return the channel

## Actual behavior

The function throws `channel is not allowlisted` every time. Both `reply` and `download_attachment` hit this — they both go through `fetchAllowedChannel`.

## Hypothesis

Either:
- `ch.recipientId` is `undefined`/`null` at runtime (discord.js may not populate it on a bot-fetched DM channel without the recipients intent or without the channel being cached from an inbound message first)
- `ch.type` doesn't match `ChannelType.DM` at runtime (e.g. returns a numeric value that doesn't === the enum)

## Reproduction

1. Set up a DM between a bot and a user
2. Add the user's ID to `access.json` → `allowFrom`
3. Receive an inbound DM (works fine — inbound gate passes)
4. Try to `reply` or `download_attachment` targeting that DM channel ID
5. Observe the "not allowlisted" error

## Environment

- Claude Code 2.1.187
- Discord plugin 0.0.4
- Windows 11
- discord.js (whatever version ships with the plugin)

## Workaround

Using the bot token + REST API directly for DM operations (curl / Entes `send_discord`). Inbound DM delivery still works — only outbound tool calls through the plugin are affected.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start in server.ts around fetchAllowedChannel() at lines 403–412, then trace how reply and download_attachment pass the DM channel ID to it. Reproduce with a DM whose recipient ID is in access.json under allowFrom, and inspect the fetched channel's type and recipientId. Done means an allowlisted DM is accepted for both outbound operations without weakening checks for other channels.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
backend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
72/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。