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.');
}
},
};
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?
No description
4 Replies
d.js toolkit
d.js toolkit11mo 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 staff
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
treble/luna
treble/luna11mo ago
working with the filesystem also isnt a djs issue
astro
astroOP11mo ago
got it, will post in #other-js-ts
Want results from more Discord servers?
Add your server