Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/root' into root
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed Aug 17, 2023
2 parents c00edf9 + 0e0dbb2 commit 671c37d
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,21 @@ public abstract class SlashCommand<C : SlashCommandContext<*, A, M>, A : Argumen
throw InvalidCommandException(name, "No command action or subcommands/groups given.")
}

val subCommandWithSubCommand = if (parentCommand != null && subCommands.isNotEmpty()) {
this
} else {
subCommands.firstOrNull { it.subCommands.isNotEmpty() }
}

if (subCommandWithSubCommand != null) {
throw InvalidCommandException(
parentCommand?.name ?: name,

"Subcommand ${subCommandWithSubCommand.name} has its own subcommands, but subcommands may not be " +
"nested."
)
}

if (::body.isInitialized && !(groups.isEmpty() && subCommands.isEmpty())) {
throw InvalidCommandException(
name,
Expand Down

0 comments on commit 671c37d

Please sign in to comment.