Closed almostSouji closed 1 year ago
Do this in your index.js above eventsPath = ....
client.commands = new Collection(); const commandsPath = path.join(__dirname, 'commands'); const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) { const filePath = path.join(commandsPath, file); const command = require(filePath); client.commands.set(command.data.name, command); }
Tries to get from
Client#commands
https://github.com/discordjs/guide/blob/6bea5078bc76911f9600d0ef80448610a73b8f61/code-samples/creating-your-bot/event-handling/events/interactionCreate.js#L6
but never defines it:
https://github.com/discordjs/guide/blob/6bea5078bc76911f9600d0ef80448610a73b8f61/code-samples/creating-your-bot/event-handling/index.js#L6-L21
Resulting Code is supposed to be a working Code base to fall back to and compare against.