ygimenez / Pagination-Utils

A collection of methods to make message pagination with JDA easier.
GNU Lesser General Public License v2.1
27 stars 7 forks source link

The first of two buttons does not work #16

Closed Nick-kel closed 3 years ago

Nick-kel commented 3 years ago

Checklist

Library info

Describe the bug If I add two bottuns in the success consumer of a message, the first button does not execute the consumer when reacting:

 Pages.buttonize(success, Collections.singletonMap("❌", deny), false, 120, TimeUnit.SECONDS);
 Pages.buttonize(success, Collections.singletonMap("✅", accept), false, 120, TimeUnit.SECONDS);

In this example, nothing happens when reacting with ❌. I also switched the order of the code lines and then the ✅ reaction didn't work.

ygimenez commented 3 years ago

That's because each message must have only one button listener attached to at any time. To use multiple buttons on buttonize method, use a normal Map instead of a singleton, like the example below:

Map<String, BiConsumer<Message, User>> buttons = new HashMap(){{
  put("❌", deny);
  put("✅", accept);
}};

Pages.buttonize(success, buttons, false, 120, TimeUnit.SECONDS);