From c0053ca98912901b5d387d58fbc57f9b7da91f38 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 18 Mar 2026 15:29:51 +0100 Subject: voice doesn't work due to DAVE, but we got copyparty search --- cogs/math_commands.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 cogs/math_commands.py (limited to 'cogs/math_commands.py') diff --git a/cogs/math_commands.py b/cogs/math_commands.py new file mode 100644 index 0000000..bf164b3 --- /dev/null +++ b/cogs/math_commands.py @@ -0,0 +1,35 @@ +# This file is part of Senator Sperma +# Licensed under the GPL-3.0 License +# Copyright (C) 2026 Salmonik @ salmonik@tuta.io +# https://codeberg.org/salmonik/senator-sperma + +import logging +import asyncio + +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 = 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) + logger.error(f"Error in math command: {e}", exc_info=True) + + +def setup(bot): + bot.add_cog(Math(bot)) -- cgit v1.2.3