#require(. . .) is not a function
9 messages · Page 1 of 1 (latest)
are you exporting a function?
it happens
but i got another error now
this is the handleComponents:
const { readdirSync } = require("fs");
module.exports = (client) => {
client.handleComponents = async () => {
const componentFolders = readdirSync(`./src/components`);
for (const folder of componentFolders) {
const componentFiles = readdirSync(`./src/components/${folder}`).filter(
(file) => file.endsWith(".js")
);
}
const { buttons } = client;
switch (folder) {
case "buttons":
for (const file of componentFiles) {
const button = require(`../../components/${folder}/${file}`);
buttons.set(button.data.name, button);
}
break;
default:
break;
}
};
};
says this:
switch (folder) {
^
ReferenceError: folder is not defined