Answer the question
In order to leave comments, you need to log in
How to combine several js files in a bot?
Please tell me what code can I run several others in a .js file?
Let's say I have several codes, the first one is for music, the second one is for messages, etc.
How to start them so that they work together?
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
I understand that you have several commands and you want to scatter them into files, the simplest solution is this:
Create a commands folder next to the index.js file (Well, or what file do you run there)
file commands/music.js
module.exports = (message) => {
// Код для музыкального файла
}
module.exports = (message) => {
// Код другой команды
}
const musicCommand = require('./commands/music.js');
const otherCommand = require('./commands/otherCommand.js');
client.on('message', msg => {
if (msg.content === 'music') {
musicCommand(msg);
}
if (msg.content === 'other') {
otherCommand(msg);
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question