From d3f2293e49a8524fa48cf86736c9d5fb92dc39bd Mon Sep 17 00:00:00 2001 From: SamlonDev Date: Mon, 26 May 2025 16:26:41 +0200 Subject: add math using qalc --- cogs/math.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 cogs/math.py (limited to 'cogs') diff --git a/cogs/math.py b/cogs/math.py new file mode 100644 index 0000000..80a6de9 --- /dev/null +++ b/cogs/math.py @@ -0,0 +1,26 @@ +from base64 import decode +from codecs import utf_8_decode +import string +import discord +from discord import (ApplicationContext) +import subprocess + +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:string): + try: + math=subprocess.check_output(f"qalc -e {equation}", shell=True) + await ctx.respond(f"{equation} = {math.decode('utf-8').strip()}") + except Exception as e: + await ctx.respond(e, ephemeral=True) + print(e) + +def setup(bot): + bot.add_cog(Math(bot)) \ No newline at end of file -- cgit v1.2.3