Więc tak robię bota do discorda w NodeJS i nie mogę przypomnieć sobie jak robiło się wiadomości o nie prawidłowej komendzie komendy są w Command Handler. Próbowałem else i else if ale nie działa
fs.readdir('./commands/', (err, files) => {
if(err) console.error(err);
let cmds = files.filter(f => f.split('.').pop() === 'js');
if(cmds.lenght <= 0) {
return console.log('Nie znaleziono żadnych komend');
}
if(cmds.lenght <= 0){
console.log(`Ładowanie ${files.lenght} komend...`);
};
cmds.forEach((f, i) => {
const command = require(`./commands/${f}`);
console.log(`${i + 1}: ${f} załadowane!`);
client.commands.set(command.help.name, command);
});
});
client.on('message', (message) => {
const prefix = config.prefix
const messageArray = message.content.split(/\s+/g);
const command = messageArray[0];
const args = messageArray.slice(1);
let cmd = client.commands.get(command.slice(prefix.length));
if(command.startsWith(prefix)){
if(cmd) cmd.run(client, message, args);
console.log(`KBOTQ: ${message.author.username}#${message.author.discriminator} used command '${command}' on ${message.guild.name}`); // We can log it to console
}
});
