Discord Channels plugin: DISCORD_STATE_DIR env var is ignored (hardcoded path prevents multi-bot setup)

Resolved 💬 4 comments Opened Mar 24, 2026 by superwidetrack Closed May 23, 2026

Problem

The Discord channel plugin (plugin:discord@claude-plugins-official) hardcodes the state directory path in server.ts:

const STATE_DIR = join(homedir(), '.claude', 'channels', 'discord')

The README documents DISCORD_STATE_DIR as the way to run multiple bots on one machine:

To run multiple bots on one machine (different tokens, separate allowlists), point DISCORD_STATE_DIR at a different directory per instance.

However, this env var is never read in the code. Additionally, even when patching server.ts to use process.env.DISCORD_STATE_DIR, Claude Code does not forward shell environment variables to plugin subprocesses, making the fix ineffective.

Expected behavior

Each Claude Code session should be able to use its own Discord bot with a separate state directory:

export DISCORD_STATE_DIR=~/.claude/channels/discord-bot1
export DISCORD_BOT_TOKEN=<token1>
claude --channels plugin:discord@claude-plugins-official

# In another terminal:
export DISCORD_STATE_DIR=~/.claude/channels/discord-bot2
export DISCORD_BOT_TOKEN=<token2>
claude --channels plugin:discord@claude-plugins-official

Current workaround

Overwriting ~/.claude/channels/discord/.env with the correct bot token before each claude --channels start, and starting agents sequentially with delays. This is fragile and doesn't scale.

Environment

  • Claude Code v2.1.81
  • macOS (Darwin 25.3.0)
  • Plugin: discord@claude-plugins-official v0.0.1

Suggestion

  1. Read DISCORD_STATE_DIR in server.ts: const STATE_DIR = process.env.DISCORD_STATE_DIR || join(homedir(), '.claude', 'channels', 'discord')
  2. Ensure Claude Code forwards shell env vars (especially DISCORD_STATE_DIR and DISCORD_BOT_TOKEN) to plugin subprocesses

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗