Attempting to remake my bot the "Correct" way
I made my entire bot in one file, and I'm looking to recreate it and section off to folders in a layout like this.. (Image below)
I figured out how to export & import my commands. However, I'm getting issues where it's trying to parse the .js files themselves before loading them into my bot.js?
Is anyone aware how I can get around this "client is not defined" issue? My commands look like this.
& they are imported like this
10 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![email protected]
v20.14.0
Please ping me if anyone knows
Take a look at your logging util. You don't seem to have access to your client in that function, so the easiest way is to pass your client as another parameter of that function
could log not just retrieve that from bot.js?
im not informed on multi-file anything lol, for all my projects i end up working with 1 file for the most part
From an import? That's not ideal, you'd very likely be creating circular dependencies by importing your client instead of passing it as a parameter instead
Couldn't I just throw
Inside of the logging.js at the top?
No, because that's not your logged-in client, that's a separate client you're creating
Oh
@Mandi I would take a look at this guide
Especially at the command and event handling
It teaches what you’re looking for