From 49c2d7475d31c2ccf342b86b24f1af041d86eef0 Mon Sep 17 00:00:00 2001 From: EazyFTW Date: Tue, 1 Sep 2020 17:04:45 -0500 Subject: [PATCH] Fixed discord formatting... the issue all along... --- .../TechDiscordBot/module/cmds/PreorderCommand.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/PreorderCommand.java b/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/PreorderCommand.java index 181e0360..a543ffb4 100644 --- a/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/PreorderCommand.java +++ b/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/PreorderCommand.java @@ -61,6 +61,7 @@ public void onCommand(TextChannel channel, Message message, Member member, Strin Member finalSelectedMember = selectedMember; Preorder preorder = TechDiscordBot.getStorage().getPreorders(getRoles().get(0).replace(" Preorder", ""), false).stream().filter(po -> po.getDiscordId() == finalSelectedMember.getUser().getIdLong()).findFirst().orElse(null); + if(preorder == null) { new TechEmbedBuilder("Preorder Cmd - Error") .error() @@ -76,21 +77,21 @@ public void onCommand(TextChannel channel, Message message, Member member, Strin new TechEmbedBuilder("Preorder - " + selectedMember.getEffectiveName() + "#" + selectedMember.getUser().getDiscriminator()) .success() - .addField("Email", showEmail ? preorder.getEmail() : obfuscateEmail(preorder.getEmail()), true) - .addField("Transaction ID", showTransactionId ? preorder.getTransactionId() : obfuscateTransactionId(preorder.getTransactionId()), true) + .addField("Email", (showEmail ? preorder.getEmail() : obfuscateEmail(preorder.getEmail())), true) + .addField("Transaction ID", (showTransactionId ? preorder.getTransactionId() : obfuscateTransactionId(preorder.getTransactionId())), true) .addField("Plugin", (query.hasAny() ? query.first().getAsMention() + " " : "") + preorder.getPlugin(), true) .addField("Discord Name", preorder.getDiscordName() + " (" + selectedMember.getAsMention() + ")", true) .send(channel); } public String obfuscateEmail(String email) { - if(email.equals("notAvailable") || email.equals("ManuallyAdded") || email.equals("NONE") || email.equals("something")) return "Unknown"; + if(email.equals("notAvailable") || email.equals("ManuallyAdded")) return "Unknown"; int index = email.indexOf("@"); if(index == -1) return email; StringBuilder length = new StringBuilder(); - for(int i = 0; i < index; i++) length.append("*"); + for(int i = 0; i < index; i++) length.append("\\*"); StringBuilder sb = new StringBuilder(email); sb.replace(0, index, length.toString()); @@ -98,10 +99,11 @@ public String obfuscateEmail(String email) { } public String obfuscateTransactionId(String transactionId) { + if(transactionId.equals("NONE") || transactionId.equals("something")) return "Unknown"; StringBuilder sb = new StringBuilder(transactionId); StringBuilder length = new StringBuilder(); - for(int i = 0; i < (int)(transactionId.length() / 1.5d); i++) length.append("*"); + for(int i = 0; i < (int)(transactionId.length() / 1.5d); i++) length.append("\\*"); sb.replace(0, (int)(transactionId.length() / 1.5d), length.toString()); return sb.toString();