How really @discord.js/voice receives audio?

I looked up the source code, but I really have no idea how he's handling that. I'm thankful for any kind of reply. I want to implement audio receiving in Koe.
27 Replies
d.js toolkit
d.js toolkit•8mo 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!
d.js docs
d.js docs•8mo ago
discord Voice Connections read more
ThePedroo
ThePedroo•8mo ago
In Discord API receiving audio is not documented. The most important part of voice receive is the parser, which parses the packets received by the udp connection
Fyphen
Fyphen•8mo ago
Yeah, I already know that. I just want to know how Discord voice server sends packets to us and how discord.js receive that?
ThePedroo
ThePedroo•8mo ago
Well, all of those are made through the UDP connection created
Fyphen
Fyphen•8mo ago
Yeah, I also know that. I WANT to know HOW Discord voice server sends packets to client? like JSON or raw rpc onUdpMessage?
ThePedroo
ThePedroo•8mo ago
Please don't act like that towards me, I'm only wanting to help. No, they are not JSONs, they are buffers, then you use readUInt*... to read them That'll be the function that is executed when a message is received
Fyphen
Fyphen•8mo ago
Oh sorry Oh wait a sec
ThePedroo
ThePedroo•8mo ago
Yes?
Fyphen
Fyphen•8mo ago
What calls onUdpMessage()?
Fyphen
Fyphen•8mo ago
um
ThePedroo
ThePedroo•8mo ago
But tecnically everything comes from here ?
Fyphen
Fyphen•8mo ago
Sorry sir
ThePedroo
ThePedroo•8mo ago
No need to sorry, I'm just confused of what you're confused This sounded very funny for some reason
Fyphen
Fyphen•8mo ago
you confused due to what I'm confused lol
ThePedroo
ThePedroo•8mo ago
Yeah 🤣
Fyphen
Fyphen•8mo ago
It comes for clients through WS right?
ThePedroo
ThePedroo•8mo ago
All information from the voice itself comes from UDP, none is transmitted by the websocket
Fyphen
Fyphen•8mo ago
oh hum
Fyphen
Fyphen•8mo ago
Actually, I want to receive audio in repo called Koe, which you can find here: https://github.com/KyokoBot/koe
GitHub
GitHub - KyokoBot/koe: Tiny and embeddable Discord media transport ...
Tiny and embeddable Discord media transport library based on Netty. - GitHub - KyokoBot/koe: Tiny and embeddable Discord media transport library based on Netty.
ThePedroo
ThePedroo•8mo ago
Oh, I know Koe From Lavalink 🤣
Fyphen
Fyphen•8mo ago
Because I use Lavalink for my music bot. oh me too lol and I want to implement receiving audio but Koe does not support audio receiving so I wanna implement for myself but I'm really not sure how can I implement that in Java
ThePedroo
ThePedroo•8mo ago
Note that for voice sending a UDP connection is necessary, so you're only going to need to decrypt it* And the same libraries that are used to encrypt it are used to decrypt it
Fyphen
Fyphen•8mo ago
tweetnacl-java
ThePedroo
ThePedroo•8mo ago
Yes, tweetnacl itself does have them In NodeJs the tweetnacl function is tweetnacl.secretbox, it must be similar in tweetnacl-java
Fyphen
Fyphen•8mo ago
I think so