From 48ca883423cc9a99857bc3410b90ac15d03346d7 Mon Sep 17 00:00:00 2001 From: Nayan <33187059+GShadow5@users.noreply.github.com> Date: Mon, 25 Aug 2025 20:59:48 -0400 Subject: [PATCH] pass discord chat to mc --- bot.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index f0aeee6..46b8d67 100644 --- a/bot.py +++ b/bot.py @@ -39,19 +39,20 @@ async def on_message(message): print(f'Message from {message.author}: {message.content}') if message.author == bot.user: return - if message.channel.name == chat_channel: + if message.channel.name == chat_channel and not message.content.startswith(command_prefix): if not active_server: await ("No server is currently active.") return await send_message(message) - await bot.process_commands(message) + if message.channel.name == command_channel and message.content.startswith(command_prefix): + await bot.process_commands(message) async def send_message(message): if not active_server: await message.channel.send("No server is currently active.") return minecraft_message = "[" + message.author.name + "] " + message.content - process = subprocess.Popen(f"screen -S {active_server} -p 0 -X stuff '{minecraft_message}'", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) + process = subprocess.Popen(f"screen -S {active_server} -p 0 -X stuff '{minecraft_message}\n'", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) stdout, stderr = process.communicate() '''