diff --git a/src/main/java/me/alexander/discordbot/SelfBot/ICommandSelfBot.java b/src/main/java/me/alexander/discordbot/SelfBot/ICommandSelfBot.java index 0e38cb2..4d5feb2 100644 --- a/src/main/java/me/alexander/discordbot/SelfBot/ICommandSelfBot.java +++ b/src/main/java/me/alexander/discordbot/SelfBot/ICommandSelfBot.java @@ -42,20 +42,23 @@ public static void doCmd(final String in, final Message message, final SelfBot b case "/ban": message.delete(); if (args.equals("")) { - EmbedBuilder emb = EmbeddedMessageUtil.getEmbeddedMessage("Usage Warning", "Invalid argument", "", "", "", Color.RED); + EmbedBuilder emb = EmbeddedMessageUtil.getEmbeddedMessage("Usage Warning", "Invalid argument", "", "", + "", Color.RED); deleteMessageLater(message.reply("", emb), 2, TimeUnit.SECONDS); break; } User user = Utils.getUser(args, message.getChannelReceiver().getServer(), bot); if (user == null) { - EmbedBuilder emb = EmbeddedMessageUtil.getEmbeddedMessage("Usage Warning", "User not found", "", "", "", Color.RED); + EmbedBuilder emb = EmbeddedMessageUtil.getEmbeddedMessage("Usage Warning", "User not found", "", "", "", + Color.RED); deleteMessageLater(message.reply("", emb), 2, TimeUnit.SECONDS); break; } // Make sure we have permission to ban in this discord server if (!Utils.hasPermission(bot.getAPI().getYourself(), message.getChannelReceiver().getServer(), PermissionType.BAN_MEMBERS)) { - EmbedBuilder emb = EmbeddedMessageUtil.getEmbeddedMessage("Usage Warning", "You are not permitted to ban others!", "", "", "", Color.RED); + EmbedBuilder emb = EmbeddedMessageUtil.getEmbeddedMessage("Usage Warning", + "You are not permitted to ban others!", "", "", "", Color.RED); deleteMessageLater(message.reply("", emb), 2, TimeUnit.SECONDS); break; } @@ -66,7 +69,6 @@ public static void doCmd(final String in, final Message message, final SelfBot b Color.YELLOW); message.reply("", emb); break; - case "/user": case "/embed": message.delete(); EmbeddedMessageUtil.embed(message, bot); diff --git a/src/main/java/me/alexander/discordbot/SelfBot/Messages/EmbeddedMessageUtil.java b/src/main/java/me/alexander/discordbot/SelfBot/Messages/EmbeddedMessageUtil.java index 4ef83c2..7fc3002 100644 --- a/src/main/java/me/alexander/discordbot/SelfBot/Messages/EmbeddedMessageUtil.java +++ b/src/main/java/me/alexander/discordbot/SelfBot/Messages/EmbeddedMessageUtil.java @@ -4,9 +4,9 @@ import static me.alexander.discordbot.SelfBot.Utils.getUser; import java.awt.Color; +import java.security.SecureRandom; import java.text.SimpleDateFormat; import java.util.Calendar; -import java.util.Random; import java.util.concurrent.Future; import de.btobastian.javacord.entities.Channel; @@ -17,13 +17,12 @@ public class EmbeddedMessageUtil { - private EmbeddedMessageUtil() { - } + private EmbeddedMessageUtil() {} /** * Random to get random RGB values for the color */ - private static Random rand = new Random(); + private static SecureRandom rand = new SecureRandom(); /** * Builds an embedded message @@ -97,7 +96,7 @@ public static Future embed(final Message message, final SelfBot bot) { } String msg = message.getContent().replace("/embed ", ""); - + return message.reply("", generateEmbed(msg, bot)); } @@ -112,7 +111,7 @@ public static Future embed(final Message message, final SelfBot bot) { public static Future embed(String msg, final SelfBot bot, final Channel channel) { return channel.sendMessage("", generateEmbed(msg, bot)); } - + public static EmbedBuilder generateEmbed(String msg, final SelfBot bot) { try { final EmbedBuilder emb = new EmbedBuilder();