aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/math.py
blob: 80a6de9a59d34dbe6d506c4ee758c30c582db5e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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))