diff options
author | Matt Kohls <mattkohls13@gmail.com> | 2018-04-14 14:50:18 -0400 |
---|---|---|
committer | Matt Kohls <mattkohls13@gmail.com> | 2018-04-14 14:50:18 -0400 |
commit | a9c2c03ff921098b4cc1485bf9b2edc473dd8a07 (patch) | |
tree | fb7952b64ea1d20e7a266131e9d80f242411174b /src/main | |
parent | 18527f7210fffb669da2e48bfe7349060a2e95b5 (diff) | |
download | SoundChan-a9c2c03ff921098b4cc1485bf9b2edc473dd8a07.tar.gz SoundChan-a9c2c03ff921098b4cc1485bf9b2edc473dd8a07.tar.bz2 SoundChan-a9c2c03ff921098b4cc1485bf9b2edc473dd8a07.zip |
Summoning command
Anyone can now summon SoundChan with ~summon from the public chats
Diffstat (limited to 'src/main')
-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 } |