aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/math.py
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-02-04 16:19:22 +0100
committersalmonik <raisersoft@proton.me>2026-02-04 16:19:22 +0100
commit72abc43db8f732743c65d6f6a820369ab8665766 (patch)
tree094fafdb0baf2e06a02045b1b2c0be88931a379a /cogs/math.py
parentrefactor music (diff)
downloadsenator-sperma-72abc43db8f732743c65d6f6a820369ab8665766.tar.gz
senator-sperma-72abc43db8f732743c65d6f6a820369ab8665766.zip
more asynchronous work and other minor improvements
Diffstat (limited to 'cogs/math.py')
-rw-r--r--cogs/math.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/cogs/math.py b/cogs/math.py
index 4bd62a0..bf164b3 100644
--- a/cogs/math.py
+++ b/cogs/math.py
@@ -4,7 +4,7 @@
4# https://codeberg.org/salmonik/senator-sperma 4# https://codeberg.org/salmonik/senator-sperma
5 5
6import logging 6import logging
7import subprocess 7import asyncio
8 8
9from discord import ApplicationContext 9from discord import ApplicationContext
10from discord.ext import commands 10from discord.ext import commands
@@ -22,8 +22,9 @@ class Math(commands.Cog):
22 ) 22 )
23 async def math(self, ctx: ApplicationContext, equation: str): 23 async def math(self, ctx: ApplicationContext, equation: str):
24 try: 24 try:
25 math = subprocess.check_output(f"qalc -e '{equation}'", shell=True) 25 math = await asyncio.create_subprocess_exec(f"qalc -e '{equation}'")
26 await ctx.respond(f"{equation} = {math.decode('utf-8').strip()}") 26 result = await math.wait()
27 await ctx.respond(f"{equation} = {result.decode('utf-8').strip()}")
27 logger.info(f"Math command executed: {equation}") 28 logger.info(f"Math command executed: {equation}")
28 except Exception as e: 29 except Exception as e:
29 await ctx.respond(e, ephemeral=True) 30 await ctx.respond(e, ephemeral=True)