#Need to catch the button event

1 messages · Page 1 of 1 (latest)

hidden venture
#

I attached a button to a text message, i was hoping to catch that event so that i can trigger an action based on event. Im not sure if this is the right way to do it, but this is what i did based on other implementations in TJ's code.

formal spruceBOT
#

<@&987246924425994290> please have a look, thanks.

formal spruceBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

hidden venture
glossy mural
#

implement the UserInteractor interface instead

#

there are a hand full of examples in the code base as well

hidden venture
#

ah oki, i just searched for onButtonClick and found this one😅

glossy mural
#

and it has to be the class who also created the button

hidden venture
#

oki so in same class

glossy mural
#

the magic wiring is in the ID that u attach to the button when u create it

#

which contains the name of the class

#

generateComponentId() or whatever it was called

#

so when the button is clicked, our code searches for the class with that name and forwards it to there

glossy mural
hidden venture
#

HelpSystemHelper

glossy mural
#

well

#

that won't work then

#

its a helper. it's not supposed to create and handle buttons

#

only to offer some slim static helper methods

hidden venture
#

rip

#

i was able to create a button tho, i was trynna find a way to handle that interaction

glossy mural
#

u can't. ull never receive the event

hidden venture
#

any other alternatives to that?

#

oh

#

no wonder it says interaction failed.

glossy mural
#

how were u even able to create a button with a component id

#

if ur not a userinteractor, u don't have the generate method

hidden venture
#

last couple of lines

glossy mural
#

ah. u added a selfmade id

#

well yeah. that ain't work at all

#

that's not how our system works

hidden venture
#

ah i looked up a quick example from jda docs😅

glossy mural
#

the event when clicked reaches our bot and it fails to parse it and forward it

#

yes we have a custom system

#

u should consult our wiki instead

hidden venture
#

alr

#

ill look it up

glossy mural
#

but that button stuff can't happen in the helper

#

perhaps that entire code is becoming already too big for a helper

#

and should be moved

hidden venture
#

prolly it does seem like a bit too much

glossy mural
#

yeah. sorry

hidden venture
#

no i meant the helper file seems a bit large, so you might be right about "too big for helper" thingy

glossy mural
#

indeed

hidden venture
#

this seems a bit more than i can chew atm😅

#

appreciate the help anyway, hopefully ill pick up something like this in future.