//code
const commandLocations =
[
'./commands/',
'./commands/help/',
'./commands/fun/',
'./commands/info/',
'./commands/tools/',
]
commandLocations.forEach(location => {
const commandFiles = fs.readdirSync(location).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`${location}${file}`);
Client.commands.set(command.name, command)
console.log('Message:' + command.name + ' was ' +'loaded'.green)
}
})
//error
C:\Users\imago\OneDrive\Documents\Desktop\Discord\Bots\idc bot someone wanted\index.js:36
Client.commands.set(command.name, command)
^
TypeError: Cannot read properties of undefined (reading 'set')
at C:\Users\imago\OneDrive\Documents\Desktop\Discord\Bots\idc bot someone wanted\index.js:36:25
at Array.forEach (<anonymous>)
at Object.<anonymous> (C:\Users\imago\OneDrive\Documents\Desktop\Discord\Bots\idc bot someone wanted\index.js:32:18)
at Module._compile (node:internal/modules/cjs/loader:1112:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
at Module.load (node:internal/modules/cjs/loader:988:32)
at Module._load (node:internal/modules/cjs/loader:834:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
Node.js v18.4.0