From 3a315a0a28ced9dec16282ca931328052f537e4e Mon Sep 17 00:00:00 2001 From: xeals Date: Thu, 27 Apr 2023 11:31:39 +1000 Subject: [PATCH] add calculator help --- bot.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 422414b..f1195d9 100755 --- a/bot.py +++ b/bot.py @@ -72,7 +72,9 @@ class BotClient(discord.Client): return message.content.startswith("%") async def on_command(self, message: discord.Message): - match message.content.split(" "): + match re.split(" +", message.content): + case ["%calc?"], ["%calc", "?"]: + await message.reply(content=self._help_calculate()) case ["%calc", *args]: try: calc = await self._calculate(args) @@ -85,6 +87,14 @@ class BotClient(discord.Client): case _: _log.info(f"Unrecognised command {command}") + async def _help_calculate(self) -> str: + return """ + Run Showdown damage calculations. + Example format: + ` -2 8 SpA Choice Specs Torkoal Overheat vs. 252 HP / 4+ SpD Assault Vest Abomasnow in Sun through Light Screen` + Supported: attacker/defender boosts, EVs, item, species; attacker ability; weather/terrain; screens. + """ + async def _calculate(self, args: list[str]) -> str: proc = sp.run( ["node", "calc_main.js", "--"] + args, stdout=sp.PIPE, stderr=sp.PIPE