MythEclipseandClaude Opus 4.7 d5977c8845 fix: handle streaming JSON response from AI LLM API
- Fix fetchJson to extract JSON from streaming response text
- API returns text/event-stream with complete JSON object embedded
- Extract JSON by finding first { and last } in response
- Prevents "Unexpected non-whitespace character after JSON" parse errors
- Streaming response now properly parsed and analyzed

This resolves:
- AI analysis stuck on "[Streaming in progress...]"
- JSON parse failures on streaming responses
- AI analysis now completes successfully

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 04:00:31 +07:00
2026-05-13 15:28:25 +07:00
2026-05-12 19:38:23 +07:00

🎙️ Discord Voice Recorder Bot

Bot Discord yang otomatis join ke voice channel saat startup dan merekam suara semua pengguna yang bicara. File audio disimpan secara lokal dalam format .ogg.

Dibangun dengan Bun + discord.js + @discordjs/voice.


📋 Prasyarat

  • Bun >= 1.0
  • FFmpeg (untuk encoding audio)
    # Ubuntu/Debian
    sudo apt install ffmpeg
    
    # Arch
    sudo pacman -S ffmpeg
    
  • Discord Bot dengan permission:
    • Connect (join voice channel)
    • Use Voice Activity
    • Read Messages/View Channels
    • Privileged Intents: Server Members Intent (aktifkan di Developer Portal)

⚙️ Setup

1. Clone & Install

cd /path/to/bot
bun install

2. Konfigurasi .env

cp .env.example .env

Edit .env:

DISCORD_TOKEN=your_bot_token_here
VOICE_CHANNEL_ID=your_voice_channel_id_here
GUILD_ID=your_guild_id_here
RECORDINGS_DIR=./recordings

Cara mendapatkan ID:

  • Aktifkan Developer Mode di Discord (Settings → Advanced → Developer Mode)
  • Klik kanan pada voice channel → Copy Channel ID → paste ke VOICE_CHANNEL_ID
  • Klik kanan pada server/guild → Copy Server ID → paste ke GUILD_ID
  • Token bot dari Discord Developer Portal → Bot → Reset Token

3. Invite Bot ke Server

Di Developer Portal → OAuth2 → URL Generator:

  • Scopes: bot
  • Bot Permissions: Connect, Use Voice Activity, View Channels

Copy URL, buka di browser, pilih server.


🚀 Menjalankan Bot

# Development (auto-restart saat file berubah)
bun run dev

# Production
bun run start

Bot akan langsung join ke voice channel yang ditentukan dalam .env.


📁 Struktur File Rekaman

recordings/
  ├── 123456789-1709900000000.ogg   # <user-id>-<timestamp>.ogg
  ├── 987654321-1709900001234.ogg
  └── ...

Setiap kali user bicara dan berhenti (>1 detik diam), satu file .ogg baru dibuat.


📁 Struktur Proyek

bot/
├── src/
│   ├── index.ts       # Entry point — login & auto-join
│   └── recorder.ts    # Core recording logic
├── recordings/        # File audio tersimpan (otomatis dibuat)
├── .env               # Konfigurasi (buat dari .env.example)
├── .env.example
├── package.json
└── tsconfig.json
S
Description
Bete Discord moderation watcher
Readme
26 MiB
Languages
TypeScript 97.1%
Nix 1%
Shell 0.8%
CSS 0.7%
PLpgSQL 0.4%