From 811e2cc7414eb78bb2bf964f986846f1f35e8748 Mon Sep 17 00:00:00 2001 From: Samlon Date: Wed, 20 Aug 2025 20:11:34 +0200 Subject: improved downloader.py --- cogs/math_cog.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 cogs/math_cog.py (limited to 'cogs/math_cog.py') diff --git a/cogs/math_cog.py b/cogs/math_cog.py new file mode 100644 index 0000000..8a2644c --- /dev/null +++ b/cogs/math_cog.py @@ -0,0 +1,29 @@ +import logging +import subprocess + +from discord import ApplicationContext +from discord.ext import commands + +logger = logging.getLogger(__name__) + + +class Math(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.slash_command( + name="math", + description="wrug szyskih matfisuf" + ) + 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()}") + logger.info(f"Math command executed: {equation}") + except Exception as e: + await ctx.respond(e, ephemeral=True) + logger.error(f"Error in math command: {e}", exc_info=True) + + +def setup(bot): + bot.add_cog(Math(bot)) -- cgit v1.2.3