I thought the script stopped because the loop was running constantly and thus blocked the rest of the script, but turns out the script starts running again when the loop cycles. this is the code:
@client.command()
async def start(ctx):
global process
if process == None:
await ctx.send("yessssssir")
os.chdir(minecraft_dir)
process = subprocess.Popen(executable,stdin=PIPE,stdout=PIPE, text=True)
for line in process.stdout:
await ctx.send(line)
@client.event
async def on_message(message):
global process
if message.author.id != client.user.id and message.channel.name == "mc-server-console" and message.content and process != None:
command = message.content
command = command.lower()
if command == "stop":
process = None
command = command + "\n"
cmd = command.encode()
process.stdin.write(command)
process.stdin.flush()
await client.process_commands(message)
can someone explain? to be perfectly honest I don't understand how this makes sense