• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

220
Views
How to fix slash commands disappearing after one use

Hi I added slash commands for the first time in js and like after one use the commands disappear as shown in the video below

Video url

    
    // Slash Commands
    const slashCommands = await globPromise(
        `${process.cwd()}/SlashCommands/*/*.js`
    );

    const arrayOfSlashCommands = [];
    slashCommands.map((value) => {
        const file = require(value);
        if (!file?.name) return;
        client.slashCommands.set(file.name, file);

        if (["MESSAGE", "USER"].includes(file.type)) delete file.description;
        arrayOfSlashCommands.push(file);
    });
    client.on("ready", async () => {
        // Register for a single guild
        await client.guilds.cache
            .get("900379296407896075")
            .commands.set(arrayOfSlashCommands);
      console.log('[Slash cmds] commands were loaded')

        // Register for all the guilds the bot is in
        // await client.application.commands.set(arrayOfSlashCommands);
    });```

slash command handler that I use 
about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to redeploy your bot making sure that you have selected bot and application.commands, then set the permissions and use the link at the bottom to re-invite your bot to the guild.

See picture below: discord.dev

about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error