Skip to content

Commit 5241942

Browse files
committed
Fix help command, links to source code properly again
1 parent 37775f8 commit 5241942

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

bot/src/main/java/ml/duncte123/skybot/commands/uncategorized/HelpCommand.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.Arrays;
3030
import java.util.List;
3131
import java.util.regex.Pattern;
32-
import java.util.stream.Collectors;
3332

3433
import static me.duncte123.botcommons.messaging.MessageUtils.sendEmbed;
3534
import static me.duncte123.botcommons.messaging.MessageUtils.sendMsg;
@@ -70,19 +69,20 @@ public void execute(@Nonnull CommandContext ctx) {
7069
sendHelp(ctx, HelpEmbeds.generateCommandEmbed(prefix, null));
7170
}
7271

73-
@SuppressWarnings("ConstantConditions")
7472
private boolean isCategory(String name) {
7573
try {
76-
final List<CommandCategory> categoryList = Arrays.stream(CommandCategory.values()).filter(it -> name
77-
.equalsIgnoreCase(it.getSearch())).collect(Collectors.toList());
74+
final List<CommandCategory> categoryList = Arrays.stream(CommandCategory.values())
75+
.filter(it -> name.equalsIgnoreCase(it.getSearch()))
76+
.toList();
7877

7978
if (!categoryList.isEmpty()) {
8079
return true;
8180
}
8281

83-
return CommandCategory.valueOf(name.toUpperCase()) != null;
84-
}
85-
catch (IllegalArgumentException ignored) {
82+
// throws exception if not found
83+
CommandCategory.valueOf(name.toUpperCase());
84+
return true;
85+
} catch (IllegalArgumentException ignored) {
8686
return false;
8787
}
8888
}
@@ -100,7 +100,7 @@ private void sendHelp(CommandContext ctx, EmbedBuilder embed) {
100100

101101
private void sendCommandHelp(CommandContext ctx, String toSearch, CommandManager manager, String prefix) {
102102

103-
final ICommand cmd = manager.getCommand(toSearch);
103+
final ICommand<CommandContext> cmd = manager.getCommand(toSearch);
104104

105105
if (cmd != null) {
106106
sendCommandHelpMessage(ctx, (Command) cmd, prefix, toSearch);
@@ -117,7 +117,7 @@ private void sendCommandHelpMessage(CommandContext ctx, Command cmd, String pref
117117
final boolean isKotlin = isKotlin(commandClass);
118118
final String extension = isKotlin ? ".kt" : ".java";
119119
final String type = isKotlin ? "kotlin" : "java";
120-
final String url = String.format("https://github.com/DuncteBot/SkyBot/blob/master/src/main/%s/%s%s", type, clsPath, extension);
120+
final String url = String.format("https://github.com/DuncteBot/SkyBot/blob/main/bot/src/main/%s/%s%s", type, clsPath, extension);
121121

122122
final EmbedBuilder builder = EmbedUtils
123123
.getDefaultEmbed()

bot/src/main/java/ml/duncte123/skybot/utils/HelpEmbeds.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static EmbedBuilder generateCommandEmbed(@Nonnull String prefix, @Nullabl
6868
"Privacy policy: [duncte.bot/privacy](https://duncte.bot/privacy)", false);
6969
}
7070

71-
/// <editor-fold desc="Reflection magic" defaultstate="collapsed">
71+
/// <editor-fold desc="Init junk" defaultstate="collapsed">
7272
public static void init(final CommandManager manager) {
7373
final CommandCategory[] categories = CommandCategory.values();
7474

@@ -81,7 +81,7 @@ public static void init(final CommandManager manager) {
8181
final List<String> cmds = new ArrayList<>();
8282
final List<ICommand<CommandContext>> foundCommands = manager.getCommands(category);
8383

84-
for (final ICommand command : foundCommands) {
84+
for (final ICommand<?> command : foundCommands) {
8585
cmds.add(command.getName());
8686

8787
if (command.shouldDisplayAliasesInHelp()) {
@@ -150,9 +150,9 @@ private static MessageEmbed.Field getFieldForCategory(CommandCategory category)
150150
INLINE
151151
);
152152
}
153-
/// </editor-fold>
154153

155154
private static String joinCommands(List<String> cmdNames) {
156155
return "`" + String.join("` | `", cmdNames) + "`";
157156
}
157+
/// </editor-fold>
158158
}

0 commit comments

Comments
 (0)