Import all commands from folder with ES modules
So my previous bot I build I used CommonJS and did the commands like this:
But now I really prefer to work with ES modules also because they are by default async.
But now I have been thinking about a way to import all commands from the folder. But it doesn't work that easy with
import
.
Anyone know a good way to do this.
Because the export where build like
10 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.
import like this just wont work or am I just doing something wrong. But can't an import just be used at the beginning ?
Isnt it import commandSlash from path?
yes but
Replacing path with your path ofc
Ohh
I see
Maybe you could make your own import function
In a different file
If only you could just import a folder... 😦 but I just read in the nodejs docs its not possible
doesnt even work in ES6 😦
My apologies I saw it wrong i get what you are saying now thank you.
Sorry
Thank you @qjuh
How I have it now and working
Again my apologies.