aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/vc_logs.py
diff options
context:
space:
mode:
Diffstat (limited to 'cogs/vc_logs.py')
-rw-r--r--cogs/vc_logs.py29
1 files changed, 28 insertions, 1 deletions
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
1import discord 2import discord
2from discord.ext import commands 3from discord.ext import commands
3import datetime 4import datetime
4from gtts import gTTS 5from gtts import gTTS
5import os 6import os
7import json
6 8
7class vc_logs(commands.Cog): 9class 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)