Skip to content

Commit

Permalink
Add missing methods to get the actual component in HighLevelComponent…
Browse files Browse the repository at this point in the history
… and LowLevelComponent
  • Loading branch information
felldo committed Aug 15, 2021
1 parent 0c43d7e commit 9058ccc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
@@ -1,4 +1,16 @@
package org.javacord.api.entity.message.component;

public interface HighLevelComponent extends Component {
import org.javacord.api.util.Specializable;
import java.util.Optional;

public interface HighLevelComponent extends Component, Specializable<HighLevelComponent> {

default boolean isActionRow() {
return getType() == ComponentType.ACTION_ROW;
}

default Optional<ActionRow> asActionRow() {
return isActionRow() ? Optional.of((ActionRow) this) : Optional.empty();
}

}
@@ -1,4 +1,24 @@
package org.javacord.api.entity.message.component;

public interface LowLevelComponent extends Component {
import org.javacord.api.util.Specializable;
import java.util.Optional;

public interface LowLevelComponent extends Component, Specializable<LowLevelComponent> {

default boolean isButton() {
return getType() == ComponentType.BUTTON;
}

default Optional<Button> asButton() {
return isButton() ? Optional.of((Button) this) : Optional.empty();
}

default boolean isSelectMenu() {
return getType() == ComponentType.SELECT_MENU;
}

default Optional<SelectMenu> asSelectMenu() {
return isSelectMenu() ? Optional.of((SelectMenu) this) : Optional.empty();
}

}

0 comments on commit 9058ccc

Please sign in to comment.