介绍
# Discord Doctor
针对 Discord/Gateway 可用性问题、OAuth 令牌问题以及旧版 Clawdis 配置冲突的快速诊断与修复。
## 使用方法
```bash # Check status (diagnostic only) discord-doctor
# Check and auto-fix issues discord-doctor --fix ```
## 检查内容
1. **Discord 应用** - Discord 桌面应用是否正在运行(可选,用于监控) 2. **Gateway 进程** - Clawdbot gateway 守护进程是否正在运行 3. **Gateway HTTP** - gateway 是否在 18789 端口上响应 4. **Discord 连接** - bot 是否实际连接到 Discord(通过 `clawdbot health`) 5. **Anthropic OAuth** - 您的 OAuth 令牌是否有效或已过期 6. **旧版 Clawdis** - 检测会导致冲突的旧版 launchd 服务和配置目录 7. **近期活动** - 显示最近的 Discord 会话
## 自动修复功能
当使用 `--fix` 运行时,它可以:
- **启动 gateway**(如果未运行) - **安装缺失的 npm 包**(如 discord.js, strip-ansi) - **重启 gateway**(在修复依赖项后) - **移除旧版 launchd 服务**(`com.clawdis.gateway.plist`) - **备份旧版配置**(将 `~/.clawdis` 移动到 `~/.clawdis-backup`)
## 常见问题与修复
| 问题 | 自动修复操作 | |-------|-----------------| | Gateway 未运行 | 在 18789 端口启动 gateway | | 缺失 npm 包 | 运行 `npm install` + 安装指定包 | | Discord 已断开 | 重启 gateway 以重新连接 | | OAuth 令牌已过期 | 显示重新认证的说明 | | 旧版 launchd 服务 | 移除旧的 `com.clawdis.gateway.plist` | | 旧版 ~/.clawdis 配置 | 移动到 `~/.clawdis-backup` |
## OAuth 令牌问题
如果看到“Access token EXPIRED”,请运行: ```bash cd ~/Clawdis && npx clawdbot configure ``` 然后选择“Anthropic OAuth (Claude Pro/Max)”以重新认证。
## 旧版 Clawdis 迁移
如果您已从 Clawdis 升级到 Clawdbot,可能会存在导致 OAuth 令牌冲突的旧版遗留文件:
- **旧的 launchd 服务**:`~/Library/LaunchAgents/com.clawdis.gateway.plist` - **旧的配置目录**:`~/.clawdis/`
运行 `discord-doctor --fix` 可自动清理这些文件。
## 示例输出
``` Discord Doctor Checking Discord and Gateway health...
1. Discord App Running (6 processes)
2. Gateway Process Running (PID: 66156, uptime: 07:45)
3. Gateway HTTP Responding on port 18789
4. Discord Connection Discord: ok (@Clawdis) (321ms)
5. Anthropic OAuth Valid (expires in 0h 45m)
6. Legacy Clawdis No legacy launchd service No legacy config directory
7. Recent Discord Activity - discord:group:123456789012345678 (21h ago)
Summary All checks passed! Discord is healthy. ```