diff options
| author | SamlonDev <stankiewiczgracjan2019@gmail.com> | 2025-05-26 16:26:41 +0200 |
|---|---|---|
| committer | SamlonDev <stankiewiczgracjan2019@gmail.com> | 2025-05-26 16:26:41 +0200 |
| commit | d3f2293e49a8524fa48cf86736c9d5fb92dc39bd (patch) | |
| tree | 64f6a503847908148af843f2612ca13e392d9b77 /cogs/math.py | |
| parent | use python yt-dlp instead of shell (diff) | |
| download | senator-sperma-d3f2293e49a8524fa48cf86736c9d5fb92dc39bd.tar.gz senator-sperma-d3f2293e49a8524fa48cf86736c9d5fb92dc39bd.zip | |
add math using qalc
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 | ||
