I am currently working on a discord bot using discord.py. One of the functions is starting up a minecraft server. The code for the function is as follows:
@commands.command()
async def startmc(self, ctx):
await ctx.send("Server is starting")
os.system("java -jar -Xmx2048M -Xms2048M /home/pi/Desktop/testbot/server.jar
await ctx.send("Server has started")
As you can see this is supposed to work on my raspberry pi. As soon as the server finishes starting, my bot goes offline. If i manually close the server, the bot comes back online and sends the "Server has started" message. How do i get my bot to stay online? Thanks very much in advance.
Edit:
I have now switched to the subprocess module.
@commands.command()
async def startmc(self, ctx):
await ctx.send("Server is starting")
subprocess.call("cd /home/pi/Desktop/testbot", shell = True)
subprocess.call("java -jar -Xmx2048M -Xms2048M", shell = True)
await ctx.send("Server has started")
My problem is still the same. Am i using the wrong command?