Test if spam role exist
This commit is contained in:
parent
ad31172485
commit
608ae867e0
@ -118,7 +118,6 @@ public class BotListener extends ListenerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuildVoiceLeave(GuildVoiceLeaveEvent event) {
|
public void onGuildVoiceLeave(GuildVoiceLeaveEvent event) {
|
||||||
super.onGuildVoiceLeave(event);
|
super.onGuildVoiceLeave(event);
|
||||||
|
@ -10,6 +10,7 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ public class AntiSpam {
|
|||||||
{
|
{
|
||||||
MainBot.spamUtils.get(user).setOnSpam(true);
|
MainBot.spamUtils.get(user).setOnSpam(true);
|
||||||
List<Role> spm = guild.getRolesByName("Spammer", false);
|
List<Role> spm = guild.getRolesByName("Spammer", false);
|
||||||
|
if(spm.size() != 0){
|
||||||
try{
|
try{
|
||||||
move.exc(user, spm, true, guild, guildManager);
|
move.exc(user, spm, true, guild, guildManager);
|
||||||
MainBot.spamUtils.get(user).addMessage(event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamExtermine(user,MainBot.spamUtils.get(user.getUser()).getMultip())).complete());
|
MainBot.spamUtils.get(user).addMessage(event.getTextChannel().sendMessage(EmbedMessageUtils.getSpamExtermine(user,MainBot.spamUtils.get(user.getUser()).getMultip())).complete());
|
||||||
@ -83,6 +85,12 @@ public class AntiSpam {
|
|||||||
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
|
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
|
||||||
MainBot.spamUtils.get(user).setOnSpam(false);
|
MainBot.spamUtils.get(user).setOnSpam(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageEmbed msg = EmbedMessageUtils.buildStandar(EmbedMessageUtils.getError("\nSpam role not found, you need to create it!"));
|
||||||
|
event.getTextChannel().sendMessage(msg).complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,7 +130,7 @@ public class AntiSpam {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
logger.info("["+user.getEffectiveName()+"] Démarage pour "+multip+"min");
|
logger.info("["+user.getEffectiveName()+"] Démarage pour "+multip+"min");
|
||||||
while (MainBot.spamUtils.get(user.getUser()).isOnSpam())
|
while (MainBot.spamUtils.get(user).isOnSpam())
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
@ -148,9 +156,9 @@ public class AntiSpam {
|
|||||||
logger.error("Hierarchy error");
|
logger.error("Hierarchy error");
|
||||||
}
|
}
|
||||||
logger.info("["+user.getEffectiveName()+"] Fin des "+multip+"min");
|
logger.info("["+user.getEffectiveName()+"] Fin des "+multip+"min");
|
||||||
new MessageTimeOut(new ArrayList<>(MainBot.spamUtils.get(user.getUser()).getMessages()),0).start();
|
new MessageTimeOut(new ArrayList<>(MainBot.spamUtils.get(user).getMessages()),0).start();
|
||||||
MainBot.spamUtils.get(user.getUser()).clearAndAdd(chanel.sendMessage(EmbedMessageUtils.getSpamPardon(user)).complete());
|
MainBot.spamUtils.get(user).clearAndAdd(chanel.sendMessage(EmbedMessageUtils.getSpamPardon(user)).complete());
|
||||||
new MessageTimeOut(MainBot.spamUtils.get(user.getUser()).getMessages(),60).start();
|
new MessageTimeOut(MainBot.spamUtils.get(user).getMessages(),60).start();
|
||||||
|
|
||||||
// #-----------------------------------------------#
|
// #-----------------------------------------------#
|
||||||
|
|
||||||
@ -160,4 +168,6 @@ public class AntiSpam {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user