Skip to content

Commit 7da18b2

Browse files
Add instructions for DAVE setup in JDA (#63)
* Enhance music bot setup documentation Updated instructions for setting up audio dependencies and configuring the JDA audio module. Improved code formatting and added example configuration. * Add audio module configuration to MusicBot * Update troubleshooting.md with audio problems section Added troubleshooting information for audio connection errors and DAVE protocol implementation.
1 parent 2f9a470 commit 7da18b2

2 files changed

Lines changed: 46 additions & 10 deletions

File tree

docs/using-jda/making-a-music-bot.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,26 @@
44
- [IntelliJ IDEA](../setup/intellij.md)
55
- [Eclipse](../setup/eclipse.md)
66
- [Netbeans](../setup/netbeans.md)
7-
87
2. [Set up JDA](getting-started.md)
9-
3. Once you have your project you will need an additional dependency for your [AudioSendHandler](https://github.com/discord-jda/JDA/blob/master/src/main/java/net/dv8tion/jda/api/audio/AudioSendHandler.java)
8+
3. Add a library that implements the Discord Audio & Video End-to-End Encryption (DAVE) Protocol.
9+
- For instance [JDAVE](https://github.com/MinnDevelopment/jdave) or [libdave-jvm](https://github.com/KyokoBot/libdave-jvm) and follow their setup guidelines.
10+
4. Once you have your project you will need an additional dependency for your [AudioSendHandler](https://github.com/discord-jda/JDA/blob/master/src/main/java/net/dv8tion/jda/api/audio/AudioSendHandler.java)
1011
- If you don't want to implement it yourself, use [LavaPlayer](#using-lavaplayer)
1112

13+
### Configure JDA Audio Module
14+
15+
Since JDA relies on additional dependencies to provide audio support, you need to properly setup the audio module using [JDABuilder#setAudioModuleConfig](https://docs.jda.wiki/net/dv8tion/jda/api/JDABuilder.html#setAudioModuleConfig(net.dv8tion.jda.api.audio.AudioModuleConfig)).
16+
17+
For instance, if you use [JDAVE](https://github.com/MinnDevelopment/jdave) and [udpqueue](https://github.com/MinnDevelopment/udpqueue.rs), this would be your config setup:
18+
19+
```java
20+
builder.setAudioModuleConfig(
21+
new AudioModuleConfig()
22+
.withDaveSessionFactory(new JDaveSessionFactory())
23+
.withAudioSendFactory(new NativeAudioSendFactory())
24+
)
25+
```
26+
1227
### Connecting to a VoiceChannel
1328

1429
1. Getting a VoiceChannel (`guild` references an instance of `Guild`)
@@ -43,19 +58,20 @@
4358
### A Working Example
4459

4560
```java
46-
public class MusicBot extends ListenerAdapter
47-
{
48-
public static void main(String[] args)
49-
throws IllegalArgumentException, LoginException, RateLimitedException
50-
{
61+
public class MusicBot extends ListenerAdapter {
62+
public static void main(String[] args) {
5163
JDABuilder.createDefault(args[0]) // Use token provided as JVM argument
5264
.addEventListeners(new MusicBot()) // Register new MusicBot instance as EventListener
65+
.setAudioModuleConfig(
66+
new AudioModuleConfig()
67+
.withDaveSessionFactory(new JDaveSessionFactory())
68+
.withAudioSendFactory(new NativeAudioSendFactory())
69+
)
5370
.build(); // Build JDA - connect to discord
5471
}
5572

5673
@Override
57-
public void onMessageReceived(MessageReceivedEvent event)
58-
{
74+
public void onMessageReceived(MessageReceivedEvent event) {
5975
// Make sure we only respond to events that occur in a guild
6076
if (!event.isFromGuild()) return;
6177
// This makes sure we only execute our code when someone sends a message with "!play"
@@ -101,4 +117,4 @@ public class MusicBot extends ListenerAdapter
101117
- [Wiki](https://github.com/jagrosh/MusicBot/wiki)
102118
- FredBoat by [@freyacodes](https://github.com/freyacodes)
103119
- [GitHub](https://github.com/freyacodes/archived-bot/)
104-
- [relevant package](https://github.com/freyacodes/archived-bot/tree/master/FredBoat/src/main/java/fredboat/audio)
120+
- [relevant package](https://github.com/freyacodes/archived-bot/tree/master/FredBoat/src/main/java/fredboat/audio)

docs/using-jda/troubleshooting.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,23 @@ To resolve this, try stopping all current processes for the bot that could be re
373373
### Interaction Followup Messages Timed out
374374

375375
This means you sent followup messages through `InteractionHook.sendMessage(...)` or similar but never acknowledged the interaction.
376+
377+
## Audio Problems
378+
379+
### Using passthrough dave session. Please migrate to an implementation of libdave!
380+
381+
This error indicates that you opened an audio connection (`audioManager.openAudioConnection(...)`) without configuring a [DaveSessionFactory](https://docs.jda.wiki/net/dv8tion/jda/api/audio/dave/DaveSessionFactory.html).
382+
383+
Discord requires all audio connections to implement the [DAVE protocol](https://daveprotocol.com/). To resolve this error, configure an `AudioModuleConfig` with an implementation of `DaveSessionFactory`:
384+
385+
```java
386+
JDABuilder.createDefault(token. intents)
387+
.setAudioModuleConfig(
388+
new AudioModuleConfig()
389+
.withDaveSessionFactory(daveSessionFactory))
390+
...
391+
```
392+
393+
An implementation for this protocol must be provided as an additional dependency, to avoid bloating the default size of JDA applications.
394+
You can use implementations like [JDAVE](https://github.com/MinnDevelopment/jdave) or [libdave-jvm](https://github.com/KyokoBot/libdave-jvm).
395+

0 commit comments

Comments
 (0)