Reputation: 41
Im using a discord.js bot to run a local .bat file, upon running the command, it runs the .bat file, but then it renders the bot useless as commands after that do absolutely nothing, no reply from the bot.
My understanding of it is that its "waiting" for the .bat script to finish before continuing to run other commands, how can I make it not wait until it finishes so commands/other functions still work?
This is my code so far:
const { SlashCommandBuilder } = require('@discordjs/builders');
const shell = require('shelljs');
module.exports = {
data: new SlashCommandBuilder()
.setName('start')
.setDescription('Starts the Minecraft server!'),
async execute(interaction) {
shell.cd('D:\\server\\creative_server')
shell.exec('D:\\server\\creative_server\\start.bat')
await interaction.reply('placeholder for embed');
},
};
Upvotes: 0
Views: 401
Reputation: 41
I looked into the node.js docs and found child_process.execFile()
Upvotes: 0