diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
index d8ed111..0dd3219 100644
--- a/dependency-reduced-pom.xml
+++ b/dependency-reduced-pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.fpghoti
Biscuit
- 1.6.1
+ 1.6.2
src/main/java
diff --git a/pom.xml b/pom.xml
index 686d483..cd95073 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
com.fpghoti
Biscuit
- 1.6.1
+ 1.6.2
src/main/java
diff --git a/src/main/java/com/fpghoti/biscuit/Main.java b/src/main/java/com/fpghoti/biscuit/Main.java
index 90a43f0..86f60f5 100644
--- a/src/main/java/com/fpghoti/biscuit/Main.java
+++ b/src/main/java/com/fpghoti/biscuit/Main.java
@@ -46,9 +46,6 @@ import com.fpghoti.biscuit.listener.ReactionListener;
import com.fpghoti.biscuit.listener.RoleListener;
import com.fpghoti.biscuit.logging.BColor;
import com.fpghoti.biscuit.logging.BiscuitLog;
-import com.fpghoti.biscuit.timer.task.ChatCountTimer;
-import com.fpghoti.biscuit.timer.task.DecrementTimer;
-import com.fpghoti.biscuit.timer.task.SoftMuteTimer;
import ch.qos.logback.core.rolling.RollingFileAppender;
import ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy;
@@ -100,13 +97,7 @@ public class Main {
jda.addEventListener(new RoleListener());
biscuits = new ArrayList();
for(Guild g : jda.getGuilds()) {
- Biscuit biscuit = new Biscuit(jda, g, log);
- biscuit.addTimer(new ChatCountTimer(biscuit));
- biscuit.addTimer(new SoftMuteTimer(biscuit));
- biscuit.addTimer(new DecrementTimer(biscuit));
-
- biscuit.loadTimers();
- biscuits.add(biscuit);
+ Biscuit.loadGuild(g);
}
startCommandListener();
diff --git a/src/main/java/com/fpghoti/biscuit/biscuit/Biscuit.java b/src/main/java/com/fpghoti/biscuit/biscuit/Biscuit.java
index c550eaa..c21276d 100644
--- a/src/main/java/com/fpghoti/biscuit/biscuit/Biscuit.java
+++ b/src/main/java/com/fpghoti/biscuit/biscuit/Biscuit.java
@@ -40,7 +40,7 @@ public class Biscuit {
}
return null;
}
-
+
public static Biscuit getBiscuit(String guildcode) {
for(Biscuit b : Main.getBiscuits()) {
if(b.getProperties().getGuildCode().equalsIgnoreCase(guildcode)) {
@@ -49,7 +49,7 @@ public class Biscuit {
}
return null;
}
-
+
public static ArrayList getPreUsers(User u) {
ArrayList pres = new ArrayList();
for(Guild g : Main.getJDA().getGuilds()) {
@@ -62,13 +62,12 @@ public class Biscuit {
}
return pres;
}
-
+
public static Biscuit loadGuild(Guild g) {
Biscuit biscuit = new Biscuit(Main.getJDA(), g, Main.getLogger());
biscuit.addTimer(new ChatCountTimer(biscuit));
biscuit.addTimer(new SoftMuteTimer(biscuit));
biscuit.addTimer(new DecrementTimer(biscuit));
-
biscuit.loadTimers();
Main.registerBiscuit(biscuit);
return biscuit;
@@ -88,6 +87,7 @@ public class Biscuit {
private BiscuitMessageStore messageStore;
private CopyOnWriteArrayList users = new CopyOnWriteArrayList();
+ private HashMap rolequeue;
public Biscuit(JDA jda, Guild guild, BiscuitLog log) {
this.jda = jda;
@@ -98,7 +98,7 @@ public class Biscuit {
this.config = new BiscuitConfig(this);
config.generateConfig();
this.properties = new BiscuitProperties(this);
-
+ this.rolequeue = new HashMap();
timer = new Timer();
timers = new ArrayList();
if(!Main.isPlugin) {
@@ -137,7 +137,7 @@ public class Biscuit {
public Guild getGuild() {
return guild;
}
-
+
public boolean canManageServer() {
return guild.getSelfMember().hasPermission(Permission.MANAGE_SERVER);
}
@@ -314,6 +314,10 @@ public class Biscuit {
}
}
+ public HashMap getRoleQueue() {
+ return rolequeue;
+ }
+
public void remove() {
log("Removing guild biscuit...");
for(BiscuitTimer t : timers) {
diff --git a/src/main/java/com/fpghoti/biscuit/config/BiscuitConfig.java b/src/main/java/com/fpghoti/biscuit/config/BiscuitConfig.java
index 8079b7e..2406c59 100644
--- a/src/main/java/com/fpghoti/biscuit/config/BiscuitConfig.java
+++ b/src/main/java/com/fpghoti/biscuit/config/BiscuitConfig.java
@@ -173,6 +173,8 @@ public class BiscuitConfig {
added = addProperty("Captcha-Log-Channel", "verify-log", prop, added, silent);
added = addProperty("Check-Join-Invite", "false", prop, added, silent);
added = addProperty("Custom-Command-Names", "", prop, added, silent);
+ added = addProperty("DM-Before-Kick", "true", prop, added, silent);
+ added = addProperty("Kick-DM-Invite", "", prop, added, silent);
if(!isMain) {
if(code != null) {
diff --git a/src/main/java/com/fpghoti/biscuit/config/BiscuitProperties.java b/src/main/java/com/fpghoti/biscuit/config/BiscuitProperties.java
index 83b2062..d95cedf 100644
--- a/src/main/java/com/fpghoti/biscuit/config/BiscuitProperties.java
+++ b/src/main/java/com/fpghoti/biscuit/config/BiscuitProperties.java
@@ -49,6 +49,14 @@ public class BiscuitProperties {
return biscuit.getConfig().getFromConfig(key, biscuit);
}
+ public String getKickDMInvite(){
+ String key = "Kick-DM-Invite";
+ if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) {
+ return Main.getMainBiscuit().getProperties().getKickDMInvite();
+ }
+ return biscuit.getConfig().getFromConfig(key, biscuit);
+ }
+
public boolean captchaEnabled(){
String key = "Captcha";
if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) {
@@ -67,6 +75,15 @@ public class BiscuitProperties {
return value.equalsIgnoreCase("true");
}
+ public boolean dmBeforeKick(){
+ String key = "DM-Before-Kick";
+ if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) {
+ return Main.getMainBiscuit().getProperties().dmBeforeKick();
+ }
+ String value = biscuit.getConfig().getFromConfig(key, biscuit);
+ return value.equalsIgnoreCase("true");
+ }
+
public String getCaptchaReward(){
String key = "Captcha-Reward-Role";
if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) {
diff --git a/src/main/java/com/fpghoti/biscuit/listener/DMListener.java b/src/main/java/com/fpghoti/biscuit/listener/DMListener.java
index d6fab9c..bc02cbe 100644
--- a/src/main/java/com/fpghoti/biscuit/listener/DMListener.java
+++ b/src/main/java/com/fpghoti/biscuit/listener/DMListener.java
@@ -176,7 +176,7 @@ public class DMListener extends ListenerAdapter{
Member member = g.getMemberById(author.getId());
- g.addRoleToMember(member, newrole).queue();
+ g.addRoleToMember(member, newrole).complete();
g.removeRoleFromMember(member, defaultrole).complete();
p.remove();
}
diff --git a/src/main/java/com/fpghoti/biscuit/listener/JoinListener.java b/src/main/java/com/fpghoti/biscuit/listener/JoinListener.java
index 9450140..ef6e364 100644
--- a/src/main/java/com/fpghoti/biscuit/listener/JoinListener.java
+++ b/src/main/java/com/fpghoti/biscuit/listener/JoinListener.java
@@ -55,7 +55,7 @@ public class JoinListener extends ListenerAdapter {
@Async
private void logUserInvite(final User user, final Biscuit b){
Guild g = b.getGuild();
- g.retrieveInvites().queue((invs) -> {
+ g.retrieveInvites().queue(invs -> {
String usedInv = "Other";
HashMap newinv = new HashMap();
boolean empty = b.getInviteUses().isEmpty();
diff --git a/src/main/java/com/fpghoti/biscuit/listener/LeaveListener.java b/src/main/java/com/fpghoti/biscuit/listener/LeaveListener.java
index d6cd961..77f97d1 100644
--- a/src/main/java/com/fpghoti/biscuit/listener/LeaveListener.java
+++ b/src/main/java/com/fpghoti/biscuit/listener/LeaveListener.java
@@ -15,12 +15,16 @@ public class LeaveListener extends ListenerAdapter {
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
User user = event.getMember().getUser();
PreUser u = biscuit.getPreUser(user);
- int time = u.getTimeLeft();
- u.remove();
+ int time = 1;
+ if(u != null) {
+ time = u.getTimeLeft();
+ u.remove();
+ }
if(time > 0) {
biscuit.log(BColor.YELLOW + "USER LEFT: " + user.getName() + " " + user.getAsMention());
biscuit.captchaLog("**User Left: ** ``" + user.getName() + "`` " + user.getAsMention() + "``");
}
+
}
}
\ No newline at end of file
diff --git a/src/main/java/com/fpghoti/biscuit/listener/MessageReceiveListener.java b/src/main/java/com/fpghoti/biscuit/listener/MessageReceiveListener.java
index 4f164b0..ed9234b 100644
--- a/src/main/java/com/fpghoti/biscuit/listener/MessageReceiveListener.java
+++ b/src/main/java/com/fpghoti/biscuit/listener/MessageReceiveListener.java
@@ -65,7 +65,7 @@ public class MessageReceiveListener extends ListenerAdapter{
msg = msg + " ";
}
for(Attachment a : event.getMessage().getAttachments()) {
- tail = tail + msg + " " + a.getUrl();
+ tail = tail + " " + a.getUrl();
}
msg = msg + tail;
}
diff --git a/src/main/java/com/fpghoti/biscuit/logging/BiscuitLog.java b/src/main/java/com/fpghoti/biscuit/logging/BiscuitLog.java
index 6d9da39..217f237 100644
--- a/src/main/java/com/fpghoti/biscuit/logging/BiscuitLog.java
+++ b/src/main/java/com/fpghoti/biscuit/logging/BiscuitLog.java
@@ -3,6 +3,8 @@ package com.fpghoti.biscuit.logging;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.fpghoti.biscuit.Main;
+
public class BiscuitLog {
private final Logger console = LoggerFactory.getLogger("Biscuit");
@@ -10,27 +12,37 @@ public class BiscuitLog {
public void debug(String msg) {
console.debug(BColor.MAGENTA_BOLD + msg + BColor.RESET);
- file.debug(BColor.clear(msg));
+ if(!Main.isPlugin) {
+ file.debug(BColor.clear(msg));
+ }
}
public void error(String msg) {
console.error(BColor.RED + msg + BColor.RESET);
- file.error(BColor.clear(msg));
+ if(!Main.isPlugin) {
+ file.error(BColor.clear(msg));
+ }
}
public void info(String msg) {
console.info(msg + BColor.RESET);
- file.info(BColor.clear(msg));
+ if(!Main.isPlugin) {
+ file.info(BColor.clear(msg));
+ }
}
public void trace(String msg) {
console.trace(BColor.WHITE_BOLD + msg + BColor.RESET);
- file.trace(BColor.clear(msg));
+ if(!Main.isPlugin) {
+ file.trace(BColor.clear(msg));
+ }
}
public void warn(String msg) {
console.warn(BColor.YELLOW + msg + BColor.RESET);
- file.warn(BColor.clear(msg));
+ if(!Main.isPlugin) {
+ file.warn(BColor.clear(msg));
+ }
}
}
diff --git a/src/main/java/com/fpghoti/biscuit/user/PreUser.java b/src/main/java/com/fpghoti/biscuit/user/PreUser.java
index 8e049f9..7a547bc 100644
--- a/src/main/java/com/fpghoti/biscuit/user/PreUser.java
+++ b/src/main/java/com/fpghoti/biscuit/user/PreUser.java
@@ -75,7 +75,7 @@ public class PreUser {
public void setDone() {
this.done = true;
}
-
+
public int getTimeLeft() {
return timeLeft;
}
@@ -97,9 +97,20 @@ public class PreUser {
Member m = biscuit.getGuild().getMember(user);
biscuit.log(user.getName() + " " + user.getAsMention() + " waited too long to complete the captcha. Kicking...");
biscuit.captchaLog("``" + user.getName() +"`` " + user.getAsMention() + " waited too long to complete the captcha! Kicking...");
-
+
if(m != null && m.getRoles().size() == 1 && PermUtil.hasDefaultRole(m) && !PermUtil.hasRewardRole(m)) {
- biscuit.getGuild().kick(user.getId()).queue();
+ if(biscuit.getProperties().dmBeforeKick()) {
+ String msg = "You did not complete the captcha in **"
+ + " " + biscuit.getGuild().getName() + "**! If you believe this is a mistake, rejoin the server"
+ + ", complete the captcha, and inform an administrator.";
+ String invite = biscuit.getProperties().getKickDMInvite().replace(" ", "");
+ if(!invite.equals("")) {
+ msg = msg + " " + invite;
+ }
+ final String fmsg = msg;
+ user.openPrivateChannel().flatMap(channel -> channel.sendMessage(fmsg)).complete();
+ }
+ biscuit.getGuild().kick(user.getId()).submit();
}
remove();
diff --git a/src/main/resources/config.properties b/src/main/resources/config.properties
index 5dda163..a701f1b 100644
--- a/src/main/resources/config.properties
+++ b/src/main/resources/config.properties
@@ -91,6 +91,14 @@ LogCaptcha = false
#Put the name of the text channel you want to log captcha information to.
Captcha-Log-Channel = verify-log
+#DM the user before kicking for captcha.
+DM-Before-Kick = true
+
+#Send an invite to the server when dm-ing kicked users
+#Does nothing when blank
+#Use full link
+Kick-DM-Invite =
+
#List your custom commands here. This line will always generate blank.
#Example - Custom-Command-Names = hello,botcheck,apple
Custom-Command-Names =