Annotation Interface Button


@Target(METHOD) @Retention(RUNTIME) public @interface Button

Methods annotated with Button will be registered as a button at startup.

Therefore, the method must be declared inside a class that is annotated with Interaction. Furthermore, the method signature has to meet the following conditions:

You can reply with a button by calling MessageReply.components(Component...).

Example:

@Button(value = "Press me", style = ButtonStyle.DANGER)
public void onButton(ComponentEvent event) { ... }
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Gets the Emoji of the button.
    Gets the link of the button.
    net.dv8tion.jda.api.components.buttons.ButtonStyle
    Gets the ButtonStyle.
    int
    The uniqueId of this component.
    Gets the label of the button.
  • Element Details

    • value

      String value
      Gets the label of the button.
      Returns:
      the label of the button
      Default:
      ""
    • style

      net.dv8tion.jda.api.components.buttons.ButtonStyle style
      Gets the ButtonStyle.
      Returns:
      the ButtonStyle
      Default:
      PRIMARY
    • emoji

      String emoji
      Gets the Emoji of the button.
      Returns:
      the Emoji
      Default:
      ""
    • link

      String link
      Gets the link of the button.
      Returns:
      the link of the button
      Default:
      ""
    • uniqueId

      int uniqueId
      The uniqueId of this component. Must be greater than 0. Default value is -1 which will result in Discord auto assigning an id.
      Default:
      -1