Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buttons being removed from other embeds #49

Closed
5 tasks done
ItsLewizzz opened this issue Aug 25, 2023 · 4 comments
Closed
5 tasks done

Buttons being removed from other embeds #49

ItsLewizzz opened this issue Aug 25, 2023 · 4 comments
Labels
planned Feature has been considered

Comments

@ItsLewizzz
Copy link

ItsLewizzz commented Aug 25, 2023

Checklist

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

  • Bot has the following permissions:
    • MESSAGE_ADD_REACTION
    • MESSAGE_EXT_EMOJI
    • MESSAGE_READ/WRITE
    • VIEW_CHANNEL
  • If using JDABuilder.createLight(), you added the following gateway intents:
    • GUILD_MESSAGES
    • GUILD_MESSAGE_REACTIONS
  • If using .setRemoveOnReact(true), you have the following permission:
    • MESSAGE_MANAGE
  • 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 5.0.0-beta.10
  • Pagination-Utils version 4.0.5b

Describe the bug

When I add an ActionRow to other embeds I have in my bot (that are not handled by Pagination-Utils), as soon as I react on any button the whole row is deleted. When the util was disabled my other embed buttons worked fine without being deleted.

To Reproduce

Steps to reproduce the behavior:

  1. Create external embed with buttons
  2. Interact with one of the buttons
  3. The whole action row will be deleted.

Expected behavior

Pagination Utils should not be handling other embed button listeners.

Screenshots

If applicable, add screenshots to help explain your problem.

With Pagination-Utils enabled on external embed with "buttons" that is handled by myself on my own listener.
image

With Pagination-Utils disabled (working fine, my buttons show and are usable):
image

Additional context

Add any other context about the problem here.

@ygimenez
Copy link
Owner

This happens because the library assumes all button handling will be done by itself (like with Pages.buttonize), I'll add a setting to make it ignore buttons not created through its methods on the next update.

Meanwhile, you can manually add the message to the events map through Pages.getHandler().addEvent(message, null), the second argument says non-null but it won't cause errors as it checks whether the consumer is null, just remember to manually remove the event afterwards, else it'll stay until you shutdown the bot (possibly causing a memory leak).

@ygimenez ygimenez added the planned Feature has been considered label Aug 25, 2023
@ItsLewizzz
Copy link
Author

Is there any ETA for this?

@ygimenez
Copy link
Owner

Sorry, I've been busy with some tasks at work, couldn't touch it yet, but I should be able to deal with it soon.

@ygimenez
Copy link
Owner

ygimenez commented Sep 18, 2023

I apologize for the confusion, the solution was already available (but in a different class) since version 4.0.0, but I forgot about it.

(Available in version 4.0.6)

To fix the issue you're having, simply change setOnRemove() in PaginatorBuilder to anything else (eg. an empty consumer). The default action is to remove the interactions from the message, changing it will allow you to do something else (or even leverage it as a way to get the events for your own handler).

var paginator = PaginatorBuilder.createPaginator(/* Your client */)
        ... // Other settings
        .setOnRemove(hook -> {}) // Setting it as an empty consumer will suffice, or your can use it for other things.
        .build()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
planned Feature has been considered
Projects
None yet
Development

No branches or pull requests

2 participants