Skip to content

Commit 10106bd

Browse files
Prevent users from setting voice channels as starboard
1 parent 9a186a4 commit 10106bd

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/main/java/technobot/commands/starboard/StarboardCommand.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,15 @@ public void execute(SlashCommandInteractionEvent event) {
5151
switch(event.getSubcommandName()) {
5252
case "create" -> {
5353
// Set starboard channel
54-
long channel = channelOption.getAsGuildChannel().getIdLong();
55-
starboardHandler.setChannel(channel);
56-
text = EmbedUtils.BLUE_TICK + " Set the starboard channel to <#" + channel + ">";
54+
try {
55+
long channel = channelOption.getAsTextChannel().getIdLong();
56+
starboardHandler.setChannel(channel);
57+
text = EmbedUtils.BLUE_TICK + " Set the starboard channel to <#" + channel + ">";
58+
} catch (NullPointerException e) {
59+
text = "You can only set a text channel as the starboard!";
60+
event.getHook().sendMessageEmbeds(EmbedUtils.createError(text)).queue();
61+
return;
62+
}
5763
}
5864
case "limit" -> {
5965
OptionMapping limitOption = event.getOption("stars");

0 commit comments

Comments
 (0)