|
4 | 4 | - [IntelliJ IDEA](../setup/intellij.md) |
5 | 5 | - [Eclipse](../setup/eclipse.md) |
6 | 6 | - [Netbeans](../setup/netbeans.md) |
7 | | - |
8 | 7 | 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) |
10 | 11 | - If you don't want to implement it yourself, use [LavaPlayer](#using-lavaplayer) |
11 | 12 |
|
| 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 | + |
12 | 27 | ### Connecting to a VoiceChannel |
13 | 28 |
|
14 | 29 | 1. Getting a VoiceChannel (`guild` references an instance of `Guild`) |
|
43 | 58 | ### A Working Example |
44 | 59 |
|
45 | 60 | ```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) { |
51 | 63 | JDABuilder.createDefault(args[0]) // Use token provided as JVM argument |
52 | 64 | .addEventListeners(new MusicBot()) // Register new MusicBot instance as EventListener |
| 65 | + .setAudioModuleConfig( |
| 66 | + new AudioModuleConfig() |
| 67 | + .withDaveSessionFactory(new JDaveSessionFactory()) |
| 68 | + .withAudioSendFactory(new NativeAudioSendFactory()) |
| 69 | + ) |
53 | 70 | .build(); // Build JDA - connect to discord |
54 | 71 | } |
55 | 72 |
|
56 | 73 | @Override |
57 | | - public void onMessageReceived(MessageReceivedEvent event) |
58 | | - { |
| 74 | + public void onMessageReceived(MessageReceivedEvent event) { |
59 | 75 | // Make sure we only respond to events that occur in a guild |
60 | 76 | if (!event.isFromGuild()) return; |
61 | 77 | // This makes sure we only execute our code when someone sends a message with "!play" |
@@ -101,4 +117,4 @@ public class MusicBot extends ListenerAdapter |
101 | 117 | - [Wiki](https://github.com/jagrosh/MusicBot/wiki) |
102 | 118 | - FredBoat by [@freyacodes](https://github.com/freyacodes) |
103 | 119 | - [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) |
0 commit comments