Buttons being removed from other embeds
ItsLewizzz opened this issue · 4 comments
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:
- Create external embed with buttons
- Interact with one of the buttons
- 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.
With Pagination-Utils disabled (working fine, my buttons show and are usable):
Additional context
Add any other context about the problem here.
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).
Is there any ETA for this?
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.
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()