Problem with rest module

So i asked in #djs-help-v14 a few time about my deploy command not working, especially all lines after the rest.put. Since i put this code in my ready event, everyone and me thought that i was rate limit. But the night after someone said that to me, it worked again. then, i removed the code from my ready event, changed the way to execute it so i executed it only 1 time, continued to work on my bot, and when i added a new command and executed my deploy command, it didn't work. I thought it was rate limit again because the var "response = rest.put(..." was empty. But i just found about client.rest.on("response", console.log) and i saw that i was not rate limit. So i'm asking here for help

deploy_command.js:
function deploy_commands(){


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


    const commands = [];
    // Grab all the command folders from the commands directory you created earlier
    const foldersPath = path.join(__dirname, 'commands');
    const commandFolders = fs.readdirSync(foldersPath);

    for (const folder of commandFolders) {
        // Grab all the command files from the commands directory you created earlier
        const commandsPath = path.join(foldersPath, folder);
        const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js') || file.endsWith('.mjs'));
        // Grab the SlashCommandBuilder#toJSON() output of each command's data 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.`);
            }
        }
    }

    // Construct and prepare an instance of the REST module
    const rest = new REST().setToken(token);


    

    // and deploy your commands!
    (async () => {
        try {
            console.log(`Started refreshing ${commands.length} application (/) commands. TEST`);

            // The put method is used to fully refresh all commands in the guild with the current set
            const data = await rest.put(
                Routes.applicationGuildCommands(clientId, guildId),
                { body: commands },
            ).then(async () => {
                console.log(`THEN THEN THEN Successfully reloaded ${data.length} application (/) commands.`)
            }).catch((err) => {
                console.error(err)
            });
            
            
            
            console.log("TEST TEST TEST")

            console.log(`Successfully reloaded ${data.length} application (/) commands.`);
        } catch (error) {
            // And of course, make sure you catch and log any errors!
            console.error(error);
        }
    })();
}




module.exports = deploy_commands
// deploy_commands()



one of the 10 000000 rest reponse:
{
  method: 'PUT',
  path: '/channels/1260958647878422529/permissions/1260738030206189660',
  route: '/channels/:id/permissions/:id',
  options: {
    body: '{"id":"1260738030206189660","type":0,"allow":"0","deny":"2048"}',
    headers: {
      'Content-Type': 'application/json',
      'User-Agent': 'DiscordBot (https://discord.js.org, 2.3.0) discord.js/14.15.3 Node.js/18.17.0',
      Authorization: 'Bot xxxxxxxxxx'
    },
    method: 'PUT',
    dispatcher: undefined
  },
  data: {
    body: {
      id: '1260738030206189660',
      type: 0,
      allow: [PermissionsBitField],
      deny: [PermissionsBitField]
    },
    files: undefined,
    auth: true,
    signal: undefined
  },
  retries: 0
}
Was this page helpful?