Adding auto delete of commands on chat

This commit is contained in:
Unknown 2017-10-16 17:03:17 +02:00
parent 73b00b8338
commit 04040925bf
8 changed files with 169 additions and 36 deletions

View File

@ -9,6 +9,7 @@ import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.entities.ChannelType; import net.dv8tion.jda.core.entities.ChannelType;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel;
import net.dv8tion.jda.core.events.ExceptionEvent; import net.dv8tion.jda.core.events.ExceptionEvent;
import net.dv8tion.jda.core.events.ReadyEvent; import net.dv8tion.jda.core.events.ReadyEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent;
@ -43,7 +44,9 @@ public class BotListener extends ListenerAdapter {
@Override @Override
public void onGuildMemberJoin(GuildMemberJoinEvent event) { public void onGuildMemberJoin(GuildMemberJoinEvent event) {
logger.info(event.getUser().getName()+ "join the guild, move it!"); logger.info(event.getUser().getName()+ "join the guild, move it!");
new Move().exc(event.getMember(),event.getJDA().getRolesByName("Rat_d'égout",true),false,event.getJDA().getGuilds().get(0),event.getJDA().getGuilds().get(0).getManager()); new Move().exc(event.getMember(),event.getJDA().getRolesByName("Newbies",true),false,event.getJDA().getGuilds().get(0),event.getJDA().getGuilds().get(0).getManager());
TextChannel chanel = event.getGuild().getTextChannelsByName("accueil", true).get(0);
chanel.sendMessage("Salut "+event.getUser().getAsMention()+"! Ecris ton nom, prénom, ta promotion et ton groupe ici! Un admin te donnera accées a ton groupe!").complete();
MainBot.roleFlag = false; MainBot.roleFlag = false;
} }

View File

@ -3,15 +3,19 @@ package net.Broken.Commandes;
import net.Broken.Commande; import net.Broken.Commande;
import net.Broken.MainBot; import net.Broken.MainBot;
import net.Broken.Outils.EmbedMessageUtils; import net.Broken.Outils.EmbedMessageUtils;
import net.Broken.Outils.MessageTimeOut;
import net.Broken.Outils.PrivateMessage; import net.Broken.Outils.PrivateMessage;
import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.entities.ChannelType; import net.dv8tion.jda.core.entities.ChannelType;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import net.dv8tion.jda.core.exceptions.RateLimitedException; import net.dv8tion.jda.core.exceptions.RateLimitedException;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.awt.*; import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -33,9 +37,14 @@ public class Help implements Commande {
if (MainBot.commandes.containsKey(argsString)) if (MainBot.commandes.containsKey(argsString))
{ {
logger.info("Aide demmander pour la cmd "+argsString+" par "+event.getAuthor().getName()); logger.info("Aide demmander pour la cmd "+argsString+" par "+event.getAuthor().getName());
if(!event.isFromType(ChannelType.PRIVATE)) if(!event.isFromType(ChannelType.PRIVATE)) {
event.getTextChannel().sendMessage(EmbedMessageUtils.getHelp(argsString,MainBot.commandes.get(argsString).help(args))).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getHelp(argsString, MainBot.commandes.get(argsString).help(args))).complete();
else{ List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} else{
PrivateMessage.send(event.getAuthor(), MainBot.commandes.get(argsString).help(args),logger); PrivateMessage.send(event.getAuthor(), MainBot.commandes.get(argsString).help(args),logger);
} }
@ -43,9 +52,14 @@ public class Help implements Commande {
} }
else else
{ {
if(!event.isFromType(ChannelType.PRIVATE)) if(!event.isFromType(ChannelType.PRIVATE)) {
event.getTextChannel().sendMessage(EmbedMessageUtils.getUnknowCommand()).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getUnknowCommand()).complete();
else{ List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} else{
PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getUnknowCommand(),logger); PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getUnknowCommand(),logger);
} }
logger.info("Commande Inconnue!"); logger.info("Commande Inconnue!");
@ -57,9 +71,16 @@ public class Help implements Commande {
for (Map.Entry<String, Commande> e : MainBot.commandes.entrySet()) { for (Map.Entry<String, Commande> e : MainBot.commandes.entrySet()) {
txt.append("\n- ").append(e.getKey()); txt.append("\n- ").append(e.getKey());
} }
if(!event.isFromType(ChannelType.PRIVATE))
event.getTextChannel().sendMessage(new EmbedBuilder().setTitle("Commandes envoyées par message privé").setColor(Color.green).build()).queue(); if(!event.isFromType(ChannelType.PRIVATE)){
Message rest = event.getTextChannel().sendMessage(new EmbedBuilder().setTitle("Commandes envoyées par message privé").setColor(Color.green).build()).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
}
PrivateMessage.send(event.getAuthor(),new EmbedBuilder().setTitle("Commandes du bot").setDescription(txt.toString()).setFooter("Utilise '//help <commande>' pour plus de détails.",null).setColor(Color.green).setThumbnail(event.getJDA().getSelfUser().getAvatarUrl()).build(),logger); PrivateMessage.send(event.getAuthor(),new EmbedBuilder().setTitle("Commandes du bot").setDescription(txt.toString()).setFooter("Utilise '//help <commande>' pour plus de détails.",null).setColor(Color.green).setThumbnail(event.getJDA().getSelfUser().getAvatarUrl()).build(),logger);

View File

@ -3,6 +3,7 @@ package net.Broken.Commandes;
import net.Broken.Commande; import net.Broken.Commande;
import net.Broken.MainBot; import net.Broken.MainBot;
import net.Broken.Outils.EmbedMessageUtils; import net.Broken.Outils.EmbedMessageUtils;
import net.Broken.Outils.MessageTimeOut;
import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.*; import net.dv8tion.jda.core.entities.*;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
@ -101,7 +102,12 @@ public class Move implements Commande {
if(userL.size()<1 ||roleL.size()<1) if(userL.size()<1 ||roleL.size()<1)
{ {
logger.info("Mentionnement Incorect."); logger.info("Mentionnement Incorect.");
event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Utilisateur ou Role mal mentioner.")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Utilisateur ou Role mal mentioner.")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
else else
{ {
@ -117,7 +123,12 @@ public class Move implements Commande {
boolean erreur=this.exc(user,roleL,true,serveur,serveur.getManager()); boolean erreur=this.exc(user,roleL,true,serveur,serveur.getManager());
if(erreur) if(erreur)
{ {
event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Verifier le rôle cible. ")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Verifier le rôle cible. ")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
else else
{ {
@ -137,10 +148,20 @@ public class Move implements Commande {
} }
event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveOk("Déplacement de "+user.getEffectiveName()+" vers "+roleStr.toString()+" reussi.")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveOk("Déplacement de "+user.getEffectiveName()+" vers "+roleStr.toString()+" reussi.")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
}catch (HierarchyException e){ }catch (HierarchyException e){
event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Impossible de déplacer un "+user.getRoles().get(0).getAsMention())).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Impossible de déplacer un "+user.getRoles().get(0).getAsMention())).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
logger.error("Hierarchy error, please move bot's role on top!"); logger.error("Hierarchy error, please move bot's role on top!");
} }
@ -149,7 +170,12 @@ public class Move implements Commande {
else else
{ {
logger.info("Autorisation insuffisante, deplacement refusé"); logger.info("Autorisation insuffisante, deplacement refusé");
event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Vous n'avez pas l'autorisation de faicre ça!")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Vous n'avez pas l'autorisation de faicre ça!")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
} }
@ -158,8 +184,12 @@ public class Move implements Commande {
else else
{ {
logger.warn("Arguments maquant."); logger.warn("Arguments maquant.");
event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Arguments manquant.")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Arguments manquant.")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
} }
else else

View File

@ -1,12 +1,17 @@
package net.Broken.Commandes; package net.Broken.Commandes;
import net.Broken.Commande; import net.Broken.Commande;
import net.Broken.MainBot;
import net.Broken.Outils.MessageTimeOut;
import net.dv8tion.jda.core.entities.ChannelType; import net.dv8tion.jda.core.entities.ChannelType;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.*; import java.time.*;
import java.util.ArrayList;
import java.util.List;
/** /**
@ -26,8 +31,14 @@ public class PingCommande implements Commande {
long receivedTime = Timestamp.valueOf(LocalDateTime.ofInstant(event.getMessage().getCreationTime().toInstant(), ZoneId.systemDefault())).getTime(); long receivedTime = Timestamp.valueOf(LocalDateTime.ofInstant(event.getMessage().getCreationTime().toInstant(), ZoneId.systemDefault())).getTime();
if(event.isFromType(ChannelType.PRIVATE)) if(event.isFromType(ChannelType.PRIVATE))
event.getPrivateChannel().sendMessage(":arrow_right: Pong! `"+((Timestamp.from(Instant.now()).getTime()-receivedTime))+"ms`").queue(); event.getPrivateChannel().sendMessage(":arrow_right: Pong! `"+((Timestamp.from(Instant.now()).getTime()-receivedTime))+"ms`").queue();
else else {
event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: Pong! `"+((Timestamp.from(Instant.now()).getTime()-receivedTime))+"ms`").queue(); Message rest = event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: Pong! `"+((Timestamp.from(Instant.now()).getTime()-receivedTime))+"ms`").complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages, MainBot.messageTimeOut).start();
}
LogManager.getLogger().debug("pong"); LogManager.getLogger().debug("pong");
} }

View File

@ -4,10 +4,12 @@ import net.Broken.Commande;
import net.Broken.MainBot; import net.Broken.MainBot;
import net.Broken.Outils.AntiSpam; import net.Broken.Outils.AntiSpam;
import net.Broken.Outils.EmbedMessageUtils; import net.Broken.Outils.EmbedMessageUtils;
import net.Broken.Outils.MessageTimeOut;
import net.Broken.Outils.UserSpamUtils; import net.Broken.Outils.UserSpamUtils;
import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.User; import net.dv8tion.jda.core.entities.User;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import net.dv8tion.jda.core.exceptions.RateLimitedException; import net.dv8tion.jda.core.exceptions.RateLimitedException;
@ -113,7 +115,12 @@ public class Spam implements Commande {
if(userL.size()<1) if(userL.size()<1)
{ {
logger.error("Utilisateur introuvable."); logger.error("Utilisateur introuvable.");
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError(":arrow_right: Utilisateur introuvable. ","pardon")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError(":arrow_right: Utilisateur introuvable. ","pardon")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
else { else {
Member user = serveur.getMember(userL.get(0)); Member user = serveur.getMember(userL.get(0));
@ -133,25 +140,45 @@ public class Spam implements Commande {
MainBot.spamUtils.get(user.getUser()).setOnSpam(false); MainBot.spamUtils.get(user.getUser()).setOnSpam(false);
} else { } else {
logger.warn("Utilisateur pas en spam."); logger.warn("Utilisateur pas en spam.");
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError(":arrow_right: Utilisateur non spammeur.","pardon")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError(":arrow_right: Utilisateur non spammeur.","pardon")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
} else { } else {
logger.warn("Utilisateur pas en spam."); logger.warn("Utilisateur pas en spam.");
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError(":arrow_right: Utilisateur non spammeur.","pardon")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError(":arrow_right: Utilisateur non spammeur.","pardon")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
} else { } else {
logger.warn("Autorisation insuffisante, pardon refusé"); logger.warn("Autorisation insuffisante, pardon refusé");
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Vous n'avez pas l'autorisation de faire ça!")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Vous n'avez pas l'autorisation de faire ça!")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
} }
} }
else else
{ {
logger.warn("Argument manquant."); logger.warn("Argument manquant.");
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Argument manquant!","pardon")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Argument manquant!","pardon")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
@ -175,7 +202,7 @@ public class Spam implements Commande {
if(userL.size()<1) if(userL.size()<1)
{ {
logger.warn("Mentionnement Incorect (Spam)."); logger.warn("Mentionnement Incorect (Spam).");
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Utilisateur mal mentioner. ","extermine")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Utilisateur mal mentioner. ","extermine")).complete();
} }
else{ else{
@ -205,7 +232,7 @@ public class Spam implements Commande {
else else
{ {
logger.warn("Utilisateur deja en spam."); logger.warn("Utilisateur deja en spam.");
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Utilisateur déjà spammeur.","extermine")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Utilisateur déjà spammeur.","extermine")).complete();
} }
@ -219,7 +246,12 @@ public class Spam implements Commande {
else else
{ {
logger.warn("Autorisation insuffisante, extermination refusé"); logger.warn("Autorisation insuffisante, extermination refusé");
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Vous n'avez pas l'autorisation de faire ça!")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Vous n'avez pas l'autorisation de faire ça!")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
} }
@ -229,7 +261,12 @@ public class Spam implements Commande {
else else
{ {
logger.warn("Argument manquant."); logger.warn("Argument manquant.");
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Argument manquant!","extermine")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Argument manquant!","extermine")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
} }
@ -252,7 +289,12 @@ public class Spam implements Commande {
if(userL.size()<1) if(userL.size()<1)
{ {
logger.warn("Utilisateur introuvable."); logger.warn("Utilisateur introuvable.");
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Utilisateur introuvable.","reset")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Utilisateur introuvable.","reset")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
else { else {
@ -269,13 +311,23 @@ public class Spam implements Commande {
****************************/ ****************************/
if (MainBot.spamUtils.containsKey(user.getUser())) { if (MainBot.spamUtils.containsKey(user.getUser())) {
logger.info("Reset du multiplicateur de " + user.getEffectiveName() + " réussi"); logger.info("Reset du multiplicateur de " + user.getEffectiveName() + " réussi");
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n *Le multiplcicateur de " + user.getEffectiveName() + " a été remit a zéro.*").queue(); Message rest = event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n *Le multiplcicateur de " + user.getEffectiveName() + " a été remit a zéro.*").complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
MainBot.spamUtils.remove(user.getUser()); MainBot.spamUtils.remove(user.getUser());
} }
} else { } else {
logger.warn("Autorisation insuffisante, reset refusé"); logger.warn("Autorisation insuffisante, reset refusé");
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Vous n'avez pas l'autorisation de faire ça!")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Vous n'avez pas l'autorisation de faire ça!")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
} }
@ -283,7 +335,12 @@ public class Spam implements Commande {
else else
{ {
logger.warn("Argument manquant."); logger.warn("Argument manquant.");
event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Argument manquant!","reset")).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamError("Argument manquant!","reset")).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
} }
} }
else else

View File

@ -34,9 +34,10 @@ public class MainBot {
public static HashMap<User, ArrayList<Message>> historique =new HashMap<>(); public static HashMap<User, ArrayList<Message>> historique =new HashMap<>();
public static HashMap<User, Integer> message_compteur =new HashMap<>(); public static HashMap<User, Integer> message_compteur =new HashMap<>();
public static boolean roleFlag = false; public static boolean roleFlag = false;
public static HashMap<User, UserSpamUtils> spamUtils = new HashMap<>(); public static HashMap<User, UserSpamUtils> spamUtils = new HashMap<>();
public static int messageTimeOut = 10;
private static Logger logger = LogManager.getLogger(); private static Logger logger = LogManager.getLogger();

View File

@ -72,7 +72,12 @@ public class AntiSpam {
MainBot.spamUtils.get(user.getUser()).setMinuteur(new Minuteur(MainBot.spamUtils.get(user.getUser()).getMultip(), move.user, move.saveRoleUser, move.serveur, move.serveurManager,event)); MainBot.spamUtils.get(user.getUser()).setMinuteur(new Minuteur(MainBot.spamUtils.get(user.getUser()).getMultip(), move.user, move.saveRoleUser, move.serveur, move.serveurManager,event));
MainBot.spamUtils.get(user.getUser()).launchMinuteur(); MainBot.spamUtils.get(user.getUser()).launchMinuteur();
}catch (HierarchyException e){ }catch (HierarchyException e){
event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Impossible de déplacer un "+user.getRoles().get(0).getAsMention())).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Impossible de déplacer un "+user.getRoles().get(0).getAsMention())).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
MainBot.spamUtils.get(user.getUser()).setOnSpam(false); MainBot.spamUtils.get(user.getUser()).setOnSpam(false);
} }
@ -128,7 +133,12 @@ public class AntiSpam {
try { try {
move.exc(user, saveRoleUser, true, serveur, serveurManager); //aSaveroleUser=saveRoleUser.get(i) move.exc(user, saveRoleUser, true, serveur, serveurManager); //aSaveroleUser=saveRoleUser.get(i)
}catch (HierarchyException e){ }catch (HierarchyException e){
event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Impossible de déplacer un "+user.getRoles().get(0).getAsMention())).queue(); Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getMoveError("Impossible de déplacer un "+user.getRoles().get(0).getAsMention())).complete();
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
logger.error("Hierarchy error"); logger.error("Hierarchy error");
} }
logger.info("["+user.getEffectiveName()+"] Fin des "+multip+"min"); logger.info("["+user.getEffectiveName()+"] Fin des "+multip+"min");

View File

@ -30,7 +30,7 @@ public class MessageTimeOut extends Thread{
{ {
try { try {
logger.debug(aMessage.getContent()); logger.debug(aMessage.getContent());
aMessage.delete().complete(); aMessage.delete().queue();
}catch (ErrorResponseException e){ }catch (ErrorResponseException e){
logger.warn("Unknown Message"); logger.warn("Unknown Message");
} }