1.5 KiB
1.5 KiB
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
-
Copy
.env.exampleto.envand fill in your credentials:DISCORD_TOKEN=your_discord_bot_token LAVALINK_HOST=127.0.0.1 LAVALINK_PORT=2333 LAVALINK_PASSWORD=your_lavalink_password -
Build the project:
cargo build --release -
Run the bot:
cargo run --release
Project Structure
src/main.rs- Bot entry point, initializes Serenity and LavaLink clientssrc/handler.rs- Serenity event handlers (ready, interaction, voice updates)src/lavalink_handler.rs- LavaLink event handlerssrc/state.rs- TypeMap keys for shared statesrc/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