bot errors after reboot command

Hello, this is the reboot command,
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('reboot')
        .setDescription('[!] Reboots the bot [!]')
        .setDefaultMemberPermissions(0), // Deny the command by default
    async execute(interaction) {
        // Check if the user running the command has the correct ID
        if (interaction.user.id !== '1071373709157351464') {
            return await interaction.reply({ content: 'Nice try bozo :3', ephemeral: true });
        }

        // If the user has the correct ID, restart the bot
        try {
            await interaction.reply('Restarting the bot...');
            delete require.cache[require.resolve('../index.js')];
            require('../index.js');
            await interaction.followUp('Bot restarted successfully!');
        } catch (error) {
            console.error(error);
            await interaction.followUp('An error occurred while restarting the bot.');
        }
    },
};

Now, when I run it, the bot returns an error that reads;
Error: Cannot find module '../index.js'
My file directory is attached.
Why does this happen? How can I fix it?
image.png
Was this page helpful?