Interface Button

  • All Superinterfaces:
    Component, SerializableData

    public interface Button
    extends Component
    Represents a Message Button.
    These buttons are located below the message in ActionRows.

    Each button has either a custom_id or URL attached. The id has to be provided by the user and can be used to identify the button in the ButtonClickEvent.

    Example Usage

     public class HelloBot extends ListenerAdapter {
       public void onSlashCommand(SlashCommandEvent event) {
           if (event.getName().equals("hello")) {
               event.reply("Click the button to say hello")
                     Button.primary("hello", "Click Me"), // Button with only a label
                     Button.success("emoji", Emoji.fromMarkdown("<:minn:245267426227388416>"))) // Button with only an emoji
           } else if (event.getName().equals("info")) {
               event.reply("Click the buttons for more info")
                   .addActionRow( // link buttons don't send events, they just open a link in the browser when clicked
             "", "GitHub")
                         .withEmoji(Emoji.fromMarkdown("<:github:849286315580719104>")), // Link Button with label and emoji
             "", "Javadocs")) // Link Button with only a label
       public void onButtonClick(ButtonClickEvent event) {
           if (event.getComponentId().equals("hello")) {
               event.reply("Hello :)").queue();
    To see what each button looks like here is an example cheatsheet:
    See Also:
    ReplyAction.addActionRow(Component...), ReplyAction.addActionRows(ActionRow...)