Based on the information you gave me I think your just missing the commands
directory. In your code you are trying to read files in the commands
directory, but since it does not exist it throws the error.
I assume your project structure looks like this (bases on your comment)
/
node_modules/
main.js
package.json
If you are trying to read the files inside a directory called commands
from within the main.js
file, you need to actually create the directory first. So your structure should look like this
/
node_modules/
commands/
main.js
package.json
Then to read the files inside the commands directory you can try this
const path = require('path');
const fs = require('fs');
const files = fs.readdirSynch(path.resolve(__dirname, 'commands'));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…