Hello everyone i've been trying to do a help command which lists all directories and their files. The problem is that i want to keep some of those directories/commands secretly. How to implement this Code into Embeds i do already know so i just wanna know how to make only some directories available to see. This is what i made so far: `
let categories = [];
fs.readdirSync("./commands/").forEach((dir) => {
const commands = fs.readdirSync(`./commands/${dir}/`).filter((file) =>
file.endsWith(".js")
);
const cmds = commands.map((command) => {
let file = require(`../../commands/${dir}/${command}`);
if (!file.name) return //"No command name.";
let name = file.name.replace(".js", "");
return `\`${name}\``;
});
let FileData = new Object();
FileData = {
name: dir.toUpperCase(),
value: cmds.length === 0 ? "In progress." : cmds.join(" "),
};
const InvalidDirs = [
'blaxyy-server',
'minecraft-server',
'owner-only'
]
categories.push(FileData)
});`
The commands and directory names should be then on the Embed but i want to keep the directories which are listed in InvalidDirs private so not everyone sees them.
Anybody knows how i could do it?
In each file that you want to keep secret, add a property like this
name: 'command name',
description: 'Command Description.',
secret: true,
Then check for it here
fs.readdirSync("./commands/").forEach((dir) => {
const commands = fs.readdirSync(`./commands/${dir}/`).filter((file) =>
file.endsWith(".js")
);
const cmds = commands.map((command) => {
let file = require(`../../commands/${dir}/${command}`);
if (file.secret) return; // this is the line that will check for the secret property
if (!file.name) return //"No command name.";
let name = file.name.replace(".js", "");
return `\`${name}\``;
});
let FileData = new Object();
FileData = {
name: dir.toUpperCase(),
value: cmds.length === 0 ? "In progress." : cmds.join(" "),
};
categories.push(FileData)
});