aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamlon <stankiewiczgracjan2019@gmail.com>2025-08-21 12:22:00 +0200
committerSamlon <stankiewiczgracjan2019@gmail.com>2025-08-21 12:22:00 +0200
commitd4248bca50064d4435db713cf2c81a007d394c63 (patch)
treef43996574b412cad31150ea848ac45ff384909aa
parentplay.py rework (diff)
downloadsenator-sperma-d4248bca50064d4435db713cf2c81a007d394c63.tar.gz
senator-sperma-d4248bca50064d4435db713cf2c81a007d394c63.zip
small changes
Diffstat (limited to '')
-rw-r--r--cogs/music/join.py2
-rw-r--r--cogs/music/stop.py2
-rw-r--r--cogs/tts.py10
3 files changed, 6 insertions, 8 deletions
diff --git a/cogs/music/join.py b/cogs/music/join.py
index 47c746f..a68282c 100644
--- a/cogs/music/join.py
+++ b/cogs/music/join.py
@@ -14,7 +14,7 @@ class Join(commands.Cog):
14 channel = ctx.author.voice.channel 14 channel = ctx.author.voice.channel
15 await channel.connect() 15 await channel.connect()
16 await ctx.respond(content="\u200b", ephemeral=True) 16 await ctx.respond(content="\u200b", ephemeral=True)
17 await ctx.interaction.delete_original_message() 17 await ctx.interaction.delete_original_response()
18 logger.info("Bot connected to voice channel") 18 logger.info("Bot connected to voice channel")
19 19
20 20
diff --git a/cogs/music/stop.py b/cogs/music/stop.py
index 5713c81..e04370e 100644
--- a/cogs/music/stop.py
+++ b/cogs/music/stop.py
@@ -12,7 +12,7 @@ class Stop(commands.Cog):
12 @commands.slash_command(name="stop", description="stopuj bota") 12 @commands.slash_command(name="stop", description="stopuj bota")
13 async def stop(self, ctx): 13 async def stop(self, ctx):
14 await ctx.respond(content="\u200b", ephemeral=True) 14 await ctx.respond(content="\u200b", ephemeral=True)
15 await ctx.interaction.delete_original_message() 15 await ctx.interaction.delete_original_response()
16 await ctx.voice_client.disconnect() 16 await ctx.voice_client.disconnect()
17 logger.info("Bot disconnected from voice channel") 17 logger.info("Bot disconnected from voice channel")
18 18
diff --git a/cogs/tts.py b/cogs/tts.py
index 7461a1f..74fc12c 100644
--- a/cogs/tts.py
+++ b/cogs/tts.py
@@ -17,6 +17,7 @@ class TTS(commands.Cog):
17 text: str = discord.Option(str, "Tekst do przeczytania", required=True), 17 text: str = discord.Option(str, "Tekst do przeczytania", required=True),
18 output: str = discord.Option(str, "Wybierz sposób odtwarzania", choices=["file", "vc"], default="vc") 18 output: str = discord.Option(str, "Wybierz sposób odtwarzania", choices=["file", "vc"], default="vc")
19 ): 19 ):
20 await ctx.defer()
20 tts = gTTS(text=text, lang='pl') 21 tts = gTTS(text=text, lang='pl')
21 tts.save('tts.mp3') 22 tts.save('tts.mp3')
22 23
@@ -29,11 +30,11 @@ class TTS(commands.Cog):
29 30
30 if output == "file": 31 if output == "file":
31 await ctx.respond(file=discord.File('tts.mp3')) 32 await ctx.respond(file=discord.File('tts.mp3'))
32 logger.info("TTS file sent") 33 logger.info(f"sent {text}")
33 os.remove('tts.mp3') 34 os.remove('tts.mp3')
34 elif output == "vc": 35 elif output == "vc":
35 await ctx.respond(content="\u200b", ephemeral=True) 36 await ctx.respond(content="\u200b", ephemeral=True)
36 await ctx.interaction.delete_original_message() 37 await ctx.interaction.delete_original_response()
37 38
38 # Check if the user is in a voice channel 39 # Check if the user is in a voice channel
39 if not (ctx.author.voice and ctx.author.voice.channel): 40 if not (ctx.author.voice and ctx.author.voice.channel):
@@ -50,11 +51,8 @@ class TTS(commands.Cog):
50 # Play the TTS audio 51 # Play the TTS audio
51 if not voice_client.is_playing(): 52 if not voice_client.is_playing():
52 audio_source = discord.FFmpegPCMAudio('tts.mp3', options=f'-filter:a "volume={volume}"') 53 audio_source = discord.FFmpegPCMAudio('tts.mp3', options=f'-filter:a "volume={volume}"')
53 logger.info("TTS audio played") 54 logger.info(f"playing {text}")
54 voice_client.play(audio_source) 55 voice_client.play(audio_source)
55 # Wait for playback to finish
56 while voice_client.is_playing():
57 await discord.utils.sleep_until(datetime.datetime.now() + datetime.timedelta(seconds=1))
58 os.remove('tts.mp3') 56 os.remove('tts.mp3')
59 else: 57 else:
60 await ctx.respond("Nieznany sposób odtwarzania.", ephemeral=True) 58 await ctx.respond("Nieznany sposób odtwarzania.", ephemeral=True)