Compare commits
No commits in common. "3a315a0a28ced9dec16282ca931328052f537e4e" and "cf3906be94d9c7ca5115d9f83ee82ae2285db7d5" have entirely different histories.
3a315a0a28
...
cf3906be94
14
bot.py
14
bot.py
@ -72,9 +72,7 @@ class BotClient(discord.Client):
|
||||
return message.content.startswith("%")
|
||||
|
||||
async def on_command(self, message: discord.Message):
|
||||
match re.split(" +", message.content):
|
||||
case ["%calc?"], ["%calc", "?"]:
|
||||
await message.reply(content=self._help_calculate())
|
||||
match message.content.split(" "):
|
||||
case ["%calc", *args]:
|
||||
try:
|
||||
calc = await self._calculate(args)
|
||||
@ -82,19 +80,11 @@ class BotClient(discord.Client):
|
||||
except Exception as e:
|
||||
_log.exception("running calculation")
|
||||
await message.reply(
|
||||
content="```\n" + str(e) + "\n```", delete_after=10
|
||||
content="```\n" + str(e) + "\n```", delete_after=30
|
||||
)
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user