diff --git a/src/main/java/de/presti/ree6/commands/impl/level/Level.java b/src/main/java/de/presti/ree6/commands/impl/level/Level.java index 91ec7a86f..1f426acf3 100644 --- a/src/main/java/de/presti/ree6/commands/impl/level/Level.java +++ b/src/main/java/de/presti/ree6/commands/impl/level/Level.java @@ -21,29 +21,30 @@ public void onPerform(CommandEvent commandEvent) { if (commandEvent.isSlashCommand()) { OptionMapping targetOption = commandEvent.getSlashCommandInteractionEvent().getOption("target"); + OptionMapping levelType = commandEvent.getSlashCommandInteractionEvent().getOption("typ"); - if (targetOption != null && targetOption.getAsMember() != null) { - sendLevel(targetOption.getAsMember(), commandEvent); + if (targetOption != null && targetOption.getAsMember() != null && levelType != null) { + sendLevel(targetOption.getAsMember(), commandEvent, levelType.getAsString()); } else { - sendLevel(commandEvent.getMember(), commandEvent); + sendLevel(commandEvent.getMember(), commandEvent, "chat"); } } else { - if (commandEvent.getArguments().length <= 1) { + if (commandEvent.getArguments().length == 1 || commandEvent.getArguments().length == 2) { if (commandEvent.getMessage().getMentionedMembers().isEmpty()) { - sendLevel(commandEvent.getMember(), commandEvent); + sendLevel(commandEvent.getMember(), commandEvent, commandEvent.getArguments()[0]); } else { - sendLevel(commandEvent.getMessage().getMentionedMembers().get(0), commandEvent); + sendLevel(commandEvent.getMessage().getMentionedMembers().get(0), commandEvent, commandEvent.getArguments()[0]); } } else { Main.getInstance().getCommandManager().sendMessage("Not enough Arguments!", commandEvent.getTextChannel(), commandEvent.getInteractionHook()); - Main.getInstance().getCommandManager().sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "level or " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "level @user", commandEvent.getTextChannel(), commandEvent.getInteractionHook()); + Main.getInstance().getCommandManager().sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "level chat/voice or " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "level chat/voice @user", commandEvent.getTextChannel(), commandEvent.getInteractionHook()); } } } @Override public CommandData getCommandData() { - return new CommandDataImpl("level", "Show your own Level or the Level of another User in the Guild.") + return new CommandDataImpl("level", "Show your own Level or the Level of another User in the Guild.").addOptions(new OptionData(OptionType.STRING, "typ", "Do you want to see chat or voice level?").setRequired(true)) .addOptions(new OptionData(OptionType.USER, "target", "Show the Level of the User.")); } @@ -52,11 +53,11 @@ public String[] getAlias() { return new String[] {"lvl", "xp", "rank"}; } - public void sendLevel(Member member, CommandEvent commandEvent) { + public void sendLevel(Member member, CommandEvent commandEvent, String type) { - // TODO Add Voice Level support. - - UserLevel userLevel = Main.getInstance().getSqlConnector().getSqlWorker().getChatLevelData(commandEvent.getGuild().getId(), member.getId()); + UserLevel userLevel = type.equalsIgnoreCase("chat") ? + Main.getInstance().getSqlConnector().getSqlWorker().getChatLevelData(commandEvent.getGuild().getId(), member.getId()) : + Main.getInstance().getSqlConnector().getSqlWorker().getVoiceLevelData(commandEvent.getGuild().getId(), member.getId()); userLevel.setUser(member.getUser()); if (commandEvent.isSlashCommand()) { diff --git a/src/main/java/de/presti/ree6/main/Main.java b/src/main/java/de/presti/ree6/main/Main.java index 95825c924..5a233f4ad 100644 --- a/src/main/java/de/presti/ree6/main/Main.java +++ b/src/main/java/de/presti/ree6/main/Main.java @@ -129,7 +129,7 @@ public static void main(String[] args) { // Create a new Instance of the Bot, as well as add the Events. try { - BotWorker.createBot(BotVersion.DEV, "1.7.0"); + BotWorker.createBot(BotVersion.PUBLIC, "1.7.0"); instance.musicWorker = new MusicWorker(); instance.addEvents(); } catch (Exception ex) { diff --git a/src/main/java/de/presti/ree6/utils/data/ImageCreationUtility.java b/src/main/java/de/presti/ree6/utils/data/ImageCreationUtility.java index 9a827a8e1..f3f972187 100644 --- a/src/main/java/de/presti/ree6/utils/data/ImageCreationUtility.java +++ b/src/main/java/de/presti/ree6/utils/data/ImageCreationUtility.java @@ -52,13 +52,22 @@ public static byte[] createRankImage(UserLevel userLevel) throws IOException { graphics2D.setColor(Color.BLACK); graphics2D.fillRoundRect(0, 0, base.getWidth(), base.getHeight(), 10, 10); - // TODO find a way to allow unicode Names. - // Draw basic Information, such as the User Image, Username and the Experience Rect. graphics2D.drawImage(userImage, null, 25, 45); graphics2D.setColor(Color.WHITE); - graphics2D.setFont(new Font("Verdana", Font.PLAIN, 40)); - graphics2D.drawString(new String(user.getName().getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8), 200, 110); + Font verdana40Font = new Font("Verdana", Font.PLAIN, 40); + + String username = new String(user.getName().getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8); + + if (username.length() > 16) { + username = username.substring(0, 15); + } + + graphics2D.setFont(verdana40Font); + graphics2D.drawString(username, 200, 110); + graphics2D.setColor(Color.GRAY); + graphics2D.setFont(new Font("Verdana", Font.PLAIN, 20)); + graphics2D.drawString("#" + user.getDiscriminator(), 200 + graphics2D.getFontMetrics(verdana40Font).stringWidth(username) + 5, 110); graphics2D.fillRoundRect(200, 130, base.getWidth() - 300, 50, 50, 50); //region Experience