aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt <mattkohls13@gmail.com>2018-04-07 20:03:15 -0400
committerGitHub <noreply@github.com>2018-04-07 20:03:15 -0400
commit6822f398098b505fcd54be8125b3d54bfd7eed71 (patch)
tree16cb93c04b015c407ea95d9a30bc565d72670510
parent05395d976b90ec672a6edc7b81180fff3a679140 (diff)
parent02dbcc2e9eea74f0ecd40efcd12ec49f3073afe7 (diff)
downloadSoundChan-6822f398098b505fcd54be8125b3d54bfd7eed71.tar.gz
SoundChan-6822f398098b505fcd54be8125b3d54bfd7eed71.tar.bz2
SoundChan-6822f398098b505fcd54be8125b3d54bfd7eed71.zip
Merge pull request #1 from bwaggone/following
Bot Following
-rw-r--r--src/main/java/soundchan/Main.java24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/main/java/soundchan/Main.java b/src/main/java/soundchan/Main.java
index 651d16b..3d0b9b6 100644
--- a/src/main/java/soundchan/Main.java
+++ b/src/main/java/soundchan/Main.java
@@ -12,8 +12,8 @@ import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.JDABuilder;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.MessageChannel;
-import net.dv8tion.jda.core.entities.TextChannel;
import net.dv8tion.jda.core.entities.VoiceChannel;
+import net.dv8tion.jda.core.events.guild.voice.GuildVoiceMoveEvent;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import net.dv8tion.jda.client.events.call.voice.CallVoiceJoinEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
@@ -36,6 +36,7 @@ public class Main extends ListenerAdapter {
localFilePath = properties.getProperty("localFilePath");
jda.addEventListener(new Main());
+ followingUser = properties.getProperty("followingUser");
}
private static Properties LoadProperties(){
@@ -59,6 +60,7 @@ public class Main extends ListenerAdapter {
private long monitoredGuildId = -1;
private Guild monitoredGuild;
+ private static String followingUser;
private static String localFilePath;
private final AudioPlayerManager playerManager;
private final Map<Long, GuildMusicManager> musicManagers;
@@ -104,6 +106,18 @@ public class Main extends ListenerAdapter {
}
+
+ @Override
+ public void onGuildVoiceMove(GuildVoiceMoveEvent event) {
+ if(event.getMember().getEffectiveName().compareTo(followingUser) == 0) {
+ AudioManager audioManager = monitoredGuild.getAudioManager();
+ if(!audioManager.isAttemptingToConnect()) {
+ audioManager.openAudioConnection(event.getChannelJoined());
+ }
+ }
+ super.onGuildVoiceMove(event);
+ }
+
@Override
public void onMessageReceived(MessageReceivedEvent event) {
String[] command = event.getMessage().getContentRaw().split(" ", 2);
@@ -241,8 +255,12 @@ public class Main extends ListenerAdapter {
private static void connectToFirstVoiceChannel(AudioManager audioManager) {
if (!audioManager.isConnected() && !audioManager.isAttemptingToConnect()) {
for (VoiceChannel voiceChannel : audioManager.getGuild().getVoiceChannels()) {
- audioManager.openAudioConnection(voiceChannel);
- break;
+ for(int i = 0; i < voiceChannel.getMembers().size(); i++) {
+ if(voiceChannel.getMembers().get(i).getEffectiveName().compareTo(followingUser) == 0) {
+ audioManager.openAudioConnection(voiceChannel);
+ break;
+ }
+ }
}
}
}