Error: https://i.imgur.com/UKGSIjs.png
Code reproducing this error is:
https://github.com/AbsoluteZero273/niconico/blob/master/bot/commands/voice/music.js
Error basically happens in play and execute function. error event is emitted in the middle of the song playback and will subsequently emit end event
Note: Connection should not be a problem as I tested this in both VPS with 18Mbps connection and locally too.
Maybe it's an issue with YTDL? Could you try piping the audio to a file and then creating a read stream that discord.js can use?
how do I create readable stream from a file?
I ran this
const ytdl = require('ytdl-core');
const fs = require('fs');
ytdl('https://www.youtube.com/watch?v=K0_sanTbsYw', {filter: 'audioonly'})
.pipe(fs.createWriteStream('test.mp3'));
test.mp3 is downloaded without any issue and it runs perfectly
By creating stream from the file, did you mean VoiceConnection.playFile ?
Ok I tried creating readable stream from a file and fed it to playStream. I am still having the same problem. The song gets played smoothly until some minutes and then same error is thrown.
Code:
const stream = fs.createReadStream('/home/absolutezero273/Documents/Projects/Dumps/yttest/test.mp3');
voiceConnData.dispatcher = voiceConn.playStream(stream);
Does test.mp3 play normally outside of discord.js?
Yes, it plays normally
Seems to be the addition of the new unpipe listener, will check later.
i get this too, if you ignore the error everything works fine
after speaking to @AbsoluteZero273 his issue occurs in mid playback where mine only happens on end which explains why i can ignore the issue.
lil more info where i can help i get the error on Ubuntu 16.04.1 and Kali 2016.2
but not on CentOS 7.2
Same case as @trinitynet running on windows, however some YTDL streams suddenly end towards the end (but not right at the end)
Fixed in 77e83fb85af09d2e2cd767ae04aa9dad348e5c5f :smile:
Most helpful comment
Fixed in 77e83fb85af09d2e2cd767ae04aa9dad348e5c5f :smile: