Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
How can i make my Bot show only some directories from my Commands

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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)
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!