Skip to content

Commit 69ac2e1

Browse files
committed
Add Lavalink music playback with slash and prefix controls
Integrate Riffy and Lavalink v4 for play, queue, join, nowplaying, and music subcommands. Add prefix shortcuts for join, leave, pause, resume, skip, stop, and volume. Separate pause and resume with synced now-playing embed buttons. Include Lavalink docker-compose service and env configuration.
1 parent 9ec5503 commit 69ac2e1

32 files changed

Lines changed: 2410 additions & 8 deletions

.env.example

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,18 @@ BACKUP_DIR=./backups
5454
BACKUP_RETENTION_DAYS=14
5555
POSTGRES_RESTORE_URL=
5656

57+
# Music (Lavalink + Riffy) — requires a Lavalink v4 server
58+
# Local dev: run Lavalink via docker compose (see README), then use localhost below.
59+
# Docker Compose bot service uses LAVALINK_HOST=lavalink instead.
60+
LAVALINK_HOST=localhost
61+
LAVALINK_PORT=2333
62+
LAVALINK_PASSWORD=youshallnotpass
63+
LAVALINK_SECURE=false
64+
LAVALINK_NAME=Main
65+
# Optional: override nodes as JSON array (for multiple Lavalink nodes)
66+
# LAVALINK_NODES=[{"host":"lavalink","port":2333,"password":"youshallnotpass","secure":false,"name":"Main"}]
67+
LAVALINK_SEARCH_PLATFORM=ytmsearch
68+
LAVALINK_REST_VERSION=v4
69+
5770
# Optional Feature/API Keys
5871
TMDB_API_KEY=

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,22 @@ TitanBot is fully containerized for easy deployment.
111111
docker-compose up -d
112112
```
113113

114-
This will start both the bot and a persistent PostgreSQL database.
114+
This will start the bot, PostgreSQL, and Lavalink (when music is enabled).
115+
116+
### Music
117+
118+
Music uses [Lavalink v4](https://github.com/lavalink-devs/Lavalink) via [Riffy](https://github.com/riffy-rb/riffy), similar to [Musicify](https://github.com/codebymitch/Musicify).
119+
120+
1. Set in `.env`:
121+
```env
122+
LAVALINK_HOST=lavalink
123+
LAVALINK_PORT=2333
124+
LAVALINK_PASSWORD=youshallnotpass
125+
LAVALINK_SECURE=false
126+
```
127+
2. With Docker Compose, Lavalink is included automatically when you `docker compose up`.
128+
3. On Railway, deploy Lavalink separately or as another service and point `LAVALINK_HOST` at the private hostname.
129+
4. Use `/play <song>` from a voice channel, or `/join` to connect without playing. Prefix shortcuts: `join`, `np`, `leave`, `pause`, `resume`, `skip`, `stop`, `volume <0-100>`, or `music <subcommand>`. Use `/nowplaying` and `/queue` for status; `/music` for loop, shuffle, seek, and other controls.
115130

116131
### Using GitHub Container Registry
117132

docker-compose.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,27 @@ services:
1010
- GUILD_ID=${GUILD_ID}
1111
- MULTI_GUILD=${MULTI_GUILD:-false}
1212
- DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
13+
- LAVALINK_HOST=lavalink
14+
- LAVALINK_PORT=2333
15+
- LAVALINK_PASSWORD=${LAVALINK_PASSWORD:-youshallnotpass}
16+
- LAVALINK_SECURE=false
1317
- PORT=3000
1418
depends_on:
1519
db:
1620
condition: service_healthy
21+
lavalink:
22+
condition: service_started
23+
networks:
24+
- titan-network
25+
26+
lavalink:
27+
image: ghcr.io/lavalink-devs/lavalink:4
28+
container_name: titanbot-lavalink
29+
restart: unless-stopped
30+
environment:
31+
- LAVALINK_PASSWORD=${LAVALINK_PASSWORD:-youshallnotpass}
32+
volumes:
33+
- ./lavalink/application.yml:/opt/Lavalink/application.yml
1734
networks:
1835
- titan-network
1936

lavalink/application.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
server:
2+
port: 2333
3+
address: 0.0.0.0
4+
5+
lavalink:
6+
plugins:
7+
- dependency: "dev.lavalink.youtube:youtube-plugin:1.13.5"
8+
snapshot: false
9+
server:
10+
password: "${LAVALINK_PASSWORD:youshallnotpass}"
11+
sources:
12+
youtube: false
13+
bandcamp: true
14+
soundcloud: true
15+
http: true
16+
local: false
17+
18+
plugins:
19+
youtube:
20+
enabled: true
21+
allowSearch: true
22+
allowDirectVideoIds: true
23+
allowDirectPlaylistIds: true
24+
clients:
25+
- MUSIC
26+
- ANDROID_TESTSUITE
27+
- WEB

0 commit comments

Comments
 (0)