Skip to content

ForeverInLaw/ForeverInMusic

Repository files navigation

ForeverInMusic

Discord music bot built with Discord.js, discord-player, Prisma, and Supabase. Supports YouTube and Spotify playback, queue management with interactive controls, and English/Russian localization. Access is limited to allowlisted guilds and roles.

Features

  • Slash commands for play/search/queue/controls (skip, stop, pause/resume, volume, seek, shuffle, clear, remove, language).
  • YouTube and Spotify inputs (tracks and playlists up to 500 items), with Spotify-to-YouTube conversion.
  • Now Playing message with button controls and volume adjustments.
  • Guild-level allowlist plus role-based permissions.
  • Owner-only allowlist onboarding (/owner allow) using BOT_OWNER_ID.
  • English and Russian localization via i18next.
  • Prisma ORM backed by Supabase PostgreSQL.

Tech Stack

  • Runtime: Node.js 24+
  • Discord: discord.js 14, discord-player 7
  • Data: Prisma 5, Supabase PostgreSQL
  • i18n: i18next 25
  • Tooling: TypeScript 5, tsx, Vitest

Prerequisites

  • Node.js 24.x (LTS) and pnpm
  • FFmpeg available in PATH
  • Supabase PostgreSQL credentials (pooled and direct URLs)
  • Discord application with a bot token and client ID

Quick Start

  1. Install dependencies
    pnpm install

  2. Configure environment
    cp .env.example .env and fill in:

  • DISCORD_TOKEN / DISCORD_CLIENT_ID
  • DATABASE_URL (Supabase pooled, port 6543) and DIRECT_URL (session, port 5432)
  • Optional: SPOTIFY_CLIENT_ID / SPOTIFY_CLIENT_SECRET
  • Required: BOT_OWNER_ID (Discord user ID allowed to run /owner allow)
  1. Generate Prisma client and sync schema
    pnpm run db:generate
    pnpm run db:push

  2. Deploy slash commands to Discord
    pnpm run deploy-commands

  3. Run the bot
    Development: pnpm run dev
    Production: pnpm run build && pnpm start

Useful Scripts

  • pnpm run dev — watch + reload via tsx.
  • pnpm run build — TypeScript compile to dist/.
  • pnpm start — run compiled bot.
  • pnpm run deploy-commands — register slash commands.
  • pnpm run db:generate / pnpm run db:push / pnpm run db:studio — Prisma workflows.
  • pnpm test — run Vitest suite (unit tests present).

Project Structure

.
├── src/                 # TypeScript sources
│   ├── commands/        # Slash command implementations
│   ├── events/          # Discord event handlers
│   ├── handlers/        # Interaction routing (buttons, menus, player)
│   ├── services/        # Business logic (player, permissions, guild)
│   ├── i18n/            # i18next setup and locales (en/ru)
│   ├── utils/           # Embeds, buttons, validators, logger
│   └── index.ts         # Entry point
├── prisma/schema.prisma # Database schema
├── scripts/             # Command deployment
├── tests/               # Vitest unit/integration suites
└── dist/                # Build output

Key Behaviors

  • Allowlist: only guilds in the database can use the bot; guild activity flag enforced.
  • Role-based access: if roles are configured for a guild, only those roles may issue commands.
  • Owner allowlist activation: /owner allow upserts/activates the current guild; only the user ID in BOT_OWNER_ID may run it.
  • Queue limits: max 500 tracks; track duration and inactivity timeouts configurable via GuildSettings.
  • Localization: defaults to English; supports Russian.

Deployment Notes

  • Keep secrets out of version control (DISCORD_TOKEN, DISCORD_CLIENT_ID, DATABASE_URL, Spotify creds).
  • Ensure FFmpeg is installed on the host.
  • For process management, run the compiled dist/index.js under your preferred supervisor (e.g., PM2 or systemd).

License

PolyForm Noncommercial 1.0.0 (LICENSE). Commercial use is not permitted.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors