ygimenez/Pagination-Utils

MessageAddReactionEvent Fires Twice Unconsistently / Pagination Skipping Pages Unintentionally

sgoudham opened this issue · 1 comments

Checklist

Make sure that you've checked all the items below.

  • Bot has the following permissions:
    • MESSAGE_MANAGE
    • MESSAGE_ADD_REACTION
    • MESSAGE_EXT_EMOJI
    • MESSAGE_READ/WRITE
    • VIEW_CHANNEL
  • PaginationUtils is up-to-date.
  • You have activated the library as descripted in the README.

Library info

What libraries versions are you using?

  • JDA version 4.2.0_221
  • PaginationUtils version 1.3.0

Describe the bug

  • The MessageReactionAddEvent seems to be firing twice consistently after the first time of any pagination being used in a command.
  • The first time that pagination is used, it will work fine and only skip 1 page with the forward and back arrows. However, with any other commands after that (Doesn't matter if in different channel or server) it will seem to fire the event twice and hence skip 2 pages with one reaction of forward and back arrows.

To Reproduce

Steps to reproduce the behaviour:

    1. Boot up an instance of the bot
    1. Execute command that makes use of .paginate() with MessageEmbeds
    1. Observe reactions working correctly
    1. Execute command again that makes use of paginate() with MessageEmbeds
    1. See unexpected behaviour with clicking reactions as pages will have been skipped (By 2 each time)

Expected behaviour

  • I expect that the page increments and decrements by 1 consistently to ensure that no pages are skipped unintentionally

Screenshots

  • Streamable Video Link For Demonstration: Click here

Additional context

  • I was passing an arraylist of pages that included MessageEmbeds. I was locally hosting the bot to test this.

Analyzing the video, looks like you're activating the library during command handling, that's probably the reason why it's doubling on-click events.

I'll add an exception to be thrown whenever you try to use Pages.activate() with a handler already set.
Please put the activation method inside the initialization part of the code, if the problem persists please reopen this issue.