slash command getting messed up
so yeah same issue again the previous slash command aint getting deleted
heres deploy-commands.js
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();