Skip to content

Commit

Permalink
Updated the Command Interface
Browse files Browse the repository at this point in the history
Additionally, TODO comments were added to the `CommandHandler.java`
class.
  • Loading branch information
beanbeanjuice committed Oct 29, 2023
1 parent 4633f47 commit 0264beb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ public CommandHandler(@NotNull JDA jda) {
List<SubcommandData> subCommands = new ArrayList<>();

for (ISubCommand subCommand : command.getSubCommands()) {
// TODO: Check if subcommand is a modal.
SubcommandData subCommandData = new SubcommandData(subCommand.getName(), subCommand.getDescription());
subCommandData.addOptions(subCommand.getOptions());
subCommands.add(subCommandData);
Expand All @@ -195,7 +196,7 @@ public CommandHandler(@NotNull JDA jda) {
}

case MODAL -> {
// Do nothing.
// Do nothing. TODO: Remove this?
}
}

Expand Down
11 changes: 4 additions & 7 deletions src/main/java/com/beanbeanjuice/utility/command/ICommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ public interface ICommand {
*/
void handle(@NotNull SlashCommandInteractionEvent event);

default void handleModal(@NotNull ModalInteractionEvent event) {
return;
};
default void handleModal(@NotNull ModalInteractionEvent event) { }

/**
* @return The description for the {@link ICommand}.
Expand Down Expand Up @@ -72,11 +70,10 @@ default ArrayList<ISubCommand> getSubCommands() {
* @param event The {@link SlashCommandInteractionEvent event} that triggered the {@link ICommand}.
*/
default void runSubCommand(@NotNull String subCommandName, @NotNull SlashCommandInteractionEvent event) {
for (ISubCommand subCommand : getSubCommands()) {
if (subCommand.getName().equals(subCommandName)) {
getSubCommands().forEach((subCommand) -> {
if (subCommand.getName().equals(subCommandName))
subCommand.handle(event);
}
}
});
}

/**
Expand Down

0 comments on commit 0264beb

Please sign in to comment.