Audio Not Playing
Discord JS Ver 14.13.0, Voice ver 0.16.0, Node 16.14.0
The bot joins the channel that I am in, however it doesn't play any audio and doesn't give any errors, I don't understand why?
49 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!Log some values to see what’s happening. Does it stop executing at any point that you expect it to reach?
It seems to go through the entire script, logging all the way
The audio file is in the same folder as the script btw
it could quite possibly be the position of the audio file
I changed up the code a bit, but it still doesn't play a sound, also includes the logs
pretty confident that your issue is the path to the audio file
its not relative to the script the createAudioResource function is called
the path that it takes starts from the root of the project, where the package.json is most likely.
try
createAudioResource("./commands/soundstuff/critSong.mp3")
That didn't work, I have no idea why
no errors? no nothing?
wait why is your nodemodules folder inside your commands folder
that makes no sense
ah no wait it isnt
nevermind
Hm?
Yeah there is no errors whatsoever! I don't understand why?!
show me your dependencies
whatever is on package.json, also do you have ffmpeg installed and added in the environment variables of your system?
also upload your latest code to pastebin or something so i can see it
I do have ffmpeg, idk if there is a specific version for djs
package.json
there shouldnt but that one looks outdated...
It is a little old yeah
im pretty sure you need a couple more dependencies
What else?
like opus for example
opus?
so like npm install opus
did you follow this guide?
https://discordjs.guide/voice/#installation
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
i did initially
i'll install some more of those dependency
you dont need to install every of them, only one per category and as it says there, if you want to play audios that are different from webm opus and ogg you do need some extra dependencies. You are trying to play an mp3 file
although ffmpeg should be enough but try installing the sodium wrappers and a couple others
the recommended ones should be alright
Sodium is having trouble installing, do i really have to install VS 2015?
yes
you can install those through commandline though
i dont quite remember the command, something about build essentials
npm install --global --production --add-python-to-path windows-build-tools
It just seems to hang at one point
I still can't get sodium to work, and I feel i corrupted it somehow, but i have these dependencies
hmm
first of all i dont know why you have npm as a dependency there
if you hover over libsodium what does it say
That's just a spell checker extension I have
Don't mind it
So
what you mean by can't get sodium to work?, if you are getting any kind of errors in console from libraries or anything you should show it here, we can't really guess what is happening
There is no like errors at all
Its just not playing ANY audio, and I have no idea why
could you share your current code and generate a dependency report?
All of my code and the audio file is here, I'll generate the dep report rq
Okay so sodium did somehow install, but its like half corrupted, so I have two
just the relevant code in a pastebin please
1. the line in which you call
player.play()
is commented out
2. you didn't previously have an ogg file to play, but on the assumption that it's there, you'll want to specify the inputType
as StreamType.OggOpus
3. I notice you have some logs, so just to confirm, does LOG 3
log as expected?Yes
3. is yes
To debug your voice connection and player:
- Use
debug: true
when creating your VoiceConnection
and AudioPlayer
- Add an event listener to the <VoiceConnection> and the <AudioPlayer>:
- Add an error
listener to the stream you are passing to the resource:
Note: The <>
represents classes that need to be adapted to their respective name in your code
I do notice you aren't necessarily waiting for your connection to be ready, so it'd be nice to see this for both your player and connection
?
why does it go from playing to autopaused instantly?
that suggests that the player believes that it doesn't have any valid subscribed connections
please also listen to the
debug
event for your connection or otherwise ensure that your connection enters the Ready
stateBut I did?
And I put it right under
ok so then nothing even logs
please ensure you have the
GuildVoiceStates
intent🤦♂️ I feel like an idiot now
Yeah that was the issue