From 72abc43db8f732743c65d6f6a820369ab8665766 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Feb 2026 16:19:22 +0100 Subject: more asynchronous work and other minor improvements --- cogs/math.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cogs/math.py') 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 @@ # https://codeberg.org/salmonik/senator-sperma import logging -import subprocess +import asyncio from discord import ApplicationContext from discord.ext import commands @@ -22,8 +22,9 @@ class Math(commands.Cog): ) async def math(self, ctx: ApplicationContext, equation: str): try: - math = subprocess.check_output(f"qalc -e '{equation}'", shell=True) - await ctx.respond(f"{equation} = {math.decode('utf-8').strip()}") + math = await asyncio.create_subprocess_exec(f"qalc -e '{equation}'") + result = await math.wait() + await ctx.respond(f"{equation} = {result.decode('utf-8').strip()}") logger.info(f"Math command executed: {equation}") except Exception as e: await ctx.respond(e, ephemeral=True) -- cgit v1.2.3