From d00b70758aeaf1b5eab5019427991496fa5efdf1 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Thu, 29 Feb 2024 18:50:22 -0500 Subject: [PATCH] fix(pterodactyl): hopefully fixed tellraw error --- pterodactyl/pterodactyl.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pterodactyl/pterodactyl.py b/pterodactyl/pterodactyl.py index 89c4b01..e7107aa 100644 --- a/pterodactyl/pterodactyl.py +++ b/pterodactyl/pterodactyl.py @@ -146,6 +146,9 @@ class Pterodactyl(commands.Cog): else: self.logger.debug("Chat channel not set. Skipping sending chat message to Discord") + def get_tellraw_string(self, username: str, message: str): + return f'tellraw @a ["",{{"text":"{username} (DISCORD): ","color":"blue"}},{{"text":"{message}","color":"white"}}]' + def get_task(self): return self.bot.loop.create_task(self.establish_websocket_connection(), name="Pterodactyl Websocket Connection") @@ -167,7 +170,7 @@ class Pterodactyl(commands.Cog): channel = self.bot.get_channel(await self.config.console_channel()) if channel: await channel.send(f"Received chat message from {message.author.id}: {message.content[:1900]}") - msg = json.dumps({"event": "send command", "args": ['tellraw @a ["",{"text":"%s (DISCORD): ","color":"blue"},{"text":"%s","color":"white"}]', message.author.name, message.content]}) + msg = json.dumps({"event": "send command", "args": [self.get_tellraw_string(message.author.name, message.content)]}) self.logger.debug("Sending chat message to server:\n%s", msg) await self.websocket.send(msg)