Update command reply

This commit is contained in:
Logan Cusano
2025-05-25 21:56:26 -04:00
parent 338704b6e8
commit ea53f5da3d

View File

@@ -135,7 +135,10 @@ async def leave_server(guild_id):
@command @command
async def get_status(websocket, request_id): async def get_status(websocket, request_id):
# Return the status object # Return the status object
await websocket.send({"type":"response", "request_id": request_id, "status": client_status}) response_payload = {"status": client_status} # It's good practice to wrap the actual data in a 'payload' key
# Corrected line: Convert the dictionary to a JSON string before sending
await websocket.send(json.dumps({"type":"response", "request_id": request_id, "payload": response_payload}))
@command @command
async def run_task(websocket, task_id, duration_seconds): async def run_task(websocket, task_id, duration_seconds):
@@ -168,7 +171,7 @@ async def receive_commands(websocket):
else: else:
print(f"Received unknown command: {command_name}") print(f"Received unknown command: {command_name}")
elif data.get("type") == "handshake_ack": elif data.get("type") == "handshake_ack":
print(f"Server acknowledged handshake.") print(f"Server acknowledged handshake.")
else: else:
print(f"Received unknown message type: {data.get('type')}") print(f"Received unknown message type: {data.get('type')}")