#22946: fix(discord): reject thread creation in thread/voice/stage channels
channel: discord
size: XS
Cluster:
Signal and Discord Fixes
## Summary
- Adds a type guard in `createThreadDiscord()` that rejects thread creation when the target channel is a thread, voice, or stage channel
- Discord returns an opaque "Cannot execute action on this channel type" error in these cases — this gives the agent a clear, actionable error message instead
The existing channel type detection (added for forum channel support) already fetches the channel type. This builds on that by checking for unsupported types before proceeding.
Closes #20613
## Test plan
- [ ] Verify thread creation still works normally in text channels
- [ ] Verify thread creation still works in forum/media channels
- [ ] Verify attempting to create a thread in a thread returns a clear error message
- [ ] Verify attempting to create a thread in a voice channel returns a clear error message
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds validation to prevent thread creation in unsupported Discord channel types (threads, voice, and stage channels) before making the API call. When these channel types are detected, the function now throws a descriptive error message instead of letting Discord return an opaque "Cannot execute action on this channel type" error.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The change adds defensive validation that improves error messaging without changing existing behavior. It uses the same channel type detection pattern already present in the code and follows existing code patterns in the codebase for similar validation. The error is thrown before any API calls are made, preventing unnecessary Discord API requests.
- No files require special attention
<sub>Last reviewed commit: 4a20819</sub>
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#17254: fix(discord): intercept text-based slash commands instead of forwar...
by robbyczgw-cla · 2026-02-15
73.9%
#23158: discord: harden preflight/reply path against slow lookup latency
by danielstarman · 2026-02-22
73.9%
#17513: fix(discord): respect groupPolicy in channel config fallback (#4555)
by aronchick · 2026-02-15
73.6%
#7585: Tests: fix lint in discord auto-thread race test
by justinhuangcode · 2026-02-03
73.5%
#12074: feat(discord): enhanced forum post creation with multi-tag support
by xiaoyaner0201 · 2026-02-08
73.4%
#12204: fix(discord): resolve numeric guildId/channelId pairs in channel al...
by mcaxtr · 2026-02-09
72.9%
#22940: fix(discord): detect voice messages for preflight transcription bef...
by aldoeliacim · 2026-02-21
71.8%
#14443: fix(telegram): skip General topic thread ID for all chat types (#14...
by lailoo · 2026-02-12
71.2%
#21463: fix(discord): prevent WebSocket death spiral + fix numeric channel ID…
by akropp · 2026-02-20
71.0%
#22951: feat(discord): make thread session isolation configurable
by iamhitarth · 2026-02-21
70.8%