-1
I’m making a bot for Discord, there is a folder called Commands, I wonder what I call the files of this folder in my main file, bot.js and run them
-1
I’m making a bot for Discord, there is a folder called Commands, I wonder what I call the files of this folder in my main file, bot.js and run them
1
meu-app
|--bot.js // Arquivo principal
|--commands // Pasta com os comandos que serão executados no arquivo bot.js
|--index.js
// commands/index.js
module.exports = function check() {
return "Estou sendo executado de dentro da pasta commands."
}
Since the bot.js file and the Commands folder are at the same directory level, to call the index.js file that is inside the Commands folder, in the bot.js file use the require command to call the files from the Commands folder.
// bot.js
const check = require('./commands');
console.log(check());
// Estou sendo executado de dentro da pasta commands.
Browser other questions tagged javascript node.js
You are not signed in. Login or sign up in order to post.
I didn’t even come to this post, I didn’t understand his answer
– Pythinho