New commands only appear after completely removing and re-adding bot from servers

This is my deploy-commands.js: const { REST, Routes } = require('discord.js'); const { clientId, token } = require('./config.json'); const fs = require('fs'); const path = require('path'); const commands = []; const loadCommands = (dir) => { const files = fs.readdirSync(dir); for (const file of files) { const filePath = path.join(dir, file); if (fs.statSync(filePath).isDirectory()) { console.log(Entering directory: ${filePath}); // Debugging info loadCommands(filePath); // Recursive call for subfolders } else if (file.endsWith('.js')) { console.log(Loading command: ${filePath}); // Debugging info const command = require(filePath); commands.push(command.data.toJSON()); } } }; const foldersPath = path.join(__dirname, 'commands'); loadCommands(foldersPath); const rest = new REST({ version: '10' }).setToken(token); (async () => { try { console.log('Started refreshing application (/) commands.'); // Register commands globally await rest.put( Routes.applicationCommands(clientId), { body: commands }, ); console.log('Successfully reloaded global application (/) commands.'); } catch (error) { console.error(error); } })(); Can anyone spot why this might stop commands from being added without kicking the bot out and then adding it back in?
3 Replies
d.js toolkit
d.js toolkit2mo 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/luna2mo ago
did you reload your discord client that works too
Justin
JustinOP2mo ago
yup i was being an idiot, maybe i should sleep more. thanks.
Want results from more Discord servers?
Add your server