From ca0b4ecf005e1c1f4066460a45393ebffef1ef1c Mon Sep 17 00:00:00 2001 From: Samlon Date: Mon, 11 Aug 2025 17:39:21 +0200 Subject: more logging --- cogs/music/join.py | 5 +++++ cogs/music/leave.py | 14 -------------- cogs/music/loop.py | 4 ++++ cogs/music/play.py | 3 +++ cogs/music/play_compressed.py | 5 +++++ cogs/music/stop.py | 5 +++++ 6 files changed, 22 insertions(+), 14 deletions(-) delete mode 100644 cogs/music/leave.py (limited to 'cogs/music') diff --git a/cogs/music/join.py b/cogs/music/join.py index a613e81..c626897 100644 --- a/cogs/music/join.py +++ b/cogs/music/join.py @@ -1,5 +1,9 @@ from discord.ext import commands +import logging + +logger = logging.getLogger(__name__) + class Join(commands.Cog): def __init__(self, bot): @@ -8,6 +12,7 @@ class Join(commands.Cog): @commands.slash_command(name="join", description="dołącza do kanalu") async def join(self, ctx): await ctx.voice_client.connect() + logger.info("Bot connected to voice channel") def setup(bot): diff --git a/cogs/music/leave.py b/cogs/music/leave.py deleted file mode 100644 index 7be3b60..0000000 --- a/cogs/music/leave.py +++ /dev/null @@ -1,14 +0,0 @@ -from discord.ext import commands - - -class Leave(commands.Cog): - def __init__(self, bot): - self.bot = bot - - @commands.slash_command(name="kick", description="kickuje bota z kanalu") - async def kick(self, ctx): - await ctx.voice_client.disconnect() - - -def setup(bot): - bot.add_cog(Leave(bot)) diff --git a/cogs/music/loop.py b/cogs/music/loop.py index 2331840..77f87b7 100644 --- a/cogs/music/loop.py +++ b/cogs/music/loop.py @@ -1,4 +1,7 @@ from discord.ext import commands +import logging + +logger = logging.getLogger(__name__) class Loop(commands.Cog): @@ -18,6 +21,7 @@ class Loop(commands.Cog): looping = not self.is_looping(guild_id) self.set_looping(guild_id, looping) await ctx.respond(f"looping jest teraz {'włączony' if looping else 'wyłączony'}.") + logger.info(f"Looping has been {'enabled' if looping else 'disabled'} for guild {guild_id}") def setup(bot): diff --git a/cogs/music/play.py b/cogs/music/play.py index d902cdc..5664d31 100644 --- a/cogs/music/play.py +++ b/cogs/music/play.py @@ -59,6 +59,7 @@ class Play(commands.Cog): source = discord.FFmpegPCMAudio(url2, **ffmpeg_options) vc.play(source, after=after_playing) await ctx.followup.send(f"gra: {title}") + logger.info(f"Playing: {title}") except Exception as e: await ctx.followup.send(f"Wystąpił błąd podczas odtwarzania: {str(e)}") @@ -68,6 +69,7 @@ class Play(commands.Cog): if not (ctx.author.voice and ctx.author.voice.channel): await ctx.followup.send("nie jesteś w kanale głosowym") + logger.info("User is not in a voice channel") return channel = ctx.author.voice.channel @@ -82,6 +84,7 @@ class Play(commands.Cog): if not result['result']: await ctx.followup.send("nie znaleziono wideo dla twojego wyszukiwania.", ephemeral=True) + logger.info(f"Could not find a video for your search: {search}") return video = result['result'][0] diff --git a/cogs/music/play_compressed.py b/cogs/music/play_compressed.py index 038a15e..dd8dfd8 100644 --- a/cogs/music/play_compressed.py +++ b/cogs/music/play_compressed.py @@ -31,6 +31,7 @@ class GrajcujZkompresowane(commands.Cog): output_path = f"{base}_compressed.opus" ffmpeg_command = f"ffmpeg -i {input_path} -ac 1 -b:a 500 -acodec libopus {output_path}" subprocess.run(ffmpeg_command, check=True, shell=True) + logger.info(f"Audio compressed to {output_path}") return output_path @commands.slash_command(name="grajcuj_zkompresowane", description="grajcuj zkompresowane melodyje") @@ -38,10 +39,12 @@ class GrajcujZkompresowane(commands.Cog): await ctx.defer() if not (ctx.author.voice and ctx.author.voice.channel): await ctx.followup.send("nie jesteś w kanale głosowym") + logger.info("User is not in a voice channel") return channel = ctx.author.voice.channel if ctx.voice_client is not None: vc = ctx.voice_client + logger.info(f"User is already in a voice channel, moving to new {channel}") await vc.move_to(channel) else: vc = await channel.connect() @@ -81,6 +84,7 @@ class GrajcujZkompresowane(commands.Cog): compressed_file_path = self.compress_audio(file_path) except subprocess.CalledProcessError as e: await ctx.followup.send(f"skompresowanie nie powiodło się: {str(e)}", ephemeral=True) + logger.error(f"Failed to compress audio: {e}", exc_info=True) return found_file = compressed_file_path found_title = title @@ -99,6 +103,7 @@ class GrajcujZkompresowane(commands.Cog): vc.stop() vc.play(discord.FFmpegPCMAudio(found_file), after=after_playing) await ctx.followup.send(f"gra (zkompresowane): {title}") + logger.info(f"Playing audio: {title}") def setup(bot): diff --git a/cogs/music/stop.py b/cogs/music/stop.py index e842b08..c7abfbd 100644 --- a/cogs/music/stop.py +++ b/cogs/music/stop.py @@ -1,5 +1,9 @@ from discord.ext import commands +import logging + +logger = logging.getLogger(__name__) + class Stop(commands.Cog): def __init__(self, bot): @@ -8,6 +12,7 @@ class Stop(commands.Cog): @commands.slash_command(name="stop", description="stopuj bota") async def stop(self, ctx): await ctx.voice_client.disconnect() + logger.info("Bot disconnected from voice channel") def setup(bot): -- cgit v1.2.3