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
- 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!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
Yeah, I already know that. I just want to know how Discord voice server sends packets to us and how discord.js receive that?
Well, all of those are made through the UDP connection created
Yeah, I also know that. I WANT to know HOW Discord voice server sends packets to client?
like JSON or raw rpc
onUdpMessage?
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
Oh sorry
Oh
wait a sec
Yes?
What calls onUdpMessage()?
GitHub
discord.js/packages/voice/src/receive/VoiceReceiver.ts at main · di...
A powerful JavaScript library for interacting with the Discord API - discordjs/discord.js
um
Sorry sir
No need to sorry, I'm just confused of what you're confused
This sounded very funny for some reason
you confused due to what I'm confused lol
Yeah 🤣
It comes for clients through WS right?
All information from the voice itself comes from UDP, none is transmitted by the websocket
oh
hum
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.
Oh, I know Koe
From Lavalink 🤣
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
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
tweetnacl-java
Yes, tweetnacl itself does have them
In NodeJs the tweetnacl function is tweetnacl.secretbox, it must be similar in tweetnacl-java
I think so