diff options
Diffstat (limited to '')
| -rw-r--r-- | cogs/math.py | 11 | ||||
| -rw-r--r-- | cogs/vc_logs.py | 29 |
2 files changed, 32 insertions, 8 deletions
diff --git a/cogs/math.py b/cogs/math.py index 80a6de9..df2be4a 100644 --- a/cogs/math.py +++ b/cogs/math.py | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | from base64 import decode | 1 | from discord.ext import commands |
| 2 | from codecs import utf_8_decode | ||
| 3 | import string | ||
| 4 | import discord | 2 | import discord |
| 5 | from discord import (ApplicationContext) | 3 | from discord import (ApplicationContext) |
| 6 | import subprocess | 4 | import subprocess |
| @@ -10,11 +8,10 @@ class Math(commands.Cog): | |||
| 10 | self.bot = bot | 8 | self.bot = bot |
| 11 | 9 | ||
| 12 | @commands.slash_command( | 10 | @commands.slash_command( |
| 13 | name="Math", | 11 | name="math", |
| 14 | description="wrug szyskih matfisuf", | 12 | description="wrug szyskih matfisuf" |
| 15 | |||
| 16 | ) | 13 | ) |
| 17 | async def math(self, ctx:ApplicationContext, equation:string): | 14 | async def math(self, ctx:ApplicationContext, equation:str): |
| 18 | try: | 15 | try: |
| 19 | math=subprocess.check_output(f"qalc -e {equation}", shell=True) | 16 | math=subprocess.check_output(f"qalc -e {equation}", shell=True) |
| 20 | await ctx.respond(f"{equation} = {math.decode('utf-8').strip()}") | 17 | await ctx.respond(f"{equation} = {math.decode('utf-8').strip()}") |
diff --git a/cogs/vc_logs.py b/cogs/vc_logs.py index 669be3b..e4a8454 100644 --- a/cogs/vc_logs.py +++ b/cogs/vc_logs.py | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | |||
| 1 | import discord | 2 | import discord |
| 2 | from discord.ext import commands | 3 | from discord.ext import commands |
| 3 | import datetime | 4 | import datetime |
| 4 | from gtts import gTTS | 5 | from gtts import gTTS |
| 5 | import os | 6 | import os |
| 7 | import json | ||
| 6 | 8 | ||
| 7 | class vc_logs(commands.Cog): | 9 | class vc_logs(commands.Cog): |
| 8 | def __init__(self, bot): | 10 | def __init__(self, bot): |
| @@ -22,12 +24,37 @@ class vc_logs(commands.Cog): | |||
| 22 | 24 | ||
| 23 | # Play the TTS audio | 25 | # Play the TTS audio |
| 24 | if not voice_client.is_playing(): | 26 | if not voice_client.is_playing(): |
| 25 | audio_source = discord.FFmpegPCMAudio('temp_tts.mp3', options='-filter:a "volume=6"') | 27 | if os.path.exists('settings.json'): |
| 28 | with open('settings.json') as f: | ||
| 29 | data = json.load(f) | ||
| 30 | volume = data['volume'] | ||
| 31 | else: | ||
| 32 | with open('settings.json', 'w') as f: | ||
| 33 | json.dump({'volume': '5'}, f, indent=4) | ||
| 34 | |||
| 35 | audio_source = discord.FFmpegPCMAudio('temp_tts.mp3', options=f'-filter:a "volume={volume}"') | ||
| 26 | voice_client.play(audio_source) | 36 | voice_client.play(audio_source) |
| 27 | while voice_client.is_playing(): | 37 | while voice_client.is_playing(): |
| 28 | await discord.utils.sleep_until(datetime.datetime.now() + datetime.timedelta(seconds=1)) | 38 | await discord.utils.sleep_until(datetime.datetime.now() + datetime.timedelta(seconds=1)) |
| 29 | os.remove('temp_tts.mp3') | 39 | os.remove('temp_tts.mp3') |
| 30 | 40 | ||
| 41 | @commands.slash_command( | ||
| 42 | name="log_volume" | ||
| 43 | ) | ||
| 44 | async def volume(self, ctx: discord.ApplicationContext, volume: int): | ||
| 45 | try: | ||
| 46 | if not os.path.exists('settings.json'): | ||
| 47 | with open('settings.json', 'w') as f: | ||
| 48 | json.dump({'volume': '5'}, f, indent=4) | ||
| 49 | with open('settings.json', 'w') as f: | ||
| 50 | json.dump({"volume": volume}, f, indent=4) | ||
| 51 | await ctx.send(f"Volume has been set to: {volume}") | ||
| 52 | except Exception as e: | ||
| 53 | await ctx.respond(e, ephemeral=True) | ||
| 54 | print(e) | ||
| 55 | |||
| 56 | |||
| 57 | |||
| 31 | @commands.Cog.listener() | 58 | @commands.Cog.listener() |
| 32 | async def on_voice_state_update(self, member, before, after): | 59 | async def on_voice_state_update(self, member, before, after): |
| 33 | log_channel = self.bot.get_channel(1213843195457183885) | 60 | log_channel = self.bot.get_channel(1213843195457183885) |
