Skip to content

Commit

Permalink
Handle channel ID error in CommunityMessageCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
randomnetcat committed Nov 19, 2023
1 parent 9a8c8b4 commit f283b38
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ class CommunityMessageCommand(
.permissions(globalCommandPermission(PERMISSION_ACTION_CREATE)) cmd@{ (name, targetChannelId) ->
val guildStorage = globalStorage.storageForGuild(currentGuildId)

val targetChannel = currentGuild.getTextChannelById(targetChannelId)
val targetChannel = try {
currentGuild.getTextChannelById(targetChannelId)
} catch (e: Exception) {
respond("Unable to parse channel ID: $targetChannelId")
return@cmd
}

if (targetChannel == null) {
respond("Unable to find a channel with that id.")
Expand Down

0 comments on commit f283b38

Please sign in to comment.