Discord Multi Bot (Music / Manage / Notify)

TypeScript 기반 디스코드 봇 템플릿입니다. 음악 재생은 Lavalink(Shoukaku)로 동작합니다.

Stack

  • TypeScript + Node.js 20+
  • discord.js v14
  • PostgreSQL + Prisma
  • Redis + BullMQ
  • Lavalink + Shoukaku

1) 환경 변수

cp .env.example .env

.env 예시:

DISCORD_TOKEN=...
DISCORD_CLIENT_ID=...
DISCORD_GUILD_ID=... # 개발/테스트 서버 ID
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/discord_multibot
REDIS_URL=redis://localhost:6379/1
LAVALINK_NODE_NAME=local
LAVALINK_HOST=127.0.0.1
LAVALINK_PORT=2333
LAVALINK_PASSWORD=youshallnotpass
LAVALINK_SECURE=false
LOG_LEVEL=info

2) PostgreSQL 준비

예시:

docker run -d \
  --name discord-postgres \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=postgres \
  -e POSTGRES_DB=discord_multibot \
  -p 5432:5432 \
  -v discord_postgres_data:/var/lib/postgresql/data \
  postgres:16

프로젝트 루트에서:

docker compose -f docker-compose.lavalink.yml up -d

상태 확인:

docker logs -f discord-lavalink

4) 의존성/DB 초기화

npm install
npm run prisma:generate
npm run prisma:push

5) 실행

npm run dev

정상 로그 예시:

  • Guild commands registered
  • Bot ready

명령어

  • /play query:<검색어 또는 유튜브 URL>
  • /queue
  • /skip
  • /stop

Manage

  • /warn user:<user> reason:<string>
  • /warnings user:<user>

Notify

  • /notify_schedule channel:<channel> cron:<expr> message:<text>
  • /notify_list
  • /notify_disable rule_id:<id>

News

  • /news query:<optional>

Summarize (Google AI Studio)

  • /summarize url:<url> mode:<auto|fast|quality>

Translate

  • /translate text:<text> source:<optional> target:<optional>
  • 우선순위: DeepL API -> deepl-cli(web) -> Google Web v2

실제 사용 예시

  1. 봇과 사용자 모두 같은 음성 채널 입장

  2. 텍스트 채널에서:

    • /play query:아이유 밤편지
    • /play query:https://www.youtube.com/watch?v=...
  3. 제어:

    • /queue (대기열 확인)
    • /skip (다음 곡)
    • /stop (정지 + 음성채널 퇴장)
  4. 접두사 명령:

    • !play <검색어 또는 URL>
    • !queue
    • !skip
    • !stop
    • !뉴스 [키워드]
    • !news [keyword]
    • !요약 <url> [auto|fast|quality]
    • !summarize <url> [auto|fast|quality]
    • !번역 [source->target] <텍스트> (기본 auto->ko)
    • !translate [source->target] <text>
    • !ani "제목" (gds_dviewer 애니 검색)
    • !영화 "제목" / !movie "title" (gds_dviewer 영화 검색)

참고

  • REDIS_URL이 없으면 BullMQ 워커는 비활성화됩니다.
  • YouTube 재생 안정성은 Lavalink 서버 상태/플러그인에 영향받습니다.
  • 요약 기능은 GEMINI_API_KEY가 필요합니다.
  • 번역 기능은 DEEPL_API_KEY가 없으면 deepl-cli를 먼저 시도하고, 실패 시 Google Web v2를 사용합니다.
  • deepl-cli 테스트용 설정:
    • DEEPL_CLI_BIN=deepl
    • DEEPL_CLI_TIMEOUT_MS=45000
    • pyenv 사용 시 예시: DEEPL_CLI_BIN=/Users/yommi/.pyenv/versions/3.11.0/envs/FF_3.11/bin/deepl
  • !ani 기능 환경 변수:
    • GDS_DVIEWER_BASE_URL=http://127.0.0.1:9099/gds_dviewer/normal/explorer
    • GDS_DVIEWER_API_KEY=...
    • GDS_DVIEWER_SOURCE_ID=0
    • EXTERNAL_VIDEO_PLAYER_URL=https://your-domain/player/external_video_player.html (Discord 노출 URL 분리용, 권장)
Description
No description provided
Readme 1.5 MiB
Languages
TypeScript 98.1%
JavaScript 1.9%