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
- 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 OPpass them in via the customId
additionally, if you do want to emit a custom event, use <Client>.emit()
right, kinda phrased that badly.
Is there a way to pass other objects along with the interaction event?
you can do that in your event handler
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
the execute() function's params will be the params the event fires with, which is an interaction and the additional params you passed in