No description
  • Squirrel 96.4%
  • TypeScript 3.5%
Find a file
2026-05-18 07:12:41 +07:00
.github/workflows fix: register new github public remote for selfbot submodule and update workflow to checkout recursively 2026-05-17 22:53:13 +07:00
docs/superpowers docs: add implementation plan for robust moderation and tests 2026-05-18 04:37:00 +07:00
drizzle/migrations fix: make moderation index migration portable 2026-05-14 20:19:47 +07:00
frontend feat: add searchMessages function and corresponding API endpoint for message queries 2026-05-18 06:39:12 +07:00
scripts feat: add installation script for yt-dlp and update package.json 2026-05-15 21:40:20 +07:00
src fix: wrap parsed moderation response in results object for LLM variations 2026-05-18 07:12:41 +07:00
tests feat: add searchMessages function and corresponding API endpoint for message queries 2026-05-18 06:39:12 +07:00
vendor chore: update subproject commit to indicate dirty state 2026-05-17 18:24:17 +07:00
.dockerignore feat: add Docker configuration and automated deployment workflows for VPS orchestration 2026-05-17 21:23:50 +07:00
.env.example feat: split text and voice channel selection 2026-05-15 15:58:38 +07:00
.gitignore chore: remove test environment configuration file 2026-05-17 17:35:37 +07:00
.gitmodules fix: register new github public remote for selfbot submodule and update workflow to checkout recursively 2026-05-17 22:53:13 +07:00
biome.json feat: enhance message capture and processing with backlog support 2026-05-15 06:52:20 +07:00
CLAUDE.md chore: add pnpm workspace configuration with only built dependencies 2026-05-14 01:07:50 +07:00
components.json feat: migrate and redesign dashboard to modern React 2026-05-16 19:17:34 +07:00
debug-screen.ts refactor: remove Discord-video-stream submodule and integrate streaming functionality 2026-05-17 05:10:46 +07:00
deploy.sh fix: implement smart docker compose vs legacy docker-compose command fallback for VPS 2026-05-17 22:08:03 +07:00
docker-compose.yml feat: add Docker configuration and automated deployment workflows for VPS orchestration 2026-05-17 21:23:50 +07:00
Dockerfile fix: register new github public remote for selfbot submodule and update workflow to checkout recursively 2026-05-17 22:53:13 +07:00
drizzle.config.ts fix: update drizzle config to read env vars directly for CLI compatibility 2026-05-14 16:14:48 +07:00
package.json a 2026-05-17 19:39:46 +07:00
pnpm-lock.yaml a 2026-05-17 19:39:46 +07:00
pnpm-workspace.yaml refactor: remove Discord-video-stream submodule and integrate streaming functionality 2026-05-17 05:10:46 +07:00
postcss.config.js feat: migrate and redesign dashboard to modern React 2026-05-16 19:17:34 +07:00
README.md feat: add installation script for yt-dlp and update package.json 2026-05-15 21:40:20 +07:00
setup-postgres.sh feat: add PostgreSQL config and dependencies 2026-05-14 14:44:01 +07:00
tailwind.config.js feat: migrate and redesign dashboard to modern React 2026-05-16 19:17:34 +07:00
test_dank.ts fix: address LLM square bracket mapping format and resolve Biome import formatting 2026-05-18 04:40:54 +07:00
test_dank2.ts fix: address LLM square bracket mapping format and resolve Biome import formatting 2026-05-18 04:40:54 +07:00
test_out.nut feat: add streaming demuxer tests and implement dual-stream output piping in streaming service 2026-05-17 20:44:13 +07:00
test_stream.ts fix: address LLM square bracket mapping format and resolve Biome import formatting 2026-05-18 04:40:54 +07:00
tsconfig.json feat: add multimodal analysis support to LLM moderation client by processing image attachments 2026-05-17 23:56:04 +07:00
vitest.config.ts style: organize imports after dashboard rebuild 2026-05-14 21:19:43 +07:00

Discord Moderation Watcher Bot

Bot monitoring Discord yang merekam voice channel, menangkap pesan teks, menyimpan attachment, menjalankan analisis opsional, dan menyediakan dashboard web real-time.

Stack utama: Node.js, pnpm, TypeScript, discord.js-selfbot-v13, @discordjs/voice, Express, WebSocket, Drizzle ORM, SQLite/PostgreSQL, React, Vite, Vitest, dan Biome.

Prasyarat

  • Node.js versi modern yang kompatibel dengan TypeScript dan Vite.
  • pnpm 10.x. Repo ini dipin ke pnpm@10.25.0.
  • FFmpeg tersedia di PATH untuk proses muxing audio dan playback media.
  • yt-dlp tersedia di PATH untuk resolve audio YouTube, search result YouTube, dan Spotify track.
  • Native audio dependencies dapat dibuild di mesin lokal (@discordjs/opus, better-sqlite3, sodium-native).

Install FFmpeg:

# Ubuntu/Debian
sudo apt install ffmpeg

# Arch
sudo pacman -S ffmpeg

Install yt-dlp:

pnpm run install:yt-dlp

Script installer akan memakai package manager yang tersedia (pacman, apt-get, dnf, brew) atau fallback ke pipx/pip.

Setup

pnpm install
cp .env.example .env

Edit .env sesuai server yang dimonitor:

DISCORD_TOKEN=your_token_here
MONITOR_GUILD_ID=your_guild_id_here
RECORDINGS_DIR=./recordings
WEBSERVER_PORT=3000
DATABASE_TYPE=sqlite

Catatan: project ini memakai selfbot library, bukan bot token Discord standar. Pastikan penggunaan sesuai risiko dan aturan platform yang berlaku.

Menjalankan

# Bot/server utama dengan auto-restart
pnpm run dev

# Production-style start
pnpm run start

# Dashboard frontend dev server
pnpm run dev:web

Dashboard build production disajikan dari public/app setelah menjalankan:

pnpm run build:web

Command Development

# Type checking
pnpm run typecheck

# Lint
pnpm run lint

# Format
pnpm run format

# Test
pnpm run test

# Build frontend + TypeScript
pnpm run build

# Install external yt-dlp CLI for YouTube/search/Spotify track playback
pnpm run install:yt-dlp

Database

Default database adalah SQLite di .muxer-queue.db. PostgreSQL dapat dipakai dengan DATABASE_TYPE=postgres dan konfigurasi DATABASE_URL atau variabel POSTGRES_*.

# Generate migration Drizzle
pnpm run db:generate

# Jalankan migration via drizzle-kit
pnpm run db:migrate

# Jalankan migration programmatic
pnpm run db:migrate:programmatic

# Buka Drizzle Studio
pnpm run db:studio

Fitur

  • Voice recording ke segment .ogg per user.
  • Metadata JSON per segment audio.
  • Text message capture untuk pesan baru, edit, dan delete.
  • Attachment capture dan upload ke endpoint Picser.
  • SQLite/PostgreSQL via Drizzle ORM.
  • REST API dan WebSocket untuk dashboard.
  • Dashboard React untuk pesan, gambar, voice, media playback, dan moderation review.
  • Media playback dari direct URL, file lokal, YouTube URL, search terms, dan Spotify track URL.
  • Metrics Prometheus di endpoint server.
  • Retry dengan backoff untuk operasi eksternal.
  • AI moderation analysis opsional via konfigurasi AI_*.

Struktur Rekaman

recordings/
  <user-id>/
    <user-id>-<session-start>-0.ogg
    <user-id>-<session-start>-0.json
    <user-id>-<session-start>-1.ogg
    <user-id>-<session-start>-1.json

Segment duration dikontrol oleh RECORDING_SEGMENT_MS.

Struktur Proyek

src/
  index.ts                    Entry point Discord client dan server
  recorder.ts                 Voice recording pipeline
  recorder/                   Audio stream, decoder, segment metadata
  moderation/                 Message capture, storage, uploads, AI review
  database/                   Drizzle setup, schema, migrations
  routes/                     Express route modules
  webserver.ts                Express + WebSocket server
  retry.ts                    Retry helper berbasis p-retry
  audio/ffmpegProcess.ts      Direct ffmpeg process wrapper
frontend/                     React dashboard source
public/app/                   Dashboard build output
tests/                        Vitest tests
drizzle/migrations/           Database migrations

Konfigurasi Penting

Lihat .env.example untuk daftar lengkap. Variabel utama:

  • DISCORD_TOKEN — token akun/client yang dipakai selfbot.
  • MONITOR_GUILD_ID — guild yang dimonitor untuk moderation capture.
  • RECORDINGS_DIR — direktori output audio.
  • WEBSERVER_PORT — port HTTP/WebSocket.
  • DATABASE_TYPEsqlite atau postgres.
  • PICSER_UPLOAD_URL — endpoint upload attachment.
  • AI_ANALYSIS_ENABLED — aktifkan/nonaktifkan analisis AI.
  • AI_LLM_API_KEY, AI_LLM_BASE_URL, AI_LLM_MODEL — konfigurasi provider LLM.

Verifikasi Setelah Perubahan

Sebelum menjalankan lama atau deploy, jalankan:

pnpm install
pnpm run typecheck
pnpm run lint
pnpm run test
pnpm run build

Catatan Library Modernization

Project memakai Zod untuk validasi runtime, Drizzle untuk database, dan wrapper node:child_process langsung untuk FFmpeg. Library lama class-transformer, class-validator, dan fluent-ffmpeg sudah tidak dipakai.