Emit custom event on button press?

As title says, I was wondering if or how you can emit a custom event when hitting a button. Else it'd be interesting how you could pass additional arguments to the event emitted by a button.
6 Replies
d.js toolkit
d.js toolkit13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
treble/luna
treble/luna13mo ago
pass them in via the customId additionally, if you do want to emit a custom event, use <Client>.emit()
LordFalke
LordFalkeOP13mo ago
right, kinda phrased that badly. Is there a way to pass other objects along with the interaction event?
treble/luna
treble/luna13mo ago
you can do that in your event handler
LordFalke
LordFalkeOP13mo ago
yeah figured that out just as you typed it lol. any recommendation of how I could embed this into my existing event handler (I'm just using the one shown in the guide)? Right now I've just created another listener in the class where the event is triggered. Else I'm just gonna make it so my handler doesn't act on that one customid
treble/luna
treble/luna13mo ago
the execute() function's params will be the params the event fires with, which is an interaction and the additional params you passed in
Want results from more Discord servers?
Add your server