diff options
-rw-r--r-- | src/main/java/soundchan/BotListener/BotListener.java | 13 | ||||
-rw-r--r-- | src/main/java/soundchan/BotListener/Commands.java | 3 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/soundchan/BotListener/BotListener.java b/src/main/java/soundchan/BotListener/BotListener.java index f97db95..044625d 100644 --- a/src/main/java/soundchan/BotListener/BotListener.java +++ b/src/main/java/soundchan/BotListener/BotListener.java @@ -140,7 +140,8 @@ public class BotListener extends ListenerAdapter{ }else if(enumCommand == Commands.playingnow){ // Print the currently playing song printCurrentlyPlaying(channel); - + }else if(enumCommand == Commands.summon){ + connectToUserVoiceChannel(monitoredGuild.getAudioManager(), event.getMember().getEffectiveName()); } @@ -250,10 +251,16 @@ public class BotListener extends ListenerAdapter{ private static void connectToFollowingVoiceChannel(AudioManager audioManager) { - if (!audioManager.isConnected() && !audioManager.isAttemptingToConnect()) { + if(!audioManager.isConnected()) { + connectToUserVoiceChannel(audioManager, followingUser); + } + } + + private static void connectToUserVoiceChannel(AudioManager audioManager, String user) { + if (!audioManager.isAttemptingToConnect()) { for (VoiceChannel voiceChannel : audioManager.getGuild().getVoiceChannels()) { for (int i = 0; i < voiceChannel.getMembers().size(); i++) { - if (voiceChannel.getMembers().get(i).getEffectiveName().compareTo(followingUser) == 0) { + if (voiceChannel.getMembers().get(i).getEffectiveName().compareTo(user) == 0) { audioManager.openAudioConnection(voiceChannel); break; } diff --git a/src/main/java/soundchan/BotListener/Commands.java b/src/main/java/soundchan/BotListener/Commands.java index da1f45f..1a06436 100644 --- a/src/main/java/soundchan/BotListener/Commands.java +++ b/src/main/java/soundchan/BotListener/Commands.java @@ -10,5 +10,6 @@ public enum Commands { unpause, skip, list, - playingnow + playingnow, + summon } |