aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/math.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cogs/math.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/cogs/math.py b/cogs/math.py
index df2be4a..53340f2 100644
--- a/cogs/math.py
+++ b/cogs/math.py
@@ -1,23 +1,25 @@
1from discord.ext import commands
2import discord
3from discord import (ApplicationContext)
4import subprocess 1import subprocess
5 2
3from discord import (ApplicationContext)
4from discord.ext import commands
5
6
6class Math(commands.Cog): 7class Math(commands.Cog):
7 def __init__(self, bot): 8 def __init__(self, bot):
8 self.bot = bot 9 self.bot = bot
9 10
10 @commands.slash_command( 11 @commands.slash_command(
11 name="math", 12 name="math",
12 description="wrug szyskih matfisuf" 13 description="wrug szyskih matfisuf"
13 ) 14 )
14 async def math(self, ctx:ApplicationContext, equation:str): 15 async def math(self, ctx: ApplicationContext, equation: str):
15 try: 16 try:
16 math=subprocess.check_output(f"qalc -e {equation}", shell=True) 17 math = subprocess.check_output(f"qalc -e {equation}", shell=True)
17 await ctx.respond(f"{equation} = {math.decode('utf-8').strip()}") 18 await ctx.respond(f"{equation} = {math.decode('utf-8').strip()}")
18 except Exception as e: 19 except Exception as e:
19 await ctx.respond(e, ephemeral=True) 20 await ctx.respond(e, ephemeral=True)
20 print(e) 21 print(e)
21 22
23
22def setup(bot): 24def setup(bot):
23 bot.add_cog(Math(bot)) \ No newline at end of file 25 bot.add_cog(Math(bot))