const queue = [] const video = await youtube.getVideo(args.slice().join(" ")) if(queue.length < 0){ console.log(video.id) try{ const embed = new discord.MessageEmbed() .setTitle(video.title) .setDescription(video._length.minutes + "mins" + ":" + video._length.seconds + "seconds") .setImage(video.thumbnails.maxres.url) setURL(`https://www.youtube.com/watch?v=${video.id}`) message.channel.send(embed) }catch { console.error(); } const connection = await message.member.voice.channel.join(); const dispatcher = connection.play(ytdl(`https://www.youtube.com/watch?v=${video.id}`)) .on('finish', () =>{ console.log('ended') connection.disconnect(); }) } else { queue.push(args.slice().join(" ")) console.log(queue.length) const connection = await message.member.voice.channel.join(); const dispatcher = connection.play(ytdl(`https://www.youtube.com/watch?v=${video.id}`)) .on('finish', async () => { console.log('playing next now') const connection = await message.member.voice.channel.join(); const dispatcher = connection.play(ytdl(`https://www.youtube.com/watch?v=${video.id}`)) queue.shift() }) }