Fix bot joining in AFK voice channels (#292)

* Fix bot joining in AFK voice channels

Since Discord automatically mutes users in AFK channels, bots shouldn't
play music inside AFK channels. This commit also fixes #147.

* Apply requested changes

* Fix potential NPE

Co-Authored-By: M R S E <Maurice.Craft@t-online.de>

* Fix indention
This commit is contained in:
Michaili 2019-10-20 05:02:28 +02:00 committed by John Grosh
parent 3ba13d2daa
commit 8650f82210
1 changed files with 8 additions and 0 deletions

View File

@ -73,6 +73,14 @@ public abstract class MusicCommand extends Command
event.replyError("You must be listening in "+(current==null ? "a voice channel" : "**"+current.getName()+"**")+" to use that!");
return;
}
VoiceChannel afkChannel = userState.getGuild().getAfkChannel();
if(afkChannel != null && afkChannel.equals(userState.getChannel()))
{
event.replyError("You cannot use that command in an AFK channel!");
return;
}
if(!event.getGuild().getSelfMember().getVoiceState().inVoiceChannel())
{
try