#Leaves automatically without even touching the audio file once

47 messages · Page 1 of 1 (latest)

quaint pilot
#

Basically ive coded my play command with ytdl-core to see if anything is going wrong however it just isn't playing the audio file, it says it's connecting after it joins the channel then it says its playing audio one millisecond later it just disconnects (will send screenshots in a bit)

gray sundialBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

quaint pilot
#

this is a screenshot of the bot editing the message right after joining, hasn't even touched the audio file that ytdl piped, at all

#

my ytfiles folder already has the audio files ready (my play.ts is in ZBot-En \ ZBot-En \ commands)

oblique kettle
#

Why are you downloading the video instead of passing the stream directly to the resource?

#

I personally use this configs in the Ytdl that may help:

{
quality'highestaudio', 
highWaterMark1048576 * 64, 
dlChunkSize0, 
};
#

Also add an error listener to:

  • The ytdl stream
  • The player
  • The connection

So you can catch errors

quaint pilot
#

i didnt notice that was a solution 🥲

#

but either way can I still just pass it directly into the stream or how do I do it with YTDL and stuff

oblique kettle
#

Bc I think your problem is, you are trying to read a video that's not fully downloaded yet

oblique kettle
#

Add the error listeners it will help you a lot!!!

#

The connection and the player also has an debug event which is useful

quaint pilot
#

or do I just pass it directly without the .pipe

oblique kettle
#

Simple as passing a string

#

Assign to a const an use it as param

#

No need for fancy stream things

quaint pilot
#
const downloadedFile = ytdl(link)

const audioResource = createAudioResource(downloadedFile)
oblique kettle
#

Test it, lol

quaint pilot
#

or easier

const audioResource = createAudioResource(ytdl(link))

will either work?

#

ok

#

but i gotta like compile it all lmfao

oblique kettle
#

downloadedFile.on('error', console.error)

quaint pilot
#

ive prob already compiled both of them but imma test it first and then add your suggestions

#

works @oblique kettle ty, also another question

#

if say a song ends would that be the idle event?

quaint pilot
#

because say i have a queue system for a server

#

and i wanna play the next song

oblique kettle
quaint pilot
#

goddamn error

lemme add the error listeners immediately

gray sundialBOT
oblique kettle
#

Actually no, it will go to the idle

gray sundialBOT
gray sundialBOT
#

guide Library: Handling errors - Taking action within the Idle state
read more

quaint pilot
#

this one?

quaint pilot
oblique kettle
oblique kettle
quaint pilot
#

tysm for the help its working now