aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/music
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-04-20 15:05:51 +0200
committersalmonik <raisersoft@proton.me>2026-04-20 15:05:51 +0200
commitc687d9fa1d89fef8ddc7150d1487dfef07d11abb (patch)
tree61166219a1fe77c22b4623efe9320fcb1b866525 /cogs/music
parentlil cron fix (diff)
downloadsenator-sperma-c687d9fa1d89fef8ddc7150d1487dfef07d11abb.tar.gz
senator-sperma-c687d9fa1d89fef8ddc7150d1487dfef07d11abb.zip
uploader.py and voice fixes
Signed-off-by: salmonik <raisersoft@proton.me>
Diffstat (limited to '')
-rw-r--r--cogs/music/audio_playback.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/cogs/music/audio_playback.py b/cogs/music/audio_playback.py
index 28c6118..1c715de 100644
--- a/cogs/music/audio_playback.py
+++ b/cogs/music/audio_playback.py
@@ -137,8 +137,16 @@ class AudioPlaybackManager:
137 return absolute_source, display_name, is_url 137 return absolute_source, display_name, is_url
138 138
139 @staticmethod 139 @staticmethod
140 async def execute_playback(ctx, source, display_name, is_url): 140 async def execute_playback(ctx, source, display_name, is_url, interrupt=True):
141 """Execute the actual audio playback.""" 141 """Execute the actual audio playback.
142
143 Args:
144 ctx: Discord context
145 source: Audio source path or URL
146 display_name: Name to display
147 is_url: Whether source is a URL
148 interrupt: If True, stop any currently playing audio. If False, skip if audio is playing.
149 """
142 target_channel = await AudioPlaybackManager.validate_voice_channel(ctx) 150 target_channel = await AudioPlaybackManager.validate_voice_channel(ctx)
143 if not target_channel: 151 if not target_channel:
144 return False 152 return False
@@ -169,9 +177,12 @@ class AudioPlaybackManager:
169 logger.info(f"Moving to voice channel: {target_channel.name}") 177 logger.info(f"Moving to voice channel: {target_channel.name}")
170 await vc.move_to(target_channel) 178 await vc.move_to(target_channel)
171 179
172 # Stop any currently playing audio 180 # Stop any currently playing audio (if interrupt is True)
173 if vc.is_playing() or vc.is_paused(): # type: ignore[union-attr] 181 if interrupt and (vc.is_playing() or vc.is_paused()): # type: ignore[union-attr]
174 vc.stop() # type: ignore[union-attr] 182 vc.stop() # type: ignore[union-attr]
183 elif not interrupt and vc.is_playing(): # type: ignore[union-attr]
184 logger.info("Audio already playing and interrupt=False, skipping playback")
185 return False
175 186
176 # Prepare audio source 187 # Prepare audio source
177 ( 188 (
@@ -232,13 +243,14 @@ class AudioPlaybackManager:
232 return prepared_source, display_name, is_url 243 return prepared_source, display_name, is_url
233 244
234 @staticmethod 245 @staticmethod
235 async def play(ctx, source, delete_after_play=False): 246 async def play(ctx, source, delete_after_play=False, interrupt=True):
236 """Play audio from a local file or URL. 247 """Play audio from a local file or URL.
237 248
238 Args: 249 Args:
239 ctx: Discord context 250 ctx: Discord context
240 source: Either a local file path or a URL to stream from 251 source: Either a local file path or a URL to stream from
241 delete_after_play: If True, delete the file after playing (only for local files) 252 delete_after_play: If True, delete the file after playing (only for local files)
253 interrupt: If True, stop any currently playing audio. If False, skip if audio is playing.
242 """ 254 """
243 # Validate and prepare source 255 # Validate and prepare source
244 ( 256 (
@@ -254,7 +266,7 @@ class AudioPlaybackManager:
254 266
255 # Execute playback 267 # Execute playback
256 success = await AudioPlaybackManager.execute_playback( 268 success = await AudioPlaybackManager.execute_playback(
257 ctx, prepared_source, display_name, is_url 269 ctx, prepared_source, display_name, is_url, interrupt
258 ) 270 )
259 271
260 # Cleanup if needed 272 # Cleanup if needed