Выдает ошибку при запуске кода
const Discord = require('discord.js'),
fs = require('fs'),
config = require('./config.json');
config.cfg.intents = new Discord.Intents(config.cfg.intents);
const bot = new Discord.Client(config.cfg);
bot.login(config.token);
require('./events')(bot);
bot.commands = new Discord.Collection();
const commandsFiles = fs.readdirSync('./commands');
for (const file of commandsFiles) {
const comand = require(`./commands/${file}`);
comand.names.forEach(element => {
bot.commands.set(element,comand);
});
}
console.log(bot.commands);
Ошибка
F:\dsbot\main.js:17
comand.names.forEach(element => {
^
TypeError: Cannot read properties of undefined (reading 'forEach')
at Object.<anonymous> (F:\dsbot\main.js:17:18)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47