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):