Skip to content

Commit

Permalink
Fixed discord formatting... the issue all along...
Browse files Browse the repository at this point in the history
  • Loading branch information
EazyFTW committed Sep 1, 2020
1 parent c3b3913 commit 49c2d74
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -76,32 +77,33 @@ 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());
return sb.toString();
}

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();
Expand Down

0 comments on commit 49c2d74

Please sign in to comment.