add calculator help
This commit is contained in:
parent
fa96d88964
commit
53ece70381
12
bot.py
12
bot.py
@ -72,7 +72,9 @@ class BotClient(discord.Client):
|
|||||||
return message.content.startswith("%")
|
return message.content.startswith("%")
|
||||||
|
|
||||||
async def on_command(self, message: discord.Message):
|
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]:
|
case ["%calc", *args]:
|
||||||
try:
|
try:
|
||||||
calc = await self._calculate(args)
|
calc = await self._calculate(args)
|
||||||
@ -85,6 +87,14 @@ class BotClient(discord.Client):
|
|||||||
case _:
|
case _:
|
||||||
_log.info(f"Unrecognised command {command}")
|
_log.info(f"Unrecognised command {command}")
|
||||||
|
|
||||||
|
async def _help_calculate(self) -> str:
|
||||||
|
return """
|
||||||
|
Run Showdown damage calculations.
|
||||||
|
Example format:
|
||||||
|
` %calc -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:
|
async def _calculate(self, args: list[str]) -> str:
|
||||||
proc = sp.run(
|
proc = sp.run(
|
||||||
["node", "calc_main.js", "--"] + args, stdout=sp.PIPE, stderr=sp.PIPE
|
["node", "calc_main.js", "--"] + args, stdout=sp.PIPE, stderr=sp.PIPE
|
||||||
|
Loading…
Reference in New Issue
Block a user