Skip to content

Commit 84e9a67

Browse files
committed
Clean up CommandFormatter
1 parent 7071563 commit 84e9a67

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

command/src/main/java/me/schlaubi/regnumutils/command/util/CommandFormatter.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public static EmbedBuilder formatCommand(
7373
} else {
7474
embed.addField("Type", "Command", true);
7575
}
76-
embed.addField("Usage", usageBase + command.getUsage(), false);
77-
if (!command.getExampleUsage().isEmpty() && !command.getExampleUsage().isBlank()) {
78-
embed.addField("Example Usage", usageBase + command.getExampleUsage(), false);
76+
embed.addField("Usage", usageBase + command.getUsage().trim(), false);
77+
if (isPresent(command.getExampleUsage())) {
78+
embed.addField("Example Usage", usageBase + command.getExampleUsage().trim(), false);
7979
}
8080

8181
if (command.hasSubCommands()) {
@@ -100,6 +100,10 @@ public static EmbedBuilder formatCommand(
100100
return embed;
101101
}
102102

103+
private static boolean isPresent(String usage) {
104+
return !usage.isEmpty() && !usage.isBlank();
105+
}
106+
103107
private static String formatUsageBase(CharSequence prefix, Command command) {
104108
final var buf = new StringBuilder(prefix);
105109
var currentCommand = command;

0 commit comments

Comments
 (0)