diff --git a/src/main/java/cc/fascinated/bat/command/impl/HelpCommand.java b/src/main/java/cc/fascinated/bat/command/impl/HelpCommand.java index 8524317..090e0b9 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/HelpCommand.java +++ b/src/main/java/cc/fascinated/bat/command/impl/HelpCommand.java @@ -44,7 +44,7 @@ public class HelpCommand extends BatCommand implements EventListener { public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { String categories = ""; for (Category category : Category.values()) { - long commandCount = commandService.getCommands().values().stream().filter(command -> command.getCategory() == category).count(); + long commandCount = commandService.getCommandsByCategory(category).size(); categories += "**%s** - %s Commands\n".formatted(category.getName(), commandCount); } @@ -76,9 +76,7 @@ public class HelpCommand extends BatCommand implements EventListener { } String commands = ""; - List categoryCommands = commandService.getCommands().values().stream() - .filter(command -> command.getCategory() == category) - .toList(); + List categoryCommands = commandService.getCommandsByCategory(category); if (categoryCommands.isEmpty()) { commands = "No commands available in this category."; } else { @@ -105,7 +103,7 @@ public class HelpCommand extends BatCommand implements EventListener { } event.editMessageEmbeds(EmbedUtils.genericEmbed() - .setDescription("The available commands in the **%s** category: \n\n%s".formatted(category.getName(), commands)) + .setDescription("There is %S commands in the **%s** category: \n\n%s".formatted(categoryCommands.size(), category.getName(), commands)) .build()).queue(); } } diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java index 52c2fe0..84da4a9 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java @@ -93,7 +93,7 @@ public class ScoreSaberCommand extends BatCommand { .addField("PP", NumberUtils.formatNumberCommas(account.getPp()), true) .addField("Joined", "".formatted(DateUtils.getDateFromString(account.getFirstSeen()).toInstant().toEpochMilli() / 1000), true) .setTimestamp(LocalDateTime.now()) - .setFooter(fetchTime > 3 ? "Fetched in %sms".formatted(fetchTime) : "Cached", null) + .setFooter(fetchTime > 3 ? "Fetched in %sms".formatted(fetchTime) : "Cached", "https://flagcdn.com/h120/%s.png".formatted(account.getCountry().toLowerCase())) .setColor(Colors.DEFAULT) .build()).queue(); } catch (RateLimitException ex) { diff --git a/src/main/java/cc/fascinated/bat/service/CommandService.java b/src/main/java/cc/fascinated/bat/service/CommandService.java index f4e0683..91ce62b 100644 --- a/src/main/java/cc/fascinated/bat/service/CommandService.java +++ b/src/main/java/cc/fascinated/bat/service/CommandService.java @@ -3,6 +3,7 @@ package cc.fascinated.bat.service; import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.BatCommandExecutor; import cc.fascinated.bat.command.BatSubCommand; +import cc.fascinated.bat.command.Category; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; @@ -98,6 +99,16 @@ public class CommandService extends ListenerAdapter { log.info("Registered all slash commands in {}ms", System.currentTimeMillis() - before); } + /** + * Gets commands that are in a specific category + * + * @param category The category + * @return The commands + */ + public List getCommandsByCategory(Category category) { + return commands.values().stream().filter(command -> command.getCategory() == category).toList(); + } + @Override public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) { Guild discordGuild = event.getGuild();