From 791e75cb2beeca45a6edf52b65f7e299e03b5eaf Mon Sep 17 00:00:00 2001 From: SamlonDev Date: Sat, 14 Jun 2025 18:54:02 +0200 Subject: code-style issues --- cogs/tts.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'cogs/tts.py') diff --git a/cogs/tts.py b/cogs/tts.py index 41dc366..2481ab3 100644 --- a/cogs/tts.py +++ b/cogs/tts.py @@ -1,8 +1,10 @@ +import datetime +import os + import discord from discord.ext import commands from gtts import gTTS -import os -import datetime + class TTS(commands.Cog): def __init__(self, bot): @@ -10,22 +12,22 @@ class TTS(commands.Cog): @commands.slash_command(name="tts", description="Generuje TTS dla danego tekstu") async def tts(self, ctx, - text: str = discord.Option(str, "Tekst do przeczytania", required=True), - output: str = discord.Option(str, "Wybierz sposób odtwarzania", choices=["file", "vc"], required=True) - ): + text: str = discord.Option(str, "Tekst do przeczytania", required=True), + output: str = discord.Option(str, "Wybierz sposób odtwarzania", choices=["file", "vc"], required=True) + ): tts = gTTS(text=text, lang='pl') tts.save('tts.mp3') if output == "file": await ctx.respond(file=discord.File('tts.mp3')) os.remove('tts.mp3') elif output == "vc": - # Check if user is in a voice channel + # Check if the user is in a voice channel if not (ctx.author.voice and ctx.author.voice.channel): await ctx.respond("Musisz być na kanale głosowym, aby odtworzyć TTS!", ephemeral=True) os.remove('tts.mp3') return channel = ctx.author.voice.channel - # Connect to voice channel if not already connected + # Connect to the voice channel if not already connected voice_client = discord.utils.get(self.bot.voice_clients, guild=channel.guild) if not voice_client or not voice_client.is_connected(): voice_client = await channel.connect() @@ -43,5 +45,6 @@ class TTS(commands.Cog): await ctx.respond("Nieznany sposób odtwarzania.", ephemeral=True) os.remove('tts.mp3') + def setup(bot): - bot.add_cog(TTS(bot)) \ No newline at end of file + bot.add_cog(TTS(bot)) -- cgit v1.2.3