Fixed infinite captcha kick bug
This commit is contained in:
parent
eba17ecef2
commit
b8f29984a6
|
@ -3,7 +3,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.fpghoti</groupId>
|
<groupId>com.fpghoti</groupId>
|
||||||
<artifactId>Biscuit</artifactId>
|
<artifactId>Biscuit</artifactId>
|
||||||
<version>1.8.2</version>
|
<version>1.9</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
|
@ -70,24 +70,36 @@ public class PreUser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decrementTime() {
|
public void decrementTime() {
|
||||||
|
|
||||||
|
//User is no longer in guild. Remove PreUser data from Biscuit
|
||||||
if(!capUser.shareGuild()) {
|
if(!capUser.shareGuild()) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//PreUser was created to test PreUser features. Do not proceed with kicking.
|
||||||
if(test) {
|
if(test) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//User has not completed captcha. Proceed with kick check.
|
||||||
if(!done) {
|
if(!done) {
|
||||||
if(biscuit.getProperties().noCaptchaKick()) {
|
if(biscuit.getProperties().noCaptchaKick()) { //Make sure kicking is enabled in config
|
||||||
timeLeft = timeLeft - 1;
|
timeLeft = timeLeft - 1;
|
||||||
if(timeLeft <= 0) {
|
if(timeLeft <= 0) {
|
||||||
Member m = biscuit.getGuild().getMember(user);
|
Member m = biscuit.getGuild().getMember(user);
|
||||||
|
|
||||||
|
if(m == null || PermUtil.hasRewardRole(m) || !PermUtil.hasDefaultRole(m)){ // Do not kick if user has the reward role or does not have the captcha check role.
|
||||||
|
setDone();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
biscuit.log(user.getName() + " " + user.getAsMention() + " waited too long to complete the captcha. Kicking...");
|
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...");
|
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)) {
|
//While being checked for captcha, a user should only have one role. If they have the captcha role and other roles(s),
|
||||||
|
//do not kick. This is to prevent issues from arising where users are given the captcha role after the check.
|
||||||
|
if(m.getRoles().size() == 1) {
|
||||||
if(biscuit.getProperties().dmBeforeKick()) {
|
if(biscuit.getProperties().dmBeforeKick()) {
|
||||||
String msg = "You did not complete the captcha in **"
|
String msg = "You did not complete the captcha in **"
|
||||||
+ " " + biscuit.getGuild().getName() + "**! If you believe this is a mistake, rejoin the server"
|
+ " " + biscuit.getGuild().getName() + "**! If you believe this is a mistake, rejoin the server"
|
||||||
|
@ -103,7 +115,7 @@ public class PreUser {
|
||||||
}
|
}
|
||||||
kick();
|
kick();
|
||||||
});
|
});
|
||||||
}else {
|
}else { //If DMing before kicking is not enabled, just kick.
|
||||||
kick();
|
kick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue