slash command getting messed up

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();
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();
6 Replies
d.js toolkit
d.js toolkit4mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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
treble/luna
treble/luna4mo ago
do you get any output and did you refresh your discord client
cloud
cloudOP4mo ago
No description
cloud
cloudOP4mo ago
yes i did + the commands are duplicate in only one server they are fine in another
d.js docs
d.js docs4mo ago
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: [] })
cloud
cloudOP4mo ago
aight aight fixed i just had to reset guild specific commands
Want results from more Discord servers?
Add your server