From 9d97399504ae81fb443606666b1b63c5632e6c9a Mon Sep 17 00:00:00 2001 From: Samlon Date: Mon, 11 Aug 2025 17:55:20 +0200 Subject: more logs!?!?! --- cogs/music/play.py | 1 + cogs/tts.py | 5 ++++- cogs/vclogs.py | 3 +++ cogs/web.py | 9 +++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) (limited to 'cogs') diff --git a/cogs/music/play.py b/cogs/music/play.py index 5664d31..e75c91f 100644 --- a/cogs/music/play.py +++ b/cogs/music/play.py @@ -62,6 +62,7 @@ class Play(commands.Cog): logger.info(f"Playing: {title}") except Exception as e: await ctx.followup.send(f"Wystąpił błąd podczas odtwarzania: {str(e)}") + logger.error(f"Error playing audio: {e}", exc_info=True) @commands.slash_command(name="grajcuj", description="grajcuj melodyje") async def play(self, ctx, *, search: str): diff --git a/cogs/tts.py b/cogs/tts.py index dceb26c..8076a2d 100644 --- a/cogs/tts.py +++ b/cogs/tts.py @@ -22,12 +22,13 @@ class TTS(commands.Cog): tts.save('tts.mp3') if output == "file": await ctx.respond(file=discord.File('tts.mp3')) + logger.info("TTS file sent") os.remove('tts.mp3') elif output == "vc": # 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) - logger.info("tts: User is not in a voice channel") + logger.info("User is not in a voice channel") os.remove('tts.mp3') return channel = ctx.author.voice.channel @@ -40,6 +41,7 @@ class TTS(commands.Cog): # Play the TTS audio if not voice_client.is_playing(): audio_source = discord.FFmpegPCMAudio('tts.mp3', options='-filter:a "volume=6"') + logger.info("TTS audio played") voice_client.play(audio_source) # Wait for playback to finish while voice_client.is_playing(): @@ -47,6 +49,7 @@ class TTS(commands.Cog): os.remove('tts.mp3') else: await ctx.respond("Nieznany sposób odtwarzania.", ephemeral=True) + logger.info("Unknown playback method") os.remove('tts.mp3') diff --git a/cogs/vclogs.py b/cogs/vclogs.py index ed0737b..a9672ac 100644 --- a/cogs/vclogs.py +++ b/cogs/vclogs.py @@ -66,6 +66,7 @@ class VcLogs(commands.Cog): else: with open('settings.json', 'w') as f: json.dump({'volume': '5'}, f, indent=4) + logger.info("settings.json created") audio_source = discord.FFmpegPCMAudio('temp_tts.mp3', options=f'-filter:a "volume={volume}"') voice_client.play(audio_source) @@ -81,9 +82,11 @@ class VcLogs(commands.Cog): if not os.path.exists('settings.json'): with open('settings.json', 'w') as f: json.dump({'volume': '5'}, f, indent=4) + logger.info("settings.json created") with open('settings.json', 'w') as f: json.dump({"volume": volume}, f, indent=4) await ctx.followup.send(f"Volume has been set to: {volume}") + logger.info(f"Volume changed to: {volume}") except Exception as e: await ctx.respond(e, ephemeral=True) logger.error(f"Error in volume command: {e}", exc_info=True) diff --git a/cogs/web.py b/cogs/web.py index bea684b..9431e84 100644 --- a/cogs/web.py +++ b/cogs/web.py @@ -5,6 +5,9 @@ import requests from bs4 import BeautifulSoup import urllib.parse import pytube +import logging + +logger = logging.getLogger(__name__) class Web(commands.Cog): def __init__(self, bot): @@ -24,6 +27,8 @@ class Web(commands.Cog): url = f"https://duckduckgo.com/html/?q={query}" response = requests.get(url, headers=headers) + logger.info(f"Query: {query}") + if response.status_code == 200: soup = BeautifulSoup(response.text, 'html.parser') links = soup.find_all('a', class_='result__a') @@ -33,6 +38,7 @@ class Web(commands.Cog): for i, link in enumerate(links[:5], start=1): title = link.text if link.get('href').startswith('https://www.youtube.com/'): + logger.info("youtube link") try: parsed_url = urllib.parse.urlparse(link.get('href')) video_id = urllib.parse.parse_qs(parsed_url.query).get('v', [None])[0] @@ -48,10 +54,13 @@ class Web(commands.Cog): button.callback = button_callback view.add_item(button) await ctx.respond(embed=embed, view=view, ephemeral=True) + logger.info("Search results sent") else: await ctx.respond(content="No results found.", ephemeral=True) + logger.warning("No results found") else: await ctx.respond(content=f"Error: {response.status_code}", ephemeral=True) + logger.error(f"Error: {response.status_code}") def setup(bot): bot.add_cog(Web(bot)) -- cgit v1.2.3