From 4b07aeb10c4efe0059c64c4984b30dc8a6f8a0ae Mon Sep 17 00:00:00 2001 From: xeals Date: Wed, 26 Apr 2023 17:19:36 +1000 Subject: [PATCH] fix formatting --- bot.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bot.py b/bot.py index 6f84e52..68cc4ed 100755 --- a/bot.py +++ b/bot.py @@ -74,9 +74,11 @@ class BotClient(discord.Client): async def on_command(self, message: discord.Message): match message.content.split(" "): case ["%calc", *args]: - reply = await self._calculate(args) - if reply: - await message.reply(content=reply.strip()) + try: + calc = await self._calculate(args) + await message.reply(content=calc.strip()) + except Exception as e: + await message.reply(content="```\n" + str(e) + "\n```") case _: _log.info(f"Unrecognised command {command}") @@ -86,7 +88,7 @@ class BotClient(discord.Client): ) if proc.returncode != 0: _log.error(f"running calculator: {proc.stderr}") - return proc.stdout + return proc.stdout.decode() def is_replay(self, message: discord.Message) -> bool: if re.match("https://replay.pokemonshowdown.com/dl-.*", message.content):