Skip to content

Commit 7ce48b6

Browse files
committed
used requireNonNull for guild and included pattern in channel not found message
1 parent 94b6922 commit 7ce48b6

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

application/src/main/java/org/togetherjava/tjbot/features/leaderboard/LeaderboardCommand.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Comparator;
2222
import java.util.List;
2323
import java.util.Map;
24+
import java.util.Objects;
2425
import java.util.StringJoiner;
2526
import java.util.concurrent.CompletableFuture;
2627
import java.util.concurrent.ConcurrentHashMap;
@@ -54,13 +55,7 @@ public LeaderboardCommand(Config config) {
5455

5556
@Override
5657
public void onSlashCommand(SlashCommandInteractionEvent event) {
57-
Guild guild = event.getGuild();
58-
if (guild == null) {
59-
event.reply("This command can only be used inside a server.")
60-
.setEphemeral(true)
61-
.queue();
62-
return;
63-
}
58+
Guild guild = Objects.requireNonNull(event.getGuild());
6459

6560
event.deferReply().queue();
6661

@@ -73,7 +68,10 @@ public void onSlashCommand(SlashCommandInteractionEvent event) {
7368
.orElse(null);
7469

7570
if (hallOfFame == null) {
76-
event.getHook().editOriginal("Could not find the hall of fame channel.").queue();
71+
event.getHook()
72+
.editOriginal(
73+
"Could not find channel matching '%s'.".formatted(channelPattern.pattern()))
74+
.queue();
7775
return;
7876
}
7977

0 commit comments

Comments
 (0)