#slash command getting messed up

11 messages · Page 1 of 1 (latest)

distant wing
#

so yeah same issue again the previous slash command aint getting deleted
heres deploy-commands.js

const { REST, Routes } = require('discord.js');
const fs = require('node:fs');
const path = require('node:path');
const { clientId, token } = require('./config.json');

// Validate required configuration
if (!token || !clientId) {
    console.error('Missing bot token or clientId in config.json');
    process.exit(1);
}

const commands = [];
const commandsPath = path.join(__dirname, 'commands', 'utility');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));

// Load commands into an array for deployment
for (const file of commandFiles) {
    const filePath = path.join(commandsPath, file);
    const command = require(filePath);
    if ('data' in command && 'execute' in command) {
        commands.push(command.data.toJSON());
    } else {
        console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
    }
}

const rest = new REST({ version: '10' }).setToken(token);

// Function to override commands
const overrideCommands = async () => {
    try {
        console.log(`Started overriding ${commands.length} application (/) commands.`);
        
        // Override existing commands with the new set
        const data = await rest.put(
            Routes.applicationCommands(clientId),
            { body: commands }
        );
        
        console.log(`Successfully overrode ${data.length} application (/) commands.`);
    } catch (error) {
        console.error('Error overriding application commands:', error);
    }
};

// Execute the override
overrideCommands();```
toxic badgerBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by OP
zinc tendon
#

do you get any output

#

and did you refresh your discord client

distant wing
distant wing
#
  • the commands are duplicate in only one server
#

they are fine in another

swift nebulaBOT
#

If you have duplicate commands on your server, you registered both global and guild commands.

You can remove the duplicates by resetting either the global or guild commands

  • Resetting global commands: rest.put(Routes.applicationCommands(clientId), { body: [] })
  • Resetting guild commands: rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
distant wing
#

aight

#

aight fixed