From 7a2d31233ac0aa9f25d3c985df1b6a598daf8247 Mon Sep 17 00:00:00 2001 From: thmsdy Date: Tue, 22 Jun 2021 09:16:29 -0500 Subject: [PATCH] Add more logging --- dependency-reduced-pom.xml | 12 +- pom.xml | 16 +- src/main/java/com/fpghoti/biscuit/Main.java | 4 + .../com/fpghoti/biscuit/biscuit/Biscuit.java | 6 +- .../com/fpghoti/biscuit/captcha/Captcha.java | 2 +- .../biscuit/commands/base/CustomCommand.java | 29 +- .../fpghoti/biscuit/config/BiscuitConfig.java | 110 +-- .../biscuit/config/BiscuitProperties.java | 748 +++++++++--------- .../biscuit/listener/JoinListener.java | 4 +- .../biscuit/listener/LeaveListener.java | 2 +- .../listener/MessageDeleteListener.java | 2 +- .../biscuit/listener/MessageEditListener.java | 5 +- .../listener/MessageReceiveListener.java | 5 +- .../biscuit/listener/NameListener.java | 26 + .../biscuit/listener/NicknameListener.java | 41 + .../fpghoti/biscuit/logging/BiscuitLog.java | 8 +- .../com/fpghoti/biscuit/user/PreUser.java | 2 +- src/main/resources/logback.xml | 4 +- 18 files changed, 549 insertions(+), 477 deletions(-) create mode 100644 src/main/java/com/fpghoti/biscuit/listener/NameListener.java create mode 100644 src/main/java/com/fpghoti/biscuit/listener/NicknameListener.java diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index fcdb5f7..8a07db6 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -67,6 +67,11 @@ + + dv8tion + m2-dv8tion + https://m2.dv8tion.net/releases + spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ @@ -84,13 +89,6 @@ jcenter-bintray https://jcenter.bintray.com - - - false - - soluvas-public-thirdparty - http://nexus.bippo.co.id/nexus/content/repositories/soluvas-public-thirdparty/ - jitpack.io https://jitpack.io diff --git a/pom.xml b/pom.xml index 538d338..3d6e6a6 100644 --- a/pom.xml +++ b/pom.xml @@ -75,6 +75,11 @@ UTF-8 + + dv8tion + m2-dv8tion + https://m2.dv8tion.net/releases + spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ @@ -92,13 +97,6 @@ jcenter-bintray https://jcenter.bintray.com - - soluvas-public-thirdparty - http://nexus.bippo.co.id/nexus/content/repositories/soluvas-public-thirdparty/ - - false - - jitpack.io https://jitpack.io @@ -159,7 +157,7 @@ net.dv8tion JDA - 4.2.0_225 + 4.3.0_281 com.github.cage @@ -179,7 +177,7 @@ com.sedmelluq lavaplayer - 1.3.66 + 1.3.77 org.pf4j diff --git a/src/main/java/com/fpghoti/biscuit/Main.java b/src/main/java/com/fpghoti/biscuit/Main.java index fb9a045..aff65ab 100644 --- a/src/main/java/com/fpghoti/biscuit/Main.java +++ b/src/main/java/com/fpghoti/biscuit/Main.java @@ -60,6 +60,8 @@ import com.fpghoti.biscuit.listener.LeaveListener; import com.fpghoti.biscuit.listener.MessageDeleteListener; import com.fpghoti.biscuit.listener.MessageEditListener; import com.fpghoti.biscuit.listener.MessageReceiveListener; +import com.fpghoti.biscuit.listener.NameListener; +import com.fpghoti.biscuit.listener.NicknameListener; import com.fpghoti.biscuit.listener.ReactionListener; import com.fpghoti.biscuit.listener.RoleListener; import com.fpghoti.biscuit.logging.BColor; @@ -139,6 +141,8 @@ public class Main { jda.addEventListener(new DMListener()); jda.addEventListener(new ReactionListener()); jda.addEventListener(new RoleListener()); + jda.addEventListener(new NicknameListener()); + jda.addEventListener(new NameListener()); biscuits = new ArrayList(); for(Guild g : jda.getGuilds()) { Biscuit.loadGuild(g); diff --git a/src/main/java/com/fpghoti/biscuit/biscuit/Biscuit.java b/src/main/java/com/fpghoti/biscuit/biscuit/Biscuit.java index a230c32..e396c34 100644 --- a/src/main/java/com/fpghoti/biscuit/biscuit/Biscuit.java +++ b/src/main/java/com/fpghoti/biscuit/biscuit/Biscuit.java @@ -227,15 +227,15 @@ public class Biscuit { public ArrayList getCaptchaLogChannels() { ArrayList ch = new ArrayList(); for(TextChannel t : guild.getTextChannels()) { - if(t.getName().equalsIgnoreCase(properties.getCaptchaLogChannel())) { + if(t.getName().equalsIgnoreCase(properties.getEventLogChannel())) { ch.add(t); } } return ch; } - public void captchaLog(String msg) { - if(properties.logCaptcha()) { + public void eventLog(String msg) { + if(properties.logEvents()) { for(TextChannel t : getCaptchaLogChannels()) { MessageText.send(t, msg); } diff --git a/src/main/java/com/fpghoti/biscuit/captcha/Captcha.java b/src/main/java/com/fpghoti/biscuit/captcha/Captcha.java index 1dfc0c1..5bd4e08 100644 --- a/src/main/java/com/fpghoti/biscuit/captcha/Captcha.java +++ b/src/main/java/com/fpghoti/biscuit/captcha/Captcha.java @@ -197,7 +197,7 @@ public class Captcha { token = null; log(BColor.YELLOW_BOLD + author.getName() + " successfully completed a captcha challenge. Granting role."); - biscuit.captchaLog(" ``" + author.getName() +"`` " + author.getAsMention() + " successfully completed a captcha challenge. Granting role."); + biscuit.eventLog(" ``" + author.getName() +"`` " + author.getAsMention() + " successfully completed a captcha challenge. Granting role."); } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/base/CustomCommand.java b/src/main/java/com/fpghoti/biscuit/commands/base/CustomCommand.java index 0c5eef3..a871e3d 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/base/CustomCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/base/CustomCommand.java @@ -1,5 +1,6 @@ package com.fpghoti.biscuit.commands.base; +import com.fpghoti.biscuit.Main; import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.BaseCommand; import com.fpghoti.biscuit.commands.CommandType; @@ -7,35 +8,38 @@ import com.fpghoti.biscuit.commands.CommandType; import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class CustomCommand extends BaseCommand { - + public static String fixPlaceholders(GuildMessageReceivedEvent event, String msg) { msg = msg.replace("", event.getAuthor().getAsMention()); return msg; } - + private String name; private Biscuit biscuit; - + public CustomCommand(String name, Biscuit biscuit) { this.name = name; this.biscuit = biscuit; } - + @Override public String getName() { return this.name; } - + @Override public String getUsage() { return biscuit.getProperties().getCommandSignifier() + name; } - + @Override public String getDescription() { - String desc = biscuit.getConfig().getFromConfig("cc-" + name + "-description", biscuit); + String desc = biscuit.getConfig().getFromConfig("cc-" + name + "-description"); if(desc == null) { - return "null"; + desc = Main.getMainBiscuit().getConfig().getFromConfig("cc-" + name + "-description"); + if(desc == null) { + return "null"; + } } return desc; } @@ -46,11 +50,14 @@ public class CustomCommand extends BaseCommand { } public String getMessage() { - String msg = biscuit.getConfig().getFromConfig("cc-" + name + "-message", biscuit); + String msg = biscuit.getConfig().getFromConfig("cc-" + name + "-message"); if(msg == null) { - return "null"; + msg = Main.getMainBiscuit().getConfig().getFromConfig("cc-" + name + "-message"); + if(msg == null) { + return "null"; + } } return msg; } - + } diff --git a/src/main/java/com/fpghoti/biscuit/config/BiscuitConfig.java b/src/main/java/com/fpghoti/biscuit/config/BiscuitConfig.java index 04fce65..7157c51 100644 --- a/src/main/java/com/fpghoti/biscuit/config/BiscuitConfig.java +++ b/src/main/java/com/fpghoti/biscuit/config/BiscuitConfig.java @@ -61,30 +61,30 @@ public class BiscuitConfig { } @Async - public void replaceConfig(Attachment a, TextChannel c) { - Guild guild = biscuit.getGuild(); - String code = getFromConfig("Guild-Code", biscuit); - if(guild == null) { - biscuit.error("Main config replacement is currently not allowed."); - return; - } - String name = guild.getId() + ".properties"; - if(a.getSize() > 51200) { - MessageText.send(c, "**The file is too big!**"); - return; - } - File config = new File(biscuit.getConfigDir(), name); - a.downloadToFile(config).thenAccept(file -> { - updateConfig(file, true, code); - MessageText.send(c, "**The config was successfully updated.**"); - }).exceptionally(t -> { - biscuit.error("Could not accept config file."); - MessageText.send(c, "**An Exception occurred while trying to read the file.**"); - return null; - }); + public void replaceConfig(Attachment a, TextChannel c) { + Guild guild = biscuit.getGuild(); + String code = getFromConfig("Guild-Code"); + if(guild == null) { + biscuit.error("Main config replacement is currently not allowed."); + return; + } + String name = guild.getId() + ".properties"; + if(a.getSize() > 51200) { + MessageText.send(c, "**The file is too big!**"); + return; + } + File config = new File(biscuit.getConfigDir(), name); + a.downloadToFile(config).thenAccept(file -> { + updateConfig(file, true, code); + MessageText.send(c, "**The config was successfully updated.**"); + }).exceptionally(t -> { + biscuit.error("Could not accept config file."); + MessageText.send(c, "**An Exception occurred while trying to read the file.**"); + return null; + }); - return; - } + return; + } public void updateConfig(File config) { updateConfig(config, false); @@ -172,8 +172,8 @@ public class BiscuitConfig { added = addProperty("Toggle-Role-React-Channels", "toggleroles1,toggleroles2,toggleroles3", prop, added, silent); added = addProperty("Boost-Exclusive-Roles", "role2,role3", prop, added, silent); added = addProperty("Treat-Like-Booster", "Nitro Booster,silver,gold", prop, added, silent); - added = addProperty("LogCaptcha", "false", prop, added, silent); - added = addProperty("Captcha-Log-Channel", "verify-log", prop, added, silent); + added = addProperty("LogEvents", "false", prop, added, silent); + added = addProperty("Event-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); @@ -206,44 +206,44 @@ public class BiscuitConfig { return added; } - public String getFromConfig(String property, Biscuit biscuit){ - boolean isMain = biscuit.getGuild() == null; + public String getFromConfig(String property){ + boolean isMain = biscuit.getGuild() == null; - String setting = ""; + String setting = ""; - Properties prop = new Properties(); - InputStream input = null; + Properties prop = new Properties(); + InputStream input = null; - String name = "config.properties"; + String name = "config.properties"; - if(!isMain) { - name = biscuit.getGuild().getId() + ".properties"; - } - File config = new File(biscuit.getConfigDir(), name); + if(!isMain) { + name = biscuit.getGuild().getId() + ".properties"; + } + File config = new File(biscuit.getConfigDir(), name); - if(!config.exists()) { - return ""; - } + if(!config.exists()) { + return ""; + } - try { - input = new FileInputStream(config); - prop.load(input); - setting = prop.getProperty(property); - } catch (IOException ex) { - ex.printStackTrace(); - } finally { - if (input != null) { - try { - input.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } + try { + input = new FileInputStream(config); + prop.load(input); + setting = prop.getProperty(property); + } catch (IOException ex) { + ex.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } - return setting; + return setting; - } + } public File getFile() { if(biscuit.getGuild() == null) { diff --git a/src/main/java/com/fpghoti/biscuit/config/BiscuitProperties.java b/src/main/java/com/fpghoti/biscuit/config/BiscuitProperties.java index 50ddd79..21e48a5 100644 --- a/src/main/java/com/fpghoti/biscuit/config/BiscuitProperties.java +++ b/src/main/java/com/fpghoti/biscuit/config/BiscuitProperties.java @@ -5,379 +5,379 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.util.Util; public class BiscuitProperties { - - Biscuit biscuit; - - public BiscuitProperties(Biscuit b) { - this.biscuit = b; - } + + Biscuit biscuit; + + public BiscuitProperties(Biscuit b) { + this.biscuit = b; + } - public String getToken(){ - String key = "Bot-Token"; - return Main.getMainBiscuit().getConfig().getFromConfig(key, Main.getMainBiscuit()); - } - - public String getCommandSignifier(){ - String key = "Command-Signifier"; - return Main.getMainBiscuit().getConfig().getFromConfig(key, Main.getMainBiscuit()); - } - - public boolean musicBotEnabled(){ - String key = "Enable-Music-Bot"; - return Main.getMainBiscuit().getConfig().getFromConfig(key, Main.getMainBiscuit()).equalsIgnoreCase("true"); - } - - public boolean logMusicPlayer(){ - String key = "Log-Music-Player"; - return Main.getMainBiscuit().getConfig().getFromConfig(key, Main.getMainBiscuit()).equalsIgnoreCase("true"); - } - - public boolean allowMusicBot(){ - if(!musicBotEnabled()) { - return false; - } - String key = "Allow-Music-Bot"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().allowMusicBot(); - } - String value = biscuit.getConfig().getFromConfig(key, biscuit); - return value.equalsIgnoreCase("true"); - } - - public String getGuildCode(){ - String key = "Guild-Code"; - if(biscuit.getGuild() == null) { - return "MAIN"; - } - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return biscuit.getConfig().makeCode(biscuit.getGuild().getName()); - } - return biscuit.getConfig().getFromConfig(key, biscuit); - } - - public String getDoneEmote(){ - String key = "Done-Emote"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getDoneEmote(); - } - return biscuit.getConfig().getFromConfig(key, biscuit); - } - - public String getMusicControllerRole(){ - String key = "Music-Controller-Role"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getMusicControllerRole(); - } - 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) { - return Main.getMainBiscuit().getProperties().captchaEnabled(); - } - String value = biscuit.getConfig().getFromConfig(key, biscuit); - return value.equalsIgnoreCase("true"); - } - - public boolean customDefaultRole(){ - String key = "UseCustomDefaultRole"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().customDefaultRole(); - } - String value = biscuit.getConfig().getFromConfig(key, biscuit); - 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) { - return Main.getMainBiscuit().getProperties().getCaptchaReward(); - } - return biscuit.getConfig().getFromConfig(key, biscuit); - } - - public String getDefaultRole(){ - String key = "DefaultRoleName"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getDefaultRole(); - } - return biscuit.getConfig().getFromConfig(key, biscuit); - } - - public String getModRole(){ - String key = "ModRole"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getModRole(); - } - return biscuit.getConfig().getFromConfig(key, biscuit); - } - - public String getAdminRole(){ - String key = "AdminRole"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getAdminRole(); - } - return biscuit.getConfig().getFromConfig(key, biscuit); - } - - public String getCaptchaLogChannel(){ - String key = "Captcha-Log-Channel"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getCaptchaLogChannel(); - } - return biscuit.getConfig().getFromConfig(key, biscuit); - } - - public boolean logCaptcha(){ - String key = "LogCaptcha"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().logCaptcha(); - } - String value = biscuit.getConfig().getFromConfig(key, biscuit); - return value.equalsIgnoreCase("true"); - } - - public boolean spamPunishAllow(){ - String key = "AllowSpamPunish"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().spamPunishAllow(); - } - String value = biscuit.getConfig().getFromConfig(key, biscuit); - return value.equalsIgnoreCase("true"); - } - - public boolean checkJoinInvite(){ - String key = "Check-Join-Invite"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().checkJoinInvite(); - } - String value = biscuit.getConfig().getFromConfig(key, biscuit); - return value.equalsIgnoreCase("true"); - } - - public boolean noCaptchaKick(){ - String key = "No-Captcha-Kick"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().noCaptchaKick(); - } - String value = biscuit.getConfig().getFromConfig(key, biscuit); - return value.equalsIgnoreCase("true"); - } - - public Integer noCaptchaKickTime(){ - String key = "No-Captcha-Kick-Time"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().noCaptchaKickTime(); - } - String value = biscuit.getConfig().getFromConfig(key, biscuit); - if(!Util.isDigit(value)) { - return 0; - } - return Integer.parseInt(value); - } - - public boolean logChat(){ - String key = "ChatLog"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().logChat(); - } - String value = biscuit.getConfig().getFromConfig(key, biscuit); - return value.equalsIgnoreCase("true"); - } - - public String[] getNaughtyWords(){ - String key = "NaughtyList"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getNaughtyWords(); - } - String [] list = biscuit.getConfig().getFromConfig(key, biscuit).replace(" ", "").split(","); - if(list.length == 1 && list[0].equals("")) { - String[] blank = {}; - return blank; - } - return list; - } - - public boolean restrictCmdChannels(){ - String key = "Restrict-Cmd-Channels"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().restrictCmdChannels(); - } - String value = biscuit.getConfig().getFromConfig(key, biscuit); - return value.equalsIgnoreCase("true"); - } - - public String[] getCmdChannels(){ - String key = "CmdChannels"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getCmdChannels(); - } - String [] list = biscuit.getConfig().getFromConfig(key, biscuit).replace(" ", "").split(","); - if(list.length == 1 && list[0].equals("")) { - String[] blank = {}; - return blank; - } - return list; - } - - public String[] getDontLogChannels(){ - String key = "Channels-To-Not-Chatlog"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getCmdChannels(); - } - String [] list = biscuit.getConfig().getFromConfig(key, biscuit).replace(" ", "").split(","); - if(list.length == 1 && list[0].equals("")) { - String[] blank = {}; - return blank; - } - return list; - } - - public String[] getToggleRoles(){ - String key = "ToggleRoles"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getToggleRoles(); - } - String [] list = biscuit.getConfig().getFromConfig(key, biscuit).replace(" , ", ",").replace(", ", ",").split(","); - if(list.length == 1 && list[0].equals("")) { - String[] blank = {}; - return blank; - } - return list; - } - - public String[] getBoostExclusiveRoles(){ - String key = "Boost-Exclusive-Roles"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getBoostExclusiveRoles(); - } - String [] list = biscuit.getConfig().getFromConfig(key, biscuit).replace(" , ", ",").replace(", ", ",").split(","); - if(list.length == 1 && list[0].equals("")) { - String[] blank = {}; - return blank; - } - return list; - } - - public String[] getBoosterRoles(){ - String key = "Treat-Like-Booster"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getBoosterRoles(); - } - String [] list = biscuit.getConfig().getFromConfig(key, biscuit).replace(" , ", ",").replace(", ", ",").split(","); - if(list.length == 1 && list[0].equals("")) { - String[] blank = {}; - return blank; - } - return list; - } - - public String[] getMusicChannels(){ - String key = "Music-Channels"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getMusicChannels(); - } - String [] list = biscuit.getConfig().getFromConfig(key, biscuit).replace(" , ", ",").replace(", ", ",").split(","); - if(list.length == 1 && list[0].equals("")) { - String[] blank = {}; - return blank; - } - return list; - } - - public String[] blockedUnicodeEmotes(){ - String key = "Block-Unicode-Emotes"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().blockedUnicodeEmotes(); - } - String [] list = biscuit.getConfig().getFromConfig(key, biscuit).replace(" ", "").split(","); - if(list.length == 1 && list[0].equals("")) { - String[] blank = {}; - return blank; - } - return list; - } + public String getToken(){ + String key = "Bot-Token"; + return Main.getMainBiscuit().getConfig().getFromConfig(key); + } + + public String getCommandSignifier(){ + String key = "Command-Signifier"; + return Main.getMainBiscuit().getConfig().getFromConfig(key); + } + + public boolean musicBotEnabled(){ + String key = "Enable-Music-Bot"; + return Main.getMainBiscuit().getConfig().getFromConfig(key).equalsIgnoreCase("true"); + } + + public boolean logMusicPlayer(){ + String key = "Log-Music-Player"; + return Main.getMainBiscuit().getConfig().getFromConfig(key).equalsIgnoreCase("true"); + } + + public boolean allowMusicBot(){ + if(!musicBotEnabled()) { + return false; + } + String key = "Allow-Music-Bot"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().allowMusicBot(); + } + String value = biscuit.getConfig().getFromConfig(key); + return value.equalsIgnoreCase("true"); + } + + public String getGuildCode(){ + String key = "Guild-Code"; + if(biscuit.getGuild() == null) { + return "MAIN"; + } + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return biscuit.getConfig().makeCode(biscuit.getGuild().getName()); + } + return biscuit.getConfig().getFromConfig(key); + } + + public String getDoneEmote(){ + String key = "Done-Emote"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getDoneEmote(); + } + return biscuit.getConfig().getFromConfig(key); + } + + public String getMusicControllerRole(){ + String key = "Music-Controller-Role"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getMusicControllerRole(); + } + return biscuit.getConfig().getFromConfig(key); + } + + public String getKickDMInvite(){ + String key = "Kick-DM-Invite"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getKickDMInvite(); + } + return biscuit.getConfig().getFromConfig(key); + } + + public boolean captchaEnabled(){ + String key = "Captcha"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().captchaEnabled(); + } + String value = biscuit.getConfig().getFromConfig(key); + return value.equalsIgnoreCase("true"); + } + + public boolean customDefaultRole(){ + String key = "UseCustomDefaultRole"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().customDefaultRole(); + } + String value = biscuit.getConfig().getFromConfig(key); + return value.equalsIgnoreCase("true"); + } + + public boolean dmBeforeKick(){ + String key = "DM-Before-Kick"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().dmBeforeKick(); + } + String value = biscuit.getConfig().getFromConfig(key); + return value.equalsIgnoreCase("true"); + } + + public String getCaptchaReward(){ + String key = "Captcha-Reward-Role"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getCaptchaReward(); + } + return biscuit.getConfig().getFromConfig(key); + } + + public String getDefaultRole(){ + String key = "DefaultRoleName"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getDefaultRole(); + } + return biscuit.getConfig().getFromConfig(key); + } + + public String getModRole(){ + String key = "ModRole"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getModRole(); + } + return biscuit.getConfig().getFromConfig(key); + } + + public String getAdminRole(){ + String key = "AdminRole"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getAdminRole(); + } + return biscuit.getConfig().getFromConfig(key); + } + + public String getEventLogChannel(){ + String key = "Event-Log-Channel"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getEventLogChannel(); + } + return biscuit.getConfig().getFromConfig(key); + } + + public boolean logEvents(){ + String key = "LogEvents"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().logEvents(); + } + String value = biscuit.getConfig().getFromConfig(key); + return value.equalsIgnoreCase("true"); + } + + public boolean spamPunishAllow(){ + String key = "AllowSpamPunish"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().spamPunishAllow(); + } + String value = biscuit.getConfig().getFromConfig(key); + return value.equalsIgnoreCase("true"); + } + + public boolean checkJoinInvite(){ + String key = "Check-Join-Invite"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().checkJoinInvite(); + } + String value = biscuit.getConfig().getFromConfig(key); + return value.equalsIgnoreCase("true"); + } + + public boolean noCaptchaKick(){ + String key = "No-Captcha-Kick"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().noCaptchaKick(); + } + String value = biscuit.getConfig().getFromConfig(key); + return value.equalsIgnoreCase("true"); + } + + public Integer noCaptchaKickTime(){ + String key = "No-Captcha-Kick-Time"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().noCaptchaKickTime(); + } + String value = biscuit.getConfig().getFromConfig(key); + if(!Util.isDigit(value)) { + return 0; + } + return Integer.parseInt(value); + } + + public boolean logChat(){ + String key = "ChatLog"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().logChat(); + } + String value = biscuit.getConfig().getFromConfig(key); + return value.equalsIgnoreCase("true"); + } + + public String[] getNaughtyWords(){ + String key = "NaughtyList"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getNaughtyWords(); + } + String [] list = biscuit.getConfig().getFromConfig(key).replace(" ", "").split(","); + if(list.length == 1 && list[0].equals("")) { + String[] blank = {}; + return blank; + } + return list; + } + + public boolean restrictCmdChannels(){ + String key = "Restrict-Cmd-Channels"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().restrictCmdChannels(); + } + String value = biscuit.getConfig().getFromConfig(key); + return value.equalsIgnoreCase("true"); + } + + public String[] getCmdChannels(){ + String key = "CmdChannels"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getCmdChannels(); + } + String [] list = biscuit.getConfig().getFromConfig(key).replace(" ", "").split(","); + if(list.length == 1 && list[0].equals("")) { + String[] blank = {}; + return blank; + } + return list; + } + + public String[] getDontLogChannels(){ + String key = "Channels-To-Not-Chatlog"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getCmdChannels(); + } + String [] list = biscuit.getConfig().getFromConfig(key).replace(" ", "").split(","); + if(list.length == 1 && list[0].equals("")) { + String[] blank = {}; + return blank; + } + return list; + } + + public String[] getToggleRoles(){ + String key = "ToggleRoles"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getToggleRoles(); + } + String [] list = biscuit.getConfig().getFromConfig(key).replace(" , ", ",").replace(", ", ",").split(","); + if(list.length == 1 && list[0].equals("")) { + String[] blank = {}; + return blank; + } + return list; + } + + public String[] getBoostExclusiveRoles(){ + String key = "Boost-Exclusive-Roles"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getBoostExclusiveRoles(); + } + String [] list = biscuit.getConfig().getFromConfig(key).replace(" , ", ",").replace(", ", ",").split(","); + if(list.length == 1 && list[0].equals("")) { + String[] blank = {}; + return blank; + } + return list; + } + + public String[] getBoosterRoles(){ + String key = "Treat-Like-Booster"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getBoosterRoles(); + } + String [] list = biscuit.getConfig().getFromConfig(key).replace(" , ", ",").replace(", ", ",").split(","); + if(list.length == 1 && list[0].equals("")) { + String[] blank = {}; + return blank; + } + return list; + } + + public String[] getMusicChannels(){ + String key = "Music-Channels"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getMusicChannels(); + } + String [] list = biscuit.getConfig().getFromConfig(key).replace(" , ", ",").replace(", ", ",").split(","); + if(list.length == 1 && list[0].equals("")) { + String[] blank = {}; + return blank; + } + return list; + } + + public String[] blockedUnicodeEmotes(){ + String key = "Block-Unicode-Emotes"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().blockedUnicodeEmotes(); + } + String [] list = biscuit.getConfig().getFromConfig(key).replace(" ", "").split(","); + if(list.length == 1 && list[0].equals("")) { + String[] blank = {}; + return blank; + } + return list; + } - public String[] blockedCustomEmotes(){ - String key = "Block-Custom-Emotes"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().blockedCustomEmotes(); - } - String [] list = biscuit.getConfig().getFromConfig(key, biscuit).replace(" ", "").split(","); - if(list.length == 1 && list[0].equals("")) { - String[] blank = {}; - return blank; - } - return list; - } - - public String[] getCustomCmds(){ - String key = "Custom-Command-Names"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getCustomCmds(); - } - String [] list = biscuit.getConfig().getFromConfig(key, biscuit).replace(" ", "").split(","); - if(list.length == 1 && list[0].equals("")) { - String[] blank = {}; - return blank; - } - return list; - } - - public String[] disabledCommands(){ - String key = "DisabledCommands"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().disabledCommands(); - } - String [] list = biscuit.getConfig().getFromConfig(key, biscuit).replace(" ", "").split(","); - if(list.length == 1 && list[0].equals("")) { - String[] blank = {}; - return blank; - } - return list; - } - - public String[] disabledUserCommands(){ - String key = "DisabledUserCommands"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().disabledUserCommands(); - } - String [] list = biscuit.getConfig().getFromConfig(key, biscuit).replace(" ", "").split(","); - if(list.length == 1 && list[0].equals("")) { - String[] blank = {}; - return blank; - } - return list; - } - - public String[] getToggleChannels(){ - String key = "Toggle-Role-React-Channels"; - if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { - return Main.getMainBiscuit().getProperties().getToggleChannels(); - } - String [] list = biscuit.getConfig().getFromConfig(key, biscuit).replace(" ", "").split(","); - if(list.length == 1 && list[0].equals("")) { - String[] blank = {}; - return blank; - } - return list; - } -} + public String[] blockedCustomEmotes(){ + String key = "Block-Custom-Emotes"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().blockedCustomEmotes(); + } + String [] list = biscuit.getConfig().getFromConfig(key).replace(" ", "").split(","); + if(list.length == 1 && list[0].equals("")) { + String[] blank = {}; + return blank; + } + return list; + } + + public String[] getCustomCmds(){ + String key = "Custom-Command-Names"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getCustomCmds(); + } + String [] list = biscuit.getConfig().getFromConfig(key).replace(" ", "").split(","); + if(list.length == 1 && list[0].equals("")) { + String[] blank = {}; + return blank; + } + return list; + } + + public String[] disabledCommands(){ + String key = "DisabledCommands"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().disabledCommands(); + } + String [] list = biscuit.getConfig().getFromConfig(key).replace(" ", "").split(","); + if(list.length == 1 && list[0].equals("")) { + String[] blank = {}; + return blank; + } + return list; + } + + public String[] disabledUserCommands(){ + String key = "DisabledUserCommands"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().disabledUserCommands(); + } + String [] list = biscuit.getConfig().getFromConfig(key).replace(" ", "").split(","); + if(list.length == 1 && list[0].equals("")) { + String[] blank = {}; + return blank; + } + return list; + } + + public String[] getToggleChannels(){ + String key = "Toggle-Role-React-Channels"; + if(biscuit.getConfig().getFromConfig(key).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) { + return Main.getMainBiscuit().getProperties().getToggleChannels(); + } + String [] list = biscuit.getConfig().getFromConfig(key).replace(" ", "").split(","); + if(list.length == 1 && list[0].equals("")) { + String[] blank = {}; + return blank; + } + return list; + } +} \ No newline at end of file diff --git a/src/main/java/com/fpghoti/biscuit/listener/JoinListener.java b/src/main/java/com/fpghoti/biscuit/listener/JoinListener.java index d0cab0c..21068d8 100644 --- a/src/main/java/com/fpghoti/biscuit/listener/JoinListener.java +++ b/src/main/java/com/fpghoti/biscuit/listener/JoinListener.java @@ -22,7 +22,7 @@ public class JoinListener extends ListenerAdapter { Biscuit biscuit = Biscuit.getBiscuit(event.getGuild()); User user = event.getMember().getUser(); biscuit.log(BColor.YELLOW_BOLD + "USER JOINED: " + user.getName() + " " + user.getAsMention()); - biscuit.captchaLog("**User Joined:** ``" + user.getName() + "`` " + user.getAsMention()); + biscuit.eventLog("**User Joined:** ``" + user.getName() + "`` " + user.getAsMention()); if(biscuit.canManageServer() && biscuit.getProperties().checkJoinInvite()) { logUserInvite(user, biscuit); }else { @@ -74,7 +74,7 @@ public class JoinListener extends ListenerAdapter { } b.setInviteUses(newinv); b.log(BColor.YELLOW_BOLD + "INVITE INFO: " + BColor.WHITE + user.getName() + " used invite: " + BColor.GREEN_BOLD + usedInv); - b.captchaLog("**Invite Info:** ``" + user.getName() + "`` used invite: ``" + usedInv + "``"); + b.eventLog("**Invite Info:** ``" + user.getName() + "`` used invite: ``" + usedInv + "``"); }); } diff --git a/src/main/java/com/fpghoti/biscuit/listener/LeaveListener.java b/src/main/java/com/fpghoti/biscuit/listener/LeaveListener.java index 708c743..0a4cec8 100644 --- a/src/main/java/com/fpghoti/biscuit/listener/LeaveListener.java +++ b/src/main/java/com/fpghoti/biscuit/listener/LeaveListener.java @@ -22,7 +22,7 @@ public class LeaveListener extends ListenerAdapter { } if(time > 0) { biscuit.log(BColor.YELLOW + "USER LEFT: " + user.getName() + " " + user.getAsMention()); - biscuit.captchaLog("**User Left: ** ``" + user.getName() + "`` " + user.getAsMention()); + biscuit.eventLog("**User Left: ** ``" + user.getName() + "`` " + user.getAsMention()); } } diff --git a/src/main/java/com/fpghoti/biscuit/listener/MessageDeleteListener.java b/src/main/java/com/fpghoti/biscuit/listener/MessageDeleteListener.java index b0ddaa7..ac8383e 100644 --- a/src/main/java/com/fpghoti/biscuit/listener/MessageDeleteListener.java +++ b/src/main/java/com/fpghoti/biscuit/listener/MessageDeleteListener.java @@ -13,7 +13,7 @@ public class MessageDeleteListener extends ListenerAdapter { public void onMessageDelete(MessageDeleteEvent event) { Biscuit biscuit = Biscuit.getBiscuit(event.getGuild()); if(Util.isLoggable(event.getTextChannel())) { - biscuit.log(BColor.MAGENTA_BOLD + "Message " + event.getMessageId() + " was deleted."); + biscuit.log("[" + BColor.MAGENTA + "#" + event.getChannel().getName() + BColor.RESET + "] " + BColor.MAGENTA_BOLD + "Message " + event.getMessageId() + " was deleted."); } } diff --git a/src/main/java/com/fpghoti/biscuit/listener/MessageEditListener.java b/src/main/java/com/fpghoti/biscuit/listener/MessageEditListener.java index 86e8f67..0807361 100644 --- a/src/main/java/com/fpghoti/biscuit/listener/MessageEditListener.java +++ b/src/main/java/com/fpghoti/biscuit/listener/MessageEditListener.java @@ -14,9 +14,8 @@ public class MessageEditListener extends ListenerAdapter { Biscuit biscuit = Biscuit.getBiscuit(event.getGuild()); if(Util.isLoggable(event.getTextChannel()) && (!event.getAuthor().getName().equalsIgnoreCase("jbot") && !event.getAuthor().isBot())) { biscuit.log("[" + BColor.CYAN_BOLD + "MSG EDIT" + BColor.RESET + "] " + BColor.CYAN + "ID: " + BColor.RESET + - event.getMessageId() + BColor.CYAN + " User: " + BColor.RESET + event.getAuthor().getAsMention() + - BColor.GREEN + " Channel: " + BColor.RESET + event.getChannel().getName()); - biscuit.log(BColor.CYAN + event.getAuthor().getName() + ": " + BColor.WHITE_BOLD + event.getMessage().getContentDisplay()); + event.getMessageId() + BColor.CYAN + " User: " + BColor.RESET + event.getAuthor().getAsMention()); + biscuit.log("[" + BColor.CYAN_BOLD + "#" + event.getChannel().getName() + BColor.RESET + "] " + BColor.CYAN + event.getAuthor().getName() + ": " + BColor.WHITE_BOLD + event.getMessage().getContentDisplay()); } } diff --git a/src/main/java/com/fpghoti/biscuit/listener/MessageReceiveListener.java b/src/main/java/com/fpghoti/biscuit/listener/MessageReceiveListener.java index 44655b3..62cfc42 100644 --- a/src/main/java/com/fpghoti/biscuit/listener/MessageReceiveListener.java +++ b/src/main/java/com/fpghoti/biscuit/listener/MessageReceiveListener.java @@ -54,8 +54,7 @@ public class MessageReceiveListener extends ListenerAdapter{ if(Util.isLoggable(event.getChannel())) { if(biscuit.getProperties().logChat()) { biscuit.log("[" + BColor.CYAN_BOLD + "MSG" + BColor.RESET + "] " + BColor.GREEN + "ID: " + BColor.RESET + - event.getMessageId() + BColor.GREEN + " Sender: " + BColor.RESET + event.getAuthor().getAsMention() + - BColor.GREEN + " Channel: " + BColor.RESET + event.getChannel().getName()); + event.getMessageId() + BColor.GREEN + " Sender: " + BColor.RESET + event.getAuthor().getAsMention()); String msg = event.getMessage().getContentDisplay(); if(event.getMessage().getAttachments().size() >= 1) { @@ -69,7 +68,7 @@ public class MessageReceiveListener extends ListenerAdapter{ msg = msg + tail; } - biscuit.log(BColor.GREEN_BOLD + event.getAuthor().getName() + ": " + BColor.WHITE_BOLD + msg); + biscuit.log("[" + BColor.CYAN_BOLD + "#" + event.getChannel().getName() + BColor.RESET + "] " + BColor.GREEN_BOLD + event.getAuthor().getName() + ": " + BColor.RESET + msg); } } } diff --git a/src/main/java/com/fpghoti/biscuit/listener/NameListener.java b/src/main/java/com/fpghoti/biscuit/listener/NameListener.java new file mode 100644 index 0000000..3a8f981 --- /dev/null +++ b/src/main/java/com/fpghoti/biscuit/listener/NameListener.java @@ -0,0 +1,26 @@ +package com.fpghoti.biscuit.listener; + +import com.fpghoti.biscuit.Main; +import com.fpghoti.biscuit.biscuit.Biscuit; +import com.fpghoti.biscuit.logging.BColor; + +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.User; +import net.dv8tion.jda.api.events.user.update.UserUpdateNameEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; + +public class NameListener extends ListenerAdapter { + + @Override + public void onUserUpdateName(UserUpdateNameEvent event) { + User user = event.getUser(); + Main.getMainBiscuit().log(BColor.CYAN_BOLD + "User " + user.getName() + " " + user.getAsMention() + " changed username from " + + event.getOldName() + " to " + event.getNewName() + "."); + for(Guild guild : user.getMutualGuilds()) { + Biscuit biscuit = Biscuit.getBiscuit(guild); + biscuit.eventLog("**Username changed:** ``" + user.getName() + "`` " + user.getAsMention() + " - From ``" + + event.getOldName() + "`` to ``" + event.getNewName() + "``"); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/fpghoti/biscuit/listener/NicknameListener.java b/src/main/java/com/fpghoti/biscuit/listener/NicknameListener.java new file mode 100644 index 0000000..724c195 --- /dev/null +++ b/src/main/java/com/fpghoti/biscuit/listener/NicknameListener.java @@ -0,0 +1,41 @@ +package com.fpghoti.biscuit.listener; + +import com.fpghoti.biscuit.biscuit.Biscuit; +import com.fpghoti.biscuit.logging.BColor; + +import net.dv8tion.jda.api.entities.User; +import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateNicknameEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; + +public class NicknameListener extends ListenerAdapter { + + @Override + public void onGuildMemberUpdateNickname(GuildMemberUpdateNicknameEvent event) { + Biscuit biscuit = Biscuit.getBiscuit(event.getGuild()); + User user = event.getMember().getUser(); + String oldNick = "None"; + String newNick = "None"; + + if(event.getOldNickname() != null) { + oldNick = event.getOldNickname(); + } + + if(event.getNewNickname() != null) { + newNick = event.getNewNickname(); + } + + biscuit.log(BColor.CYAN + "User " + user.getName() + " " + user.getAsMention() + " changed nickname from " + + oldNick + " to " + newNick + "."); + + if(event.getOldNickname() != null) { + oldNick = "``" + event.getOldNickname() + "``"; + } + + if(event.getNewNickname() != null) { + newNick = "``" + event.getNewNickname() + "``"; + } + biscuit.eventLog("**Nickname changed:** ``" + user.getName() + "`` " + user.getAsMention() + " - From " + + oldNick + " to " + newNick); + } + +} \ No newline at end of file diff --git a/src/main/java/com/fpghoti/biscuit/logging/BiscuitLog.java b/src/main/java/com/fpghoti/biscuit/logging/BiscuitLog.java index 217f237..73c4b04 100644 --- a/src/main/java/com/fpghoti/biscuit/logging/BiscuitLog.java +++ b/src/main/java/com/fpghoti/biscuit/logging/BiscuitLog.java @@ -11,14 +11,14 @@ public class BiscuitLog { private final Logger file = LoggerFactory.getLogger("B-File"); public void debug(String msg) { - console.debug(BColor.MAGENTA_BOLD + msg + BColor.RESET); + console.debug("[" + BColor.MAGENTA_BOLD + "DEBUG" + BColor.RESET + "] " + BColor.MAGENTA + msg + BColor.RESET); if(!Main.isPlugin) { file.debug(BColor.clear(msg)); } } public void error(String msg) { - console.error(BColor.RED + msg + BColor.RESET); + console.error("[" + BColor.RED_BOLD + "ERROR" + BColor.RESET + "] " + BColor.RED + msg + BColor.RESET); if(!Main.isPlugin) { file.error(BColor.clear(msg)); } @@ -32,14 +32,14 @@ public class BiscuitLog { } public void trace(String msg) { - console.trace(BColor.WHITE_BOLD + msg + BColor.RESET); + console.trace("[" + BColor.CYAN_BOLD + "TRACE" + BColor.RESET + "] " + BColor.CYAN + msg + BColor.RESET); if(!Main.isPlugin) { file.trace(BColor.clear(msg)); } } public void warn(String msg) { - console.warn(BColor.YELLOW + msg + BColor.RESET); + console.warn("[" + BColor.YELLOW_BOLD + "WARN" + BColor.RESET + "] " + BColor.YELLOW + msg + BColor.RESET); 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 3c4f0db..9fa8351 100644 --- a/src/main/java/com/fpghoti/biscuit/user/PreUser.java +++ b/src/main/java/com/fpghoti/biscuit/user/PreUser.java @@ -95,7 +95,7 @@ public class PreUser { } 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.eventLog("``" + user.getName() +"`` " + user.getAsMention() + " waited too long to complete the captcha! Kicking..."); //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. diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 7e3e7cd..ac7fa63 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -7,7 +7,7 @@ - %colorize([%date{MM/dd/yyyy HH:mm:ss}] %level) - %msg%n + %colorize([%date{MM/dd/yyyy HH:mm:ss}]) %msg%n @@ -19,7 +19,7 @@ - [%date{MM/dd/yyyy HH:mm:ss}] %level - %msg%n + [%date{MM/dd/yyyy HH:mm:ss}] %msg%n