Skip to content

Commit 92bfae9

Browse files
Prevent users from setting voice channels as suggestion board
1 parent 10106bd commit 92bfae9

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/main/java/technobot/commands/suggestions/SuggestionsCommand.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,16 @@ public void execute(SlashCommandInteractionEvent event) {
6666
text = EmbedUtils.BLUE_TICK + " Created a new suggestion channel!";
6767
} else {
6868
// Set suggestion board to mentioned channel
69-
long channel = channelOption.getAsGuildChannel().getIdLong();
70-
String channelMention = "<#" + channel + ">";
71-
suggestionHandler.setChannel(channel);
72-
text = EmbedUtils.BLUE_TICK + " Set the suggestion channel to " + channelMention;
69+
try {
70+
long channel = channelOption.getAsTextChannel().getIdLong();
71+
String channelMention = "<#" + channel + ">";
72+
suggestionHandler.setChannel(channel);
73+
text = EmbedUtils.BLUE_TICK + " Set the suggestion channel to " + channelMention;
74+
} catch (NullPointerException e) {
75+
text = "You can only set a text channel as the suggestion board!";
76+
event.getHook().sendMessageEmbeds(EmbedUtils.createError(text)).queue();
77+
return;
78+
}
7379
}
7480
}
7581
case "dm" -> {

0 commit comments

Comments
 (0)