fix formatting

This commit is contained in:
xeals 2023-04-26 17:19:36 +10:00
parent 699a833285
commit 4b07aeb10c
Signed by: xeals
GPG Key ID: A498C7AF27EC6B5C

10
bot.py
View File

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