The system does not work when the bot is on have voice channel and when someone enters the sound

When i put the bot in the voice channel with the command, the command does not work when someone comes or when someone enters the voice normally, the bot enters the voice and plays the mp3, if they exit and enter, the bot stops talking
33 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!
ZeKe
ZeKeOP15mo ago
my code
ZeKe
ZeKeOP15mo ago
need help @ShompiFlen I remember you helped me before and i tagged you for that. i have been waiting for 2 days to get help with something in the @discord.js/voice module but no one has helped me, i apologize for tagging you, can you please help me? uzgun (Sorry for tag)
ShompiFlen
ShompiFlen15mo ago
i did tell you that your bot should join the voice channel through a command instead of a voice state update, you havent changed this this looks like the same code from last week
ZeKe
ZeKeOP15mo ago
It join voice channel with a command but then what should i do with the 'connection'
ShompiFlen
ShompiFlen15mo ago
the same thing you do here in the voice state update
ZeKe
ZeKeOP15mo ago
Joining the voice channel with this command
ShompiFlen
ShompiFlen15mo ago
just copy and paste your voice state update over to the command file and then start debugging it
ZeKe
ZeKeOP15mo ago
So should i log this section with console.log() and see the output? (I wanted to say that the connection here is undefined)
ShompiFlen
ShompiFlen15mo ago
of course its undefined because you are not defining a connection anywhere again just get rid of all the code on the voice state update event, you dont need it there anymore move it to your command
ZeKe
ZeKeOP15mo ago
So should i do it like this? I wrote all the imports after sending the ss
ShompiFlen
ShompiFlen15mo ago
your if statememt in line 28 is not going to work because you dont have a newstate there. I think you can just remove that anyways
ZeKe
ZeKeOP15mo ago
I made a code like this, but this time it gives an error like below, how do i fix it?
throw new Error("Cannot play a resource that has already ended.");
^

Error: Cannot play a resource that has already ended.
throw new Error("Cannot play a resource that has already ended.");
^

Error: Cannot play a resource that has already ended.
I think i accidentally left the ping sender on in the reply, sorry. I think i need to sleep and this will be left for tomorrow, good night hoping to fix it tomorrow <:pepe_smile:884630934060695574>
ShompiFlen
ShompiFlen15mo ago
and we are back to the voice state event.... you are moving and adding code to this script in unnecessary ways
ZeKe
ZeKeOP15mo ago
But how can i make it shorter? This code was not working
ShompiFlen
ShompiFlen15mo ago
yea because newstate is not defined if you dont know how to define variables then its gonna be hard for me to help knowing the basics is also on the rules of this server
ZeKe
ZeKeOP15mo ago
I fixed them but it was not happening again Trying again
ZeKe
ZeKeOP15mo ago
not true?
ZeKe
ZeKeOP15mo ago
When it's like this, when you enter the voice, it doesn't say anything (Successfully connecting to the voice channel) I need to sleep and this will be left for tomorrow, good night hoping to fix it tomorrow :) I will read what you wrote tomorrow
ShompiFlen
ShompiFlen15mo ago
i am not sure as to why you are using a timeout inside the VoiceConnectionstatus.Ready event, just start playing the music when the bot is ready. Also would be more useful if you show the entire script And last, please just remove everything from the voiceStateUpdate event since you are not going to be using it anymore
ZeKe
ZeKeOP15mo ago
In order not to lose them, i put them in the comment line and only worked with the system in the commands
ZeKe
ZeKeOP15mo ago
Here's my code;
No description
ZeKe
ZeKeOP15mo ago
When you enter the voice, sometimes you get pinged or it loads a little late, i used timeout to prevent this, sometimes i see that when i enter the voice channel i delayed for 1-2 seconds
ShompiFlen
ShompiFlen15mo ago
you code looks correct I dont see the issue is the sound not going through? is it not playing at all?
ZeKe
ZeKeOP15mo ago
It not playing at all
ShompiFlen
ShompiFlen15mo ago
can you place console.log("Ready to play audio") inside your connection.on(VoiceConnectionstatus.Ready) event?
ZeKe
ZeKeOP15mo ago
Okey, i'm trying
ZeKe
ZeKeOP15mo ago
He wrote it, but his voice doesn't say it
No description
ZeKe
ZeKeOP15mo ago
I corrected the old one because it was the wrong extension but it didn't work again
No description
ShompiFlen
ShompiFlen15mo ago
your audio resource path is wrong why did you change it since when did you change it the path to the resource is just ./output/hg_h.mp3
ZeKe
ZeKeOP15mo ago
it worked, i typed url instead of making a file like ./ thank you for your help ohh sorry Can i ask you one more question? When this happens, it only works when i run the command and a member enters the voice channel, but not if they leave the voice channel and re-enter
ShompiFlen
ShompiFlen15mo ago
what do you mean "when this happens" what happens what is happening
ZeKe
ZeKeOP15mo ago
when this code is* In this code, when i open the bot and run the command, it works when i enter the sound, it does not work only if i exit the voice channel and re-enter, or if I throw the bot out of the sound and exit the voice channel myself and put the bot back in with the command and enter, it still does not work (I will send a message from dm to the members coming to the voice channel)
Want results from more Discord servers?
Add your server