Multi guild for daily madame

This commit is contained in:
Sebastien 2018-04-29 16:14:29 +02:00
parent c06bdcd21a
commit 38eb8c39f7

View File

@ -4,11 +4,13 @@ import net.Broken.Commands.Over18.Madame;
import net.Broken.MainBot;
import net.Broken.Tools.DayListener.NewDayListener;
import net.Broken.Tools.Redirection;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.TextChannel;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.util.List;
/**
* Daily Listener for DailyMadame
@ -21,7 +23,18 @@ public class DailyMadame implements NewDayListener{
boolean success=false;
boolean error=false;
int errorCp=0;
TextChannel chanel = MainBot.jda.getTextChannelsByName("nsfw-over18", true).get(0);
List<Guild> guilds = MainBot.jda.getGuilds();
for(Guild guild : guilds){
TextChannel chanel = null;
for(TextChannel iterator : guild.getTextChannels())
{
if(iterator.isNSFW()){
chanel = iterator;
break;
}
}
if(chanel != null){
while(!success && !error)
{
try {
@ -48,4 +61,12 @@ public class DailyMadame implements NewDayListener{
}
}
}
else {
logger.info("No NSFW chanel found for " + guild.getName() + ", ignoring it!");
}
}
}
}