I'm working on a Discord bot using the popular Discord.js library
I've recently moved all my non config files to a folder called 'src'
In my 'index.js' file I have an fs statement that reads all the files in a directory called './src/handlers'
Here is that code:
fs.readdirSync(`./src/handlers`).forEach((handler) => {
require(`./src/handlers/${handler}`)(client)
});
Yes, I've imported the 'fs' module.
Here's my button.js code incase it has something to do with the error
(there are more files in the handlers folder, so it's not likely that button.js is giving me the error, it's probably that it's the one at the top of the list)
const fs = require('fs');
const chalk = require('chalk')
var AsciiTable = require('ascii-table')
var table = new AsciiTable()
table.setHeading('Buttons', 'Stats').setBorder('|', '=', "0", "0")
module.exports = (client) => {
fs.readdirSync('./src/buttons/').filter((file) => file.endsWith('.js')).forEach((file) => {
const button = require(`../buttons/${file}`)
client.buttons.set(button.id, button)
table.addRow(button.id, '✅')
})
console.log(chalk.cyanBright(table.toString()))
};