Play audio problem
Hello, I have a problem with the "@discordjs/voice" package, and the problem is in playing the sound. Well, to understand the problem, let's assume that there are two servers, the first is called Server 1 and the second is called Server 2. When I play songs on Server 1, the same song will play on Server 2. What is the solution to this problem?
49 Replies
- What are your intents?
GuildVoiceStates
is required to receive voice data!
- Show what dependencies you are using -- generateDependencyReport()
is exported from @discordjs/voice
.
- Try looking at common examples: https://github.com/discordjs/voice-examples.
- 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 staffplease also share your code exactly as it is when it produces this behavior
continuing from https://discord.com/channels/222078108977594368/824411059443204127/1302027616110248066 , both snippets should be erroring before even playing any audio
side note: it's heavily recommended to consolidate your event listeners into one and delegate from there
going entirely on a hunch, is it possible this event listener is inside a command?
It's an old version but I'm also facing the same problem.
No
It's like If someone join to the voice
The music start play
ok but I'm curious about the indenting combined with the several variables that aren't defined in this scope
where are
connection
and channel
defined?
could you share the whole file?But if a bot enters a voice room in multiple servers, a song will be played in all of these servers. I only want it in the server that the person entered.
yeah I understand the premise
your code just doesn't appear to be the whole picture
I think I deleted some definitions for you to try
which is why I asked for the code as it is
You can bring any song playback code
For try
The problem is not related to playing the song
The problem is related to playing the same song on multiple servers.
yes, which is why I'm asking for more of the code, since this code you provided isn't the direct source
I am unable to help you with this issue if you're unable to share the code that produces it
please share the whole file
This is a demo code from AI.
that's great
please share your code
You can apply the same problem to me
My friend, I deleted half of it to try and convert it to a handler.
well if you'd just like to me analyze this code, it only plays 1 file to everyone
so therefore all servers will receive the same audio
then I cannot help you with this issue
Why?
because I do not have access to the code that produces the issue
Consider this the code.
This is my code that is giving me trouble.
consider my answer
Yes this the problem
I need a help for this
Why does it play the same song on all servers?
because you've only told it to do so?
this is a single path for a single file
it only plays this one file
What should I do if
Because I did not find a logical solution
I'm not entirely sure what you're asking
are you just having trouble using a different path?
a path other than "./Song.mp3"?
The problem is when the bot plays the song, it plays it on all the servers the bot is on, but I want it on the server that I specify.
listen if you're expecting me to just imagine code that plays more than 1 song, I'm not going to do that
please share your code
if your friend has deleted half of it, please write new code, see if it still has the same issue, and if it does, come back and share it
@duck
You can apply it with this code
I cannot because this code does not have more than 1 song
Yes
you didn't understand me
What for one moment?
Do you mean that I should make each server have its own song?
I mean when these songs are played, for example, on a server His name
lol1
The song will play automatically on another server, for example, called lol2
I only want it when the song is playing on a server called lol1
Only works on this server
Do you understand me now?I do now understand what you're focused on, but the code provided would not produce this issue
each time this command is executed, a new player is created
every guild would also have its own
VoiceConnection
it should not be playing the same audio to every connection without every connection subscribing to the new AudioPlayer
I am unable to reproduce the issue you're describing with this code
I still believe that it would be easier to diagnose if you shared your code
furthermore it's also entirely possible that after finishing your new code, you find that it's been fixed by the new code, so I would still suggest finishing that firstI used this code and same problem (:
well it shouldn't have the same problem, and having run it just now myself, it does not appear to have the same problem
how have you confirmed it does?
could you share your logs?
I suppose coming back to the multiple audio files idea, it would actually help ensure things are distinct
if you were to play different sounds per server, does it still produce the same audio for both?
okay I will do
I will try it again
Same problem
Do you see this picture?
can you share this updated code?
I do yes
is it possible that this, the green circle, is the only means by which you're checking whether it's playing in other servers?
The bot is in a voice room and when I typed the command play
He also started talking on another server.
could you answer this as well
No, I came in and heard the sound on.
I have concluded something.
I think the problem because
connection.destroy();
I'm not entirely sure how you've drawn that conclusion, but that should not be the issue
once again, this code should not be causing this issue, and if it truly does, it'd be an issue with the library
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
please add these for both the audio player and connection and share the output
I solved the problem
š„³š„³š„³š„³š„³
The problem was from
connection.destroy();
Thanks for the help.could you explain your reasoning?
once again, that should not be the source of the issue, and if it is, something still needs to be fixed
Because I forgot to define connection.destroy(); to end the music.
The reason is kind of stupid.
And illogical
And trivial
It is difficult to explain.
once again, especially if you weren't destroying the connection, the connection should not have been playing audio from a different
AudioPlayer
I really don't understand how the problem was solved (: