Yet another "no voice" thread
Hi, I'm trying to write my first Discord bot. I'm struggling with playing a sound in voice channel. I've read many posts here about the bot not playing any audio, but haven't found any solution. One strange thing I've found while debugging is, the bot switches to
Idle
state immediately after switching to Playing
state, but I can;t figure out what's wrong. Here's my code (I've simplified it in order to create a minimal failing example)
Dependency report:
Will greatly appreciate any help. Cheers!Pastebin
import { Client, Events, GatewayIntentBits, REST, Routes } from 'di...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
14 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!
- ✅
Marked as resolved by OPI've installed it now
still no sound 😦
btw I'm currently testing on Linux, but can switch to Windows if that could be the case
also forgot to mention an important thing - there are no errors (wrapped the whole command handling in
try/catch
)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
Here are some logs but I'm not sure what to make of it
you can see the player goes from
playing
to idle
after just 130ms (I've put epoch milliseconds in square brackets). Do you know what this log means?
looks like it causes the player to stop (player state change happens in the exact same time)
ok, I guess this log just says that speaking
has been set to 0
turns out the player stops playing because the resource's readable
getter returns false at some point. I will debug further tomorrowwhat is your resources format and duration?
show us the code that handles the connection, creation of the resource and playback
and uhh... im assuming you do have the VoiceStateUpdate intent
I've posted the full code in the original post. Resource format js MP3 and duration is 3s
hmm
it says playback duration 120 which doesn't make sense to be honest
your code looks correct so far
have you tried making your bot join the vc and then running /test a couple of times?
yes, I've just ran it couple of times but with no luck
also tested .wav and .ogg, the effect is the same
i had the same problem, and if i used the ffmpeg npm package instead of ffmpeg-static it works fine on linux
I've installed ffmpeg npm package but dependency report still shows 6.0-static
tried on Windows - same problem
can you show your folder structure?
and if necessary an updated code too
oh my god. thanks! appraently I just had wrong path to the test sound file. How didn't it produce an error though?
yeah, even after renaming the sound file (and leaving the old name in code) there is no error, even with logging debug information
yea im not entirely sure but i shouldve asked for the file structure a while ago
apparently it just doesnt throw an error if the path is wrong or not present
this has happened before a bunch of times
wrong paths to the file and stuff
ok. thanks!