Skip to content

Listening to buttons

Jasper edited this page Aug 21, 2022 · 1 revision

Buttons are not going to listen to themselves.

Pre-made listeners

The library comes with a pre-made listener for the buttons, you can use it by adding it to your respective library builder.

E.g., the JDA listener is the JDABookButtonListener, you can add it as you would do with any other listener.

builder.addEventListeners(new JDABookButtonListener());

Alternatively, you can create your own listener, if you wish to change the behavior.

Extra listeners

Keep in mind, the aforementioned listener only triggers if the button ID starts with book:, you should be clear to create your own listeners as long as you filter out button interactions starting with book:.

If you don't filter out those interactions, you'll be interacting with the button twice, which is not possible.