aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/music
diff options
context:
space:
mode:
authorSamlon <stankiewiczgracjan2019@gmail.com>2025-08-11 17:39:21 +0200
committerSamlon <stankiewiczgracjan2019@gmail.com>2025-08-11 17:39:21 +0200
commitca0b4ecf005e1c1f4066460a45393ebffef1ef1c (patch)
tree4c175ba876ae35d9248dfab33d2a981fe3cfb207 /cogs/music
parentchanged printing to proper logging (diff)
downloadsenator-sperma-ca0b4ecf005e1c1f4066460a45393ebffef1ef1c.tar.gz
senator-sperma-ca0b4ecf005e1c1f4066460a45393ebffef1ef1c.zip
more logging
Diffstat (limited to 'cogs/music')
-rw-r--r--cogs/music/join.py5
-rw-r--r--cogs/music/leave.py14
-rw-r--r--cogs/music/loop.py4
-rw-r--r--cogs/music/play.py3
-rw-r--r--cogs/music/play_compressed.py5
-rw-r--r--cogs/music/stop.py5
6 files changed, 22 insertions, 14 deletions
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 @@
1from discord.ext import commands 1from discord.ext import commands
2 2
3import logging
4
5logger = logging.getLogger(__name__)
6
3 7
4class Join(commands.Cog): 8class Join(commands.Cog):
5 def __init__(self, bot): 9 def __init__(self, bot):
@@ -8,6 +12,7 @@ class Join(commands.Cog):
8 @commands.slash_command(name="join", description="dołącza do kanalu") 12 @commands.slash_command(name="join", description="dołącza do kanalu")
9 async def join(self, ctx): 13 async def join(self, ctx):
10 await ctx.voice_client.connect() 14 await ctx.voice_client.connect()
15 logger.info("Bot connected to voice channel")
11 16
12 17
13def setup(bot): 18def 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 @@
1from discord.ext import commands
2
3
4class Leave(commands.Cog):
5 def __init__(self, bot):
6 self.bot = bot
7
8 @commands.slash_command(name="kick", description="kickuje bota z kanalu")
9 async def kick(self, ctx):
10 await ctx.voice_client.disconnect()
11
12
13def setup(bot):
14 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 @@
1from discord.ext import commands 1from discord.ext import commands
2import logging
3
4logger = logging.getLogger(__name__)
2 5
3 6
4class Loop(commands.Cog): 7class Loop(commands.Cog):
@@ -18,6 +21,7 @@ class Loop(commands.Cog):
18 looping = not self.is_looping(guild_id) 21 looping = not self.is_looping(guild_id)
19 self.set_looping(guild_id, looping) 22 self.set_looping(guild_id, looping)
20 await ctx.respond(f"looping jest teraz {'włączony' if looping else 'wyłączony'}.") 23 await ctx.respond(f"looping jest teraz {'włączony' if looping else 'wyłączony'}.")
24 logger.info(f"Looping has been {'enabled' if looping else 'disabled'} for guild {guild_id}")
21 25
22 26
23def setup(bot): 27def 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):
59 source = discord.FFmpegPCMAudio(url2, **ffmpeg_options) 59 source = discord.FFmpegPCMAudio(url2, **ffmpeg_options)
60 vc.play(source, after=after_playing) 60 vc.play(source, after=after_playing)
61 await ctx.followup.send(f"gra: {title}") 61 await ctx.followup.send(f"gra: {title}")
62 logger.info(f"Playing: {title}")
62 except Exception as e: 63 except Exception as e:
63 await ctx.followup.send(f"Wystąpił błąd podczas odtwarzania: {str(e)}") 64 await ctx.followup.send(f"Wystąpił błąd podczas odtwarzania: {str(e)}")
64 65
@@ -68,6 +69,7 @@ class Play(commands.Cog):
68 69
69 if not (ctx.author.voice and ctx.author.voice.channel): 70 if not (ctx.author.voice and ctx.author.voice.channel):
70 await ctx.followup.send("nie jesteś w kanale głosowym") 71 await ctx.followup.send("nie jesteś w kanale głosowym")
72 logger.info("User is not in a voice channel")
71 return 73 return
72 74
73 channel = ctx.author.voice.channel 75 channel = ctx.author.voice.channel
@@ -82,6 +84,7 @@ class Play(commands.Cog):
82 84
83 if not result['result']: 85 if not result['result']:
84 await ctx.followup.send("nie znaleziono wideo dla twojego wyszukiwania.", ephemeral=True) 86 await ctx.followup.send("nie znaleziono wideo dla twojego wyszukiwania.", ephemeral=True)
87 logger.info(f"Could not find a video for your search: {search}")
85 return 88 return
86 89
87 video = result['result'][0] 90 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):
31 output_path = f"{base}_compressed.opus" 31 output_path = f"{base}_compressed.opus"
32 ffmpeg_command = f"ffmpeg -i {input_path} -ac 1 -b:a 500 -acodec libopus {output_path}" 32 ffmpeg_command = f"ffmpeg -i {input_path} -ac 1 -b:a 500 -acodec libopus {output_path}"
33 subprocess.run(ffmpeg_command, check=True, shell=True) 33 subprocess.run(ffmpeg_command, check=True, shell=True)
34 logger.info(f"Audio compressed to {output_path}")
34 return output_path 35 return output_path
35 36
36 @commands.slash_command(name="grajcuj_zkompresowane", description="grajcuj zkompresowane melodyje") 37 @commands.slash_command(name="grajcuj_zkompresowane", description="grajcuj zkompresowane melodyje")
@@ -38,10 +39,12 @@ class GrajcujZkompresowane(commands.Cog):
38 await ctx.defer() 39 await ctx.defer()
39 if not (ctx.author.voice and ctx.author.voice.channel): 40 if not (ctx.author.voice and ctx.author.voice.channel):
40 await ctx.followup.send("nie jesteś w kanale głosowym") 41 await ctx.followup.send("nie jesteś w kanale głosowym")
42 logger.info("User is not in a voice channel")
41 return 43 return
42 channel = ctx.author.voice.channel 44 channel = ctx.author.voice.channel
43 if ctx.voice_client is not None: 45 if ctx.voice_client is not None:
44 vc = ctx.voice_client 46 vc = ctx.voice_client
47 logger.info(f"User is already in a voice channel, moving to new {channel}")
45 await vc.move_to(channel) 48 await vc.move_to(channel)
46 else: 49 else:
47 vc = await channel.connect() 50 vc = await channel.connect()
@@ -81,6 +84,7 @@ class GrajcujZkompresowane(commands.Cog):
81 compressed_file_path = self.compress_audio(file_path) 84 compressed_file_path = self.compress_audio(file_path)
82 except subprocess.CalledProcessError as e: 85 except subprocess.CalledProcessError as e:
83 await ctx.followup.send(f"skompresowanie nie powiodło się: {str(e)}", ephemeral=True) 86 await ctx.followup.send(f"skompresowanie nie powiodło się: {str(e)}", ephemeral=True)
87 logger.error(f"Failed to compress audio: {e}", exc_info=True)
84 return 88 return
85 found_file = compressed_file_path 89 found_file = compressed_file_path
86 found_title = title 90 found_title = title
@@ -99,6 +103,7 @@ class GrajcujZkompresowane(commands.Cog):
99 vc.stop() 103 vc.stop()
100 vc.play(discord.FFmpegPCMAudio(found_file), after=after_playing) 104 vc.play(discord.FFmpegPCMAudio(found_file), after=after_playing)
101 await ctx.followup.send(f"gra (zkompresowane): {title}") 105 await ctx.followup.send(f"gra (zkompresowane): {title}")
106 logger.info(f"Playing audio: {title}")
102 107
103 108
104def setup(bot): 109def 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 @@
1from discord.ext import commands 1from discord.ext import commands
2 2
3import logging
4
5logger = logging.getLogger(__name__)
6
3 7
4class Stop(commands.Cog): 8class Stop(commands.Cog):
5 def __init__(self, bot): 9 def __init__(self, bot):
@@ -8,6 +12,7 @@ class Stop(commands.Cog):
8 @commands.slash_command(name="stop", description="stopuj bota") 12 @commands.slash_command(name="stop", description="stopuj bota")
9 async def stop(self, ctx): 13 async def stop(self, ctx):
10 await ctx.voice_client.disconnect() 14 await ctx.voice_client.disconnect()
15 logger.info("Bot disconnected from voice channel")
11 16
12 17
13def setup(bot): 18def setup(bot):