From a2b5b10625126b7e98643af9fe40569c9e004047 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 18 Apr 2026 00:24:50 +0200 Subject: refactor + preparing bot for public use Signed-off-by: salmonik --- cogs/music/play_commands.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'cogs/music/play_commands.py') diff --git a/cogs/music/play_commands.py b/cogs/music/play_commands.py index e90d85f..fd5113a 100644 --- a/cogs/music/play_commands.py +++ b/cogs/music/play_commands.py @@ -23,10 +23,10 @@ class PlayCommands(commands.Cog): """Discord slash commands for music playback.""" def __init__(self, bot): + from cogs.utils.temp import get_temp_dir + self.bot = bot - self.temp_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "temp" - ) + self.temp_dir = get_temp_dir() self.path_mapping = {} # Maps display names to full paths @staticmethod @@ -104,12 +104,11 @@ class PlayCommands(commands.Cog): display = display.strip() - self.path_mapping[display] = url + if len(display) > 100: + display = display[:99] + "…" - if len(display) > 90: - display = display[:87] + "..." - - choices.append(OptionChoice(display[:100], url)) + self.path_mapping[display] = url + choices.append(OptionChoice(display, display)) if len(choices) >= 25: break @@ -167,7 +166,7 @@ class PlayCommands(commands.Cog): self, ctx: discord.ApplicationContext, file: str, compressed: bool ) -> None: """Handle file playback from copyparty URL.""" - url = file # The option value is now the URL directly + url = self.path_mapping.get(file, file) # Look up URL from display name if compressed: await self._handle_compressed_file_play(ctx, url) -- cgit v1.2.3