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:
Core Dependencies
- @discordjs/voice: 0.16.0
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: 0.0.8

Encryption Libraries
- sodium-native: 4.0.4
- sodium: 3.0.2
- libsodium-wrappers: 0.7.13
- tweetnacl: 1.0.3

FFmpeg
- version: 6.0-static https://johnvansickle.com/ffmpeg/
- libopus: yes
Core Dependencies
- @discordjs/voice: 0.16.0
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: 0.0.8

Encryption Libraries
- sodium-native: 4.0.4
- sodium: 3.0.2
- libsodium-wrappers: 0.7.13
- tweetnacl: 1.0.3

FFmpeg
- version: 6.0-static https://johnvansickle.com/ffmpeg/
- libopus: yes
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
d.js toolkit
d.js toolkit15mo ago
- 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 OP
artyshan
artyshanOP15mo ago
I've installed it now
Core Dependencies
- @discordjs/voice: 0.16.0
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: 0.0.8

Encryption Libraries
- sodium-native: 4.0.4
- sodium: 3.0.2
- libsodium-wrappers: 0.7.13
- tweetnacl: 1.0.3

FFmpeg
- version: 6.0-6
- libopus: yes
Core Dependencies
- @discordjs/voice: 0.16.0
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: 0.0.8

Encryption Libraries
- sodium-native: 4.0.4
- sodium: 3.0.2
- libsodium-wrappers: 0.7.13
- tweetnacl: 1.0.3

FFmpeg
- version: 6.0-6
- libopus: yes
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)
d.js docs
d.js docs15mo ago
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 one for each class if applicable
<AudioPlayer | VoiceConnection>
.on('debug', console.log)
.on('error', console.error)
// Add one for each class if applicable
<AudioPlayer | VoiceConnection>
.on('debug', console.log)
.on('error', console.error)
- Add an error listener to the stream you are passing to the resource:
<Stream>.on('error', console.error)
<Stream>.on('error', console.error)
Note: The <> represents classes that need to be adapted to their respective name in your code
artyshan
artyshanOP15mo ago
Here are some logs but I'm not sure what to make of it
[1695592382240] FROM PLAYER: state change:
from {"status":"idle","resource":false,"stepTimeout":false}
to {"status":"buffering","resource":true,"stepTimeout":false}
[1695592382335] FROM PLAYER: state change:
from {"status":"buffering","resource":true,"stepTimeout":false}
to {"status":"playing","missedFrames":0,"playbackDuration":0,"resource":true,"stepTimeout":false}
[1695592382359] FROM CONNECTION: [NW] [WS] >> {"op":5,"d":{"speaking":1,"delay":0,"ssrc":418685}}
[1695592382460] FROM CONNECTION: [NW] [WS] >> {"op":5,"d":{"speaking":0,"delay":0,"ssrc":418685}}
[1695592382460] FROM PLAYER: state change:
from {"status":"playing","missedFrames":0,"playbackDuration":120,"resource":true,"stepTimeout":false}
to {"status":"idle","resource":false,"stepTimeout":false}
[1695592394169] FROM CONNECTION: [NW] [WS] >> {"op":3,"d":1695592394169}
[1695592394206] FROM CONNECTION: [NW] [WS] << {"op":6,"d":1695592394169}
[1695592382240] FROM PLAYER: state change:
from {"status":"idle","resource":false,"stepTimeout":false}
to {"status":"buffering","resource":true,"stepTimeout":false}
[1695592382335] FROM PLAYER: state change:
from {"status":"buffering","resource":true,"stepTimeout":false}
to {"status":"playing","missedFrames":0,"playbackDuration":0,"resource":true,"stepTimeout":false}
[1695592382359] FROM CONNECTION: [NW] [WS] >> {"op":5,"d":{"speaking":1,"delay":0,"ssrc":418685}}
[1695592382460] FROM CONNECTION: [NW] [WS] >> {"op":5,"d":{"speaking":0,"delay":0,"ssrc":418685}}
[1695592382460] FROM PLAYER: state change:
from {"status":"playing","missedFrames":0,"playbackDuration":120,"resource":true,"stepTimeout":false}
to {"status":"idle","resource":false,"stepTimeout":false}
[1695592394169] FROM CONNECTION: [NW] [WS] >> {"op":3,"d":1695592394169}
[1695592394206] FROM CONNECTION: [NW] [WS] << {"op":6,"d":1695592394169}
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?
[1695592382460] FROM CONNECTION: [NW] [WS] >> {"op":5,"d":{"speaking":0,"delay":0,"ssrc":418685}}
[1695592382460] FROM CONNECTION: [NW] [WS] >> {"op":5,"d":{"speaking":0,"delay":0,"ssrc":418685}}
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 tomorrow
ShompiFlen
ShompiFlen15mo ago
what 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
artyshan
artyshanOP15mo ago
I've posted the full code in the original post. Resource format js MP3 and duration is 3s
ShompiFlen
ShompiFlen15mo ago
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?
artyshan
artyshanOP15mo ago
yes, I've just ran it couple of times but with no luck also tested .wav and .ogg, the effect is the same
FaiThiX
FaiThiX15mo ago
i had the same problem, and if i used the ffmpeg npm package instead of ffmpeg-static it works fine on linux
artyshan
artyshanOP15mo ago
I've installed ffmpeg npm package but dependency report still shows 6.0-static tried on Windows - same problem
Core Dependencies
- @discordjs/voice: 0.16.0
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: 0.0.8

Encryption Libraries
- sodium-native: 4.0.4
- sodium: 3.0.2
- libsodium-wrappers: 0.7.13
- tweetnacl: 1.0.3

FFmpeg
- version: 6.0-essentials_build-www.gyan.dev
- libopus: yes
Core Dependencies
- @discordjs/voice: 0.16.0
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: 0.0.8

Encryption Libraries
- sodium-native: 4.0.4
- sodium: 3.0.2
- libsodium-wrappers: 0.7.13
- tweetnacl: 1.0.3

FFmpeg
- version: 6.0-essentials_build-www.gyan.dev
- libopus: yes
ShompiFlen
ShompiFlen15mo ago
can you show your folder structure? and if necessary an updated code too
artyshan
artyshanOP15mo ago
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
ShompiFlen
ShompiFlen15mo ago
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
artyshan
artyshanOP15mo ago
ok. thanks!
Want results from more Discord servers?
Add your server