I keep getting the error that connection is not defined in my code where is says "const dispatcher = serverQueue = queue.get(guild.id);"
function play(guild, song) {
const queue = new Map()
const serverQueue = queue.get(guild.id);
if (!song) {
serverQueue.voiceChannel.leave();
queue.delete(guild.id);
return;
}
const dispatcher = serverQueue.connection
.play(ytdl(song.url))
.on("finish", () => {
serverQueue.songs.shift();
play(guild, serverQueue.songs[0]);
})
.on("error", error => console.error(error));
dispatcher.setVolumeLogarithmic(serverQueue.volume / 5);
serverQueue.textChannel.send(`Start playing: **${song.title}**`);
}
I have tried adding the line "const connection = message.member.voice.channel();" but it says that message is not defined and then when I define message and then member it says the other words are not defined either.