other arguments than `client` is not being passed to event handler
I am scaffolding code for my bot based of this guide: https://discordjs.guide/creating-your-bot/event-handling.html#reading-event-files
But when any events other than
ready
(which requires 2 or more arguments passed) are invoked, it crashes with the following error:
I suspect that when interactionCreate
is called (when I invoke a slash command, for example), interaction
is not passed to the event file.
Sample code
index.ts
(the part where I register events)
events/interactionCreate.js
Yes I know it's not a good idea mixing ES5 and ESM, but I don't know does discord.js
support it fully (I just returned from a year hiatus), the guide website still have references using ES5...
Any help would be appreciated.discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
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 OPNo event, except for the ready event emits with a client
you either should remove the client parameter, as virtually all djs structures have a client property, or pass it in in your event handler
alright, I will try removing the
client
parameter..
@wolvinny 🌈 it works! thank you so much..
by the way, is my current code structure (main file is typescript-based, events and commands are still ES5-based) okay, should I change it or keep it that way?djs is fully compatible with typescript so it should work
alr.. thank you so much for answering my questions
hope you a good day sir