Kord-Extensions/kord-extensions

Components setup function creates unnecessary listener when components only contains disabled buttons

Closed this issue · 5 comments

Summary

Disabled buttons are not actionable/clickable. When you send a message that only contains disabled buttons, the components setup function creates an unnecessary listener.

image

Preferred Behaviour

We should have a way of deciding whether we want to be able to listen for button events.

Suggestions

I've come up with two possible solutions to this problem. We could either;

  • have a parameter in the setup function that decides whether we want to listen for button events
  • when the setup function is called, we iterate through every button and check if any of them are actionable buttons. If so, we enable the listener.

I'm still thinking about this util, honestly. It works for sure, but I'm starting to wonder if it's a great approach. Can you think of a better way? Perhaps delegating event handling to a central class to cut down on handler spam?

Maybe we can have a central component registry similar to the MessageCommandRegistry and SlashCommandRegistry. The component registry would listen to interaction create events and check it against a map of interaction ids that we are currently listening to.

That's essentially what I had in mind, yeah - shouldn't be too complex to do.

Yeah it would probably be easier to create util functions for disabling buttons as well with this new approach

This has been solved with the latest snapshot commit.