diff options
Diffstat (limited to 'cogs/math.py')
| -rw-r--r-- | cogs/math.py | 26 |
1 files changed, 26 insertions, 0 deletions
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 @@ | |||
| 1 | from base64 import decode | ||
| 2 | from codecs import utf_8_decode | ||
| 3 | import string | ||
| 4 | import discord | ||
| 5 | from discord import (ApplicationContext) | ||
| 6 | import subprocess | ||
| 7 | |||
| 8 | class Math(commands.Cog): | ||
| 9 | def __init__(self, bot): | ||
| 10 | self.bot = bot | ||
| 11 | |||
| 12 | @commands.slash_command( | ||
| 13 | name="Math", | ||
| 14 | description="wrug szyskih matfisuf", | ||
| 15 | |||
| 16 | ) | ||
| 17 | async def math(self, ctx:ApplicationContext, equation:string): | ||
| 18 | try: | ||
| 19 | math=subprocess.check_output(f"qalc -e {equation}", shell=True) | ||
| 20 | await ctx.respond(f"{equation} = {math.decode('utf-8').strip()}") | ||
| 21 | except Exception as e: | ||
| 22 | await ctx.respond(e, ephemeral=True) | ||
| 23 | print(e) | ||
| 24 | |||
| 25 | def setup(bot): | ||
| 26 | bot.add_cog(Math(bot)) \ No newline at end of file | ||
