From a9c2c03ff921098b4cc1485bf9b2edc473dd8a07 Mon Sep 17 00:00:00 2001 From: Matt Kohls Date: Sat, 14 Apr 2018 14:50:18 -0400 Subject: Summoning command Anyone can now summon SoundChan with ~summon from the public chats --- src/main/java/soundchan/BotListener.java | 14 ++++++++++++-- src/main/java/soundchan/Commands.java | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src/main') 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 } -- cgit v1.2.3