Please describe the problem you are having in as much detail as possible: with some songs that i play through the StreamDispatcher (seems to be ones that have silences at the beginning), the dispatcher will almost immediately finish and throw an error.
from what i've seen, these are the two errors that i'm receiving from calling the "debug" and "error" events of the dispatcher
this: Error: ffmpeg stream: write EPIPE
and this: Error [ERR_STREAM_DESTROYED]: ffmpeg stream: Cannot call write after a stream was destroyed
Include a reproducible code sample here, if possible:
/**
* @param {Discord.VoiceConnection} connection
* @param {String} url
*/
async function run(connection, url) // assuming these two variables aren't null
{
const video = ytdl(url, { highWaterMark: 5242880 });
video.on("error", (err) => console.log(err));
let dispatcher = connection.play(video);
dispatcher.on("finish", () => console.log("finished"));
break;
}
// recommended url: https://www.youtube.com/watch?v=Auk1oVI2Icw
// (this is one i've been using to test this issue)
original code from my project plus some comments from guiding:
async play() // this is my function for playing music on the bot
{
if (this.queue.length === 0) return;
if (!this.guild.me.voice || !this.guild.me.voice.channel) return;
let connection = this.guild.me.voice.connection;
if (!connection) return;
if (connection.dispatcher) return;
let track = this.queue[0];
let channel = this.guild.channels.cache.get(track.channelID);
switch (track.type)
{
//case "soundcloud" omitted
case "youtube":
{
const video = ytdl(track.url, { highWaterMark: 5242880 });
video.on("error", (err) => console.log(err));
channel.send(`playing: **${track.name}** // requester: **${track.requester.tag}**`);
let dispatcher = connection.play(video); // dispatcher will begin
dispatcher.setVolume(this.volume);
dispatcher.on("finish", () => this.finish()); // almost immediately the following will be called
// fyi: there isn't anything special in the function called, just some code to shift the queue
break;
}
}
}
Further details:
discord.js version: 12.4.1
Node.js version: v12.18.3
Operating system: Windows 10
Priority this issue should have – please be realistic and elaborate if possible: medium; it's not something that's urgent, but i'd like to do something about it soon enough.
Relevant client options:
partials: none
gateway intents: none
other: none
[ ] I have also tested the issue on latest master, commit hash: i have not tested on the master branch. my apologies.
if this doesn't actually have to do with discord.js, i apologize for the inconvenience.
Please describe the problem you are having in as much detail as possible: with some songs that i play through the
StreamDispatcher
(seems to be ones that have silences at the beginning), the dispatcher will almost immediately finish and throw an error. from what i've seen, these are the two errors that i'm receiving from calling the "debug" and "error" events of the dispatcher this:Error: ffmpeg stream: write EPIPE
and this:Error [ERR_STREAM_DESTROYED]: ffmpeg stream: Cannot call write after a stream was destroyed
Include a reproducible code sample here, if possible:
original code from my project plus some comments from guiding:
Further details:
Relevant client options:
if this doesn't actually have to do with discord.js, i apologize for the inconvenience.