Record Class Component

java.lang.Object
java.lang.Record
com.github.kaktushose.jda.commands.dispatching.reply.Component

public record Component(boolean enabled, boolean independent, String name) extends Record

Represents a component, namely Button, StringSelectMenu or EntitySelectMenu, that should be added to a reply.

Also holds the following two settings:

  • enabled:

to enable or disable the component

  • independent:

whether the component should be executed in the same Runtime as the command it is bound to or not. If true, every component interaction will create a new Runtime. Furthermore, the component cannot expire and will always get executed, even after a bot restart.

Example:

@SlashCommand("example command")
public void onCommand(CommandEvent event) {
    event.with().components(Components.of(true, false, "onButton")).reply();
}
  • Constructor Summary

    Constructors
    Constructor
    Description
    Component(boolean enabled, boolean independent, String name)
    Creates an instance of a Component record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Component
    disabled(String component)
    Adds disabled, runtime-bound Components to the reply.
    boolean
    Returns the value of the enabled record component.
    static Component
    enabled(String component)
    Adds enabled, runtime-bound Components to the reply.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the independent record component.
    static Component
    independent(String component)
    Adds enabled, runtime-independent Components to the reply.
    Returns the value of the name record component.
    static Component
    of(boolean enabled, boolean independent, String component)
    Adds Components with the passed configuration to the reply.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Component

      public Component(boolean enabled, boolean independent, String name)
      Creates an instance of a Component record class.
      Parameters:
      enabled - the value for the enabled record component
      independent - the value for the independent record component
      name - the value for the name record component
  • Method Details

    • enabled

      public static Component enabled(String component)
      Adds enabled, runtime-bound Components to the reply.
      Parameters:
      component - the name of the method that represents the component
    • disabled

      public static Component disabled(String component)
      Adds disabled, runtime-bound Components to the reply.
      Parameters:
      component - the name of the method that represents the component
    • independent

      public static Component independent(String component)

      Adds enabled, runtime-independent Components to the reply.

      Every component interaction will create a new Runtime. Furthermore, the component cannot expire and will always get executed, even after a bot restart.

      Parameters:
      component - the name of the method that represents the component
    • of

      public static Component of(boolean enabled, boolean independent, String component)
      Adds Components with the passed configuration to the reply.
      Parameters:
      enabled - whether the Component should be enabled or disabled
      independent - whether the Component should be runtime-bound or independent
      component - the name of the method that represents the component
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • enabled

      public boolean enabled()
      Returns the value of the enabled record component.
      Returns:
      the value of the enabled record component
    • independent

      public boolean independent()
      Returns the value of the independent record component.
      Returns:
      the value of the independent record component
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component