Minor bug fix

This commit is contained in:
Ghoti 2020-07-15 21:20:44 -05:00
parent 4b443a1a6c
commit 5dc66effca
6 changed files with 50 additions and 4 deletions

View File

@ -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.6</version> <version>1.6.1</version>
<build> <build>
<sourceDirectory>src/main/java</sourceDirectory> <sourceDirectory>src/main/java</sourceDirectory>
<resources> <resources>

View File

@ -5,7 +5,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.6</version> <version>1.6.1</version>
<build> <build>
<sourceDirectory>src/main/java</sourceDirectory> <sourceDirectory>src/main/java</sourceDirectory>
<resources> <resources>

View File

@ -38,6 +38,7 @@ import com.fpghoti.biscuit.commands.console.ShutdownConsoleCommand;
import com.fpghoti.biscuit.listener.DMListener; import com.fpghoti.biscuit.listener.DMListener;
import com.fpghoti.biscuit.listener.GuildListener; import com.fpghoti.biscuit.listener.GuildListener;
import com.fpghoti.biscuit.listener.JoinListener; import com.fpghoti.biscuit.listener.JoinListener;
import com.fpghoti.biscuit.listener.LeaveListener;
import com.fpghoti.biscuit.listener.MessageDeleteListener; import com.fpghoti.biscuit.listener.MessageDeleteListener;
import com.fpghoti.biscuit.listener.MessageEditListener; import com.fpghoti.biscuit.listener.MessageEditListener;
import com.fpghoti.biscuit.listener.MessageReceiveListener; import com.fpghoti.biscuit.listener.MessageReceiveListener;
@ -93,6 +94,7 @@ public class Main {
jda.addEventListener(new MessageEditListener()); jda.addEventListener(new MessageEditListener());
jda.addEventListener(new MessageDeleteListener()); jda.addEventListener(new MessageDeleteListener());
jda.addEventListener(new JoinListener()); jda.addEventListener(new JoinListener());
jda.addEventListener(new LeaveListener());
jda.addEventListener(new DMListener()); jda.addEventListener(new DMListener());
jda.addEventListener(new ReactionListener()); jda.addEventListener(new ReactionListener());
jda.addEventListener(new RoleListener()); jda.addEventListener(new RoleListener());

View File

@ -0,0 +1,26 @@
package com.fpghoti.biscuit.listener;
import com.fpghoti.biscuit.biscuit.Biscuit;
import com.fpghoti.biscuit.logging.BColor;
import com.fpghoti.biscuit.user.PreUser;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
public class LeaveListener extends ListenerAdapter {
@Override
public void onGuildMemberRemove(GuildMemberRemoveEvent event) {
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
User user = event.getMember().getUser();
PreUser u = biscuit.getPreUser(user);
int 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() + "``");
}
}
}

View File

@ -11,6 +11,7 @@ import com.fpghoti.biscuit.util.PermUtil;
import com.fpghoti.biscuit.util.Util; import com.fpghoti.biscuit.util.Util;
import net.dv8tion.jda.api.entities.ChannelType; import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.Message.Attachment;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.hooks.ListenerAdapter;
@ -56,7 +57,20 @@ public class MessageReceiveListener extends ListenerAdapter{
biscuit.log("[" + BColor.CYAN_BOLD + "MSG" + BColor.RESET + "] " + BColor.GREEN + "ID: " + BColor.RESET + biscuit.log("[" + BColor.CYAN_BOLD + "MSG" + BColor.RESET + "] " + BColor.GREEN + "ID: " + BColor.RESET +
event.getMessageId() + BColor.GREEN + " Sender: " + BColor.RESET + event.getAuthor().getAsMention() + event.getMessageId() + BColor.GREEN + " Sender: " + BColor.RESET + event.getAuthor().getAsMention() +
BColor.GREEN + " Channel: " + BColor.RESET + event.getChannel().getName()); BColor.GREEN + " Channel: " + BColor.RESET + event.getChannel().getName());
biscuit.log(BColor.GREEN_BOLD + event.getAuthor().getName() + ": " + BColor.WHITE_BOLD + event.getMessage().getContentDisplay()); String msg = event.getMessage().getContentDisplay();
if(event.getMessage().getAttachments().size() >= 1) {
String tail = BColor.CYAN + "[ATTACHMENT(S)]: ";
if(!msg.equals("")) {
msg = msg + " ";
}
for(Attachment a : event.getMessage().getAttachments()) {
tail = tail + msg + " " + a.getUrl();
}
msg = msg + tail;
}
biscuit.log(BColor.GREEN_BOLD + event.getAuthor().getName() + ": " + BColor.WHITE_BOLD + msg);
} }
} }
} }

View File

@ -76,6 +76,10 @@ public class PreUser {
this.done = true; this.done = true;
} }
public int getTimeLeft() {
return timeLeft;
}
public void decrementTime() { public void decrementTime() {
if(!shareGuild()) { if(!shareGuild()) {
remove(); remove();
@ -94,7 +98,7 @@ public class PreUser {
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(biscuit.getGuild().getMember(user).getRoles().size() == 1 && PermUtil.hasDefaultRole(m) && !PermUtil.hasRewardRole(m)) { if(m != null && m.getRoles().size() == 1 && PermUtil.hasDefaultRole(m) && !PermUtil.hasRewardRole(m)) {
biscuit.getGuild().kick(user.getId()).queue(); biscuit.getGuild().kick(user.getId()).queue();
} }