diff --git a/docker-compose.yml b/docker-compose.yml index 100d8ef..90a91d9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,14 +8,12 @@ services: ports: - "2333:2333" environment: - 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 + - LAVALINK_SERVER_PASSWORD=${LAVALINK_PASSWORD} + # Removed LAVALINK_PLUGIN_URLS environment variable volumes: - ./application.yml:/opt/Lavalink/application.yml:ro,Z - # Optional: Persist downloaded plugins if needed, though downloading on start is fine - # - lavalink-plugins:/plugins + # Mount local plugins directory into the container + - ./plugins:/plugins:ro # Add healthcheck to verify Lavalink is ready healthcheck: # Use CMD-SHELL to allow environment variable expansion for the password @@ -24,22 +22,7 @@ services: timeout: 5s 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 - " + # Removed command override, will use default image entrypoint bot: build: . diff --git a/src/structures/ShoukakuEvents.js b/src/structures/ShoukakuEvents.js index f029e65..c099e4e 100644 --- a/src/structures/ShoukakuEvents.js +++ b/src/structures/ShoukakuEvents.js @@ -25,18 +25,19 @@ class MusicPlayer { return this.players.get(guildId); } - // Get Shoukaku node - const node = this.client.shoukaku.options.nodeResolver(this.client.shoukaku.nodes); - if (!node) { - throw new Error('No available Lavalink nodes!'); - } + // Get Shoukaku instance and node + const shoukaku = this.client.shoukaku; // Get the main shoukaku instance + const node = shoukaku.options.nodeResolver(shoukaku.nodes); + if (!node) { + throw new Error('No available Lavalink nodes!'); + } - try { - // Create a new connection to the voice channel - const connection = await this.client.shoukaku.joinVoiceChannel({ - guildId: guildId, - channelId: voiceChannel, - shardId: 0, + try { + // Create a new connection to the voice channel using the shoukaku instance + const connection = await shoukaku.joinVoiceChannel({ + guildId: guildId, + channelId: voiceChannel, + shardId: 0, // Assuming shardId 0, adjust if sharding deaf: true }); @@ -100,10 +101,12 @@ class MusicPlayer { return this; }, + shoukaku: shoukaku, // Store shoukaku instance on the player object + // Destroy the player and disconnect destroy() { - // Use the main Shoukaku instance to leave the channel - this.client.shoukaku.leaveVoiceChannel(this.guild); + // Use the stored Shoukaku instance to leave the channel + this.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}`);