discord-music-bot

Discord music bot template written in Rust using serenity and lavalink-rs.

Features

  • Slash commands: /ping, /join, /play, /leave
  • LavaLink integration for audio playback
  • Modular command handler structure

Prerequisites

  • Rust (stable toolchain)
  • A Discord application with bot token
  • LavaLink server running (see LavaLink)

Setup

  1. Copy .env.example to .env and fill in your credentials:

    DISCORD_TOKEN=your_discord_bot_token
    LAVALINK_HOST=127.0.0.1
    LAVALINK_PORT=2333
    LAVALINK_PASSWORD=your_lavalink_password
    
  2. Build the project:

    cargo build --release
    
  3. Run the bot:

    cargo run --release
    

Project Structure

  • src/main.rs - Bot entry point, initializes Serenity and LavaLink clients
  • src/handler.rs - Serenity event handlers (ready, interaction, voice updates)
  • src/lavalink_handler.rs - LavaLink event handlers
  • src/state.rs - TypeMap keys for shared state
  • src/utils.rs - Utility functions (env management)
  • src/commands/ - Modular slash command definitions and handlers

Commands

  • /ping - Replies with "Pong!"
  • /join - Bot joins your voice channel
  • /play url:<URL> - Plays audio from the given URL
  • /leave - Bot leaves the voice channel

TODO

  • Implement actual command logic in src/commands/*.rs
  • Add error handling and command concurrency management
  • Expand LavaLink event handlers

License

MIT

Description
Discord bot made in Rust using serenity and lavalink-rs
Readme GPL-3.0 3.2 MiB
Languages
TypeScript 89.2%
JavaScript 5.8%
Shell 2.9%
Dockerfile 2.1%