Adding Daily Madame #5
This commit is contained in:
parent
a95aaa536f
commit
70bc064cf7
@ -22,7 +22,8 @@ public class Madame implements Commande{
|
||||
|
||||
@Override
|
||||
public void action(String[] args, MessageReceivedEvent event) {
|
||||
if(event.getTextChannel().getName().equals("nsfw-over18")) {
|
||||
|
||||
if(event.getTextChannel().isNSFW()) {
|
||||
Redirection redirect = new Redirection();
|
||||
boolean success=false;
|
||||
boolean error=false;
|
||||
|
@ -2,6 +2,7 @@ package net.Broken;
|
||||
|
||||
import net.Broken.Tools.Command.CommandLoader;
|
||||
import net.Broken.Tools.DayListener.DayListener;
|
||||
import net.Broken.Tools.DayListener.Listeners.DailyMadame;
|
||||
import net.Broken.Tools.DayListener.Listeners.ResetSpam;
|
||||
import net.dv8tion.jda.core.AccountType;
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
@ -83,6 +84,7 @@ public class Init {
|
||||
|
||||
DayListener dayListener = DayListener.getInstance();
|
||||
dayListener.addListener(new ResetSpam());
|
||||
dayListener.addListener(new DailyMadame());
|
||||
dayListener.start();
|
||||
|
||||
logger.debug("-----------------FIN INITIALISATION-----------------");
|
||||
|
@ -0,0 +1,39 @@
|
||||
package net.Broken.Tools.DayListener.Listeners;
|
||||
|
||||
import net.Broken.MainBot;
|
||||
import net.Broken.Tools.DayListener.NewDayListener;
|
||||
import net.Broken.Tools.Redirection;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class DailyMadame implements NewDayListener{
|
||||
Logger logger = LogManager.getLogger();
|
||||
@Override
|
||||
public void onNewDay() {
|
||||
Redirection redirect = new Redirection();
|
||||
boolean success=false;
|
||||
boolean error=false;
|
||||
int errorCp=0;
|
||||
TextChannel chanel = MainBot.jda.getTextChannelsByName("nsfw-over18", true).get(0);
|
||||
while(!success && !error)
|
||||
{
|
||||
try {
|
||||
chanel.sendMessage("Le Daily Madame mes petits cochons :kissing_heart:\n" + redirect.get("http://dites.bonjourmadame.fr/random")).queue();
|
||||
success=true;
|
||||
} catch (IOException e) {
|
||||
errorCp++;
|
||||
logger.warn("Erreur de redirection. (Essais n°"+errorCp+")");
|
||||
if(errorCp>5)
|
||||
{
|
||||
logger.error("5 Erreur de redirection.");
|
||||
error=true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user