diff options
author | Brandon <bwaggone@umich.edu> | 2018-04-14 14:56:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-14 14:56:48 -0400 |
commit | f8fe02e835c6417a54033b30a66c9c3bc2097836 (patch) | |
tree | fb7952b64ea1d20e7a266131e9d80f242411174b | |
parent | 18527f7210fffb669da2e48bfe7349060a2e95b5 (diff) | |
parent | a9c2c03ff921098b4cc1485bf9b2edc473dd8a07 (diff) | |
download | SoundChan-f8fe02e835c6417a54033b30a66c9c3bc2097836.tar.gz SoundChan-f8fe02e835c6417a54033b30a66c9c3bc2097836.tar.bz2 SoundChan-f8fe02e835c6417a54033b30a66c9c3bc2097836.zip |
Merge pull request #4 from bwaggone/feature/add-summon
Summoning command
-rw-r--r-- | src/main/java/soundchan/BotListener.java | 14 | ||||
-rw-r--r-- | src/main/java/soundchan/Commands.java | 3 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/main/java/soundchan/BotListener.java b/src/main/java/soundchan/BotListener.java index 8e43ca9..8785892 100644 --- a/src/main/java/soundchan/BotListener.java +++ b/src/main/java/soundchan/BotListener.java @@ -139,6 +139,10 @@ public class BotListener extends ListenerAdapter{ case playingnow: { break; } + case summon: { + connectToUserVoiceChannel(guild.getAudioManager(), event.getMember().getEffectiveName()); + break; + } } } @@ -235,10 +239,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/Commands.java b/src/main/java/soundchan/Commands.java index 3f96d37..45fda7a 100644 --- a/src/main/java/soundchan/Commands.java +++ b/src/main/java/soundchan/Commands.java @@ -10,5 +10,6 @@ public enum Commands { unpause, skip, list, - playingnow + playingnow, + summon } |