Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

147
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 
7 months 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

7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs