fix: make !volume apply immediately during playback

stream_audio now accepts a callable for volume, re-read on each PCM
frame instead of capturing a static float at track start.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
user
2026-02-21 23:20:17 +01:00
parent eae36aa1f9
commit 67b2dc827d
4 changed files with 16 additions and 10 deletions

View File

@@ -78,10 +78,11 @@ async def _play_loop(bot) -> None:
done = asyncio.Event()
ps["done_event"] = done
volume = ps["volume"] / 100.0
try:
await bot.stream_audio(
track.url, volume=volume, on_done=done,
track.url,
volume=lambda: ps["volume"] / 100.0,
on_done=done,
)
except asyncio.CancelledError:
raise
@@ -269,7 +270,7 @@ async def cmd_volume(bot, message):
Usage:
!volume Show current volume
!volume <0-100> Set volume (applies on next track)
!volume <0-100> Set volume (takes effect immediately)
"""
if not _is_mumble(bot):
return