fix(lavalink): Correct Lavalink connection URL format and update deprecated code
This commit is contained in:
parent
e54c23cc63
commit
854cf12d64
@ -27,17 +27,17 @@ const client = new Client({
|
||||
],
|
||||
});
|
||||
|
||||
// Define Shoukaku nodes
|
||||
// Define Shoukaku nodes - fix the URL format to properly connect to Lavalink
|
||||
const Nodes = [
|
||||
{
|
||||
name: 'lavalink',
|
||||
url: `${process.env.LAVALINK_HOST || 'localhost'}:${process.env.LAVALINK_PORT || '2333'}/v4/websocket`,
|
||||
url: `${process.env.LAVALINK_HOST || 'localhost'}:${process.env.LAVALINK_PORT || '2333'}`,
|
||||
auth: process.env.LAVALINK_PASSWORD || 'youshallnotpass',
|
||||
secure: process.env.LAVALINK_SECURE === 'true'
|
||||
}
|
||||
];
|
||||
|
||||
// Initialize Shoukaku
|
||||
// Initialize Shoukaku with proper configuration
|
||||
client.shoukaku = new Shoukaku(new Connectors.DiscordJS(client), Nodes, {
|
||||
moveOnDisconnect: false,
|
||||
resume: true,
|
||||
@ -46,7 +46,7 @@ client.shoukaku = new Shoukaku(new Connectors.DiscordJS(client), Nodes, {
|
||||
});
|
||||
|
||||
// Show the actual Lavalink connection details (without exposing the actual password)
|
||||
logger.info(`Lavalink connection configured to: ${process.env.LAVALINK_HOST}:${process.env.LAVALINK_PORT}/v4/websocket (Password: ${process.env.LAVALINK_PASSWORD ? '[SET]' : '[NOT SET]'})`);
|
||||
logger.info(`Lavalink connection configured to: ${process.env.LAVALINK_HOST}:${process.env.LAVALINK_PORT} (Password: ${process.env.LAVALINK_PASSWORD ? '[SET]' : '[NOT SET]'})`);
|
||||
|
||||
// Collections for commands
|
||||
client.commands = new Collection();
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user