fix(lavalink): Correct Lavalink connection URL format and update deprecated code

This commit is contained in:
2025-04-24 00:52:16 +08:00
parent e54c23cc63
commit 854cf12d64
2 changed files with 9 additions and 8 deletions

View File

@@ -26,14 +26,14 @@ class MusicPlayer {
}
// Get Shoukaku node
const node = this.client.shoukaku.getNode();
const node = this.client.shoukaku.options.nodeResolver(this.client.shoukaku.nodes);
if (!node) {
throw new Error('No available Lavalink nodes!');
}
try {
// Create a new connection to the voice channel
const connection = await node.joinChannel({
const connection = await this.client.shoukaku.joinVoiceChannel({
guildId: guildId,
channelId: voiceChannel,
shardId: 0,
@@ -56,7 +56,7 @@ class MusicPlayer {
this.current = track;
// Start playback
await this.connection.playTrack({ track: track.track });
await this.connection.playTrack({ track: track.encoded });
this.playing = true;
return this;
@@ -207,7 +207,8 @@ class MusicPlayer {
* @returns {Promise<Array>} Array of track objects
*/
async search({ query, requester }) {
const node = this.client.shoukaku.getNode();
// Get the first available node
const node = this.client.shoukaku.options.nodeResolver(this.client.shoukaku.nodes);
if (!node) throw new Error('No available Lavalink nodes!');
try {