diff --git a/application.yml b/application.yml index 9829a0a..824d7a1 100644 --- a/application.yml +++ b/application.yml @@ -22,8 +22,8 @@ lavalink: bufferDurationMs: 400 frameBufferDurationMs: 5000 gc-warnings: true - plugins: - - dependency: "dev.lavalink.youtube:youtube-plugin:1.12.0" # Use the new YouTube source plugin + # Removed dependency plugin loading + pluginsDir: "/plugins" # Specify directory for manually loaded plugins plugins: youtube: @@ -37,4 +37,4 @@ plugins: - MUSIC - ANDROID_VR - WEB - - WEBEMBEDDED \ No newline at end of file + - WEBEMBEDDED diff --git a/docker-compose.yml b/docker-compose.yml index f6933c5..100d8ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,17 +8,38 @@ services: ports: - "2333:2333" environment: - - LAVALINK_SERVER_PASSWORD=${LAVALINK_PASSWORD} + LAVALINK_SERVER_PASSWORD: ${LAVALINK_PASSWORD} + # Add environment variable for plugin URLs (using the format you provided) + LAVALINK_PLUGIN_URLS: | + https://github.com/lavalink-devs/youtube-source/releases/download/1.12.0/youtube-plugin-1.12.0.jar volumes: - ./application.yml:/opt/Lavalink/application.yml:ro,Z + # Optional: Persist downloaded plugins if needed, though downloading on start is fine + # - lavalink-plugins:/plugins # Add healthcheck to verify Lavalink is ready healthcheck: - test: > - curl -H "Authorization: ${LAVALINK_PASSWORD}" -f http://localhost:2333/version - interval: 5s + # Use CMD-SHELL to allow environment variable expansion for the password + test: ["CMD-SHELL", "curl -H \"Authorization: $$LAVALINK_SERVER_PASSWORD\" -f http://localhost:2333/version || exit 1"] + interval: 10s # Increased interval slightly timeout: 5s - retries: 3 - start_period: 5s # Give Lavalink time to start up initially + retries: 5 + start_period: 15s # Give Lavalink time to start up initially + # Override entrypoint/command to download plugins first + command: > + sh -c " + apk add --no-cache curl && \ + mkdir -p /plugins && \ + echo 'Downloading Lavalink plugins...' && \ + echo \"$$LAVALINK_PLUGIN_URLS\" | while IFS= read -r url; do \ + if [ -n \"$$url\" ]; then \ + filename=$(basename \"$$url\") && \ + echo \"Downloading $$url to /plugins/$$filename\" && \ + curl -L -o \"/plugins/$$filename\" \"$$url\"; \ + fi \ + done && \ + echo 'Downloads complete. Starting Lavalink...' && \ + java -jar Lavalink.jar + " bot: build: . @@ -29,9 +50,9 @@ services: env_file: - .env environment: - - LAVALINK_HOST=lavalink - - LAVALINK_PORT=2333 - - LAVALINK_PASSWORD=${LAVALINK_PASSWORD} + LAVALINK_HOST: lavalink + LAVALINK_PORT: 2333 + LAVALINK_PASSWORD: ${LAVALINK_PASSWORD} # Update depends_on to wait for healthcheck depends_on: lavalink: diff --git a/src/structures/ShoukakuEvents.js b/src/structures/ShoukakuEvents.js index 53bf93b..f029e65 100644 --- a/src/structures/ShoukakuEvents.js +++ b/src/structures/ShoukakuEvents.js @@ -102,9 +102,12 @@ class MusicPlayer { // Destroy the player and disconnect destroy() { - this.client.shoukaku.leaveVoiceChannel(this.guild); - musicPlayer.players.delete(this.guild); - return this; + // Use the main Shoukaku instance to leave the channel + this.client.shoukaku.leaveVoiceChannel(this.guild); + // Remove the player instance from the manager's map + musicPlayer.players.delete(this.guild); + logger.debug(`Destroyed player for guild ${this.guild}`); + return this; // Return this for potential chaining, though unlikely needed here }, // Add a track to the queue or play it if nothing is playing