aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/math.py
diff options
context:
space:
mode:
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)