aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/music/play_commands.py
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-04-18 00:24:50 +0200
committersalmonik <raisersoft@proton.me>2026-04-18 00:24:50 +0200
commita2b5b10625126b7e98643af9fe40569c9e004047 (patch)
tree2b59a929d068bc28bbc21e8c8d8836e4d29270c0 /cogs/music/play_commands.py
parentadd mathematical plotting (diff)
downloadsenator-sperma-a2b5b10625126b7e98643af9fe40569c9e004047.tar.gz
senator-sperma-a2b5b10625126b7e98643af9fe40569c9e004047.zip
refactor + preparing bot for public use
Signed-off-by: salmonik <raisersoft@proton.me>
Diffstat (limited to 'cogs/music/play_commands.py')
-rw-r--r--cogs/music/play_commands.py17
1 files changed, 8 insertions, 9 deletions
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):
23 """Discord slash commands for music playback.""" 23 """Discord slash commands for music playback."""
24 24
25 def __init__(self, bot): 25 def __init__(self, bot):
26 from cogs.utils.temp import get_temp_dir
27
26 self.bot = bot 28 self.bot = bot
27 self.temp_dir = os.path.join( 29 self.temp_dir = get_temp_dir()
28 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "temp"
29 )
30 self.path_mapping = {} # Maps display names to full paths 30 self.path_mapping = {} # Maps display names to full paths
31 31
32 @staticmethod 32 @staticmethod
@@ -104,12 +104,11 @@ class PlayCommands(commands.Cog):
104 104
105 display = display.strip() 105 display = display.strip()
106 106
107 self.path_mapping[display] = url 107 if len(display) > 100:
108 display = display[:99] + "…"
108 109
109 if len(display) > 90: 110 self.path_mapping[display] = url
110 display = display[:87] + "..." 111 choices.append(OptionChoice(display, display))
111
112 choices.append(OptionChoice(display[:100], url))
113 112
114 if len(choices) >= 25: 113 if len(choices) >= 25:
115 break 114 break
@@ -167,7 +166,7 @@ class PlayCommands(commands.Cog):
167 self, ctx: discord.ApplicationContext, file: str, compressed: bool 166 self, ctx: discord.ApplicationContext, file: str, compressed: bool
168 ) -> None: 167 ) -> None:
169 """Handle file playback from copyparty URL.""" 168 """Handle file playback from copyparty URL."""
170 url = file # The option value is now the URL directly 169 url = self.path_mapping.get(file, file) # Look up URL from display name
171 170
172 if compressed: 171 if compressed:
173 await self._handle_compressed_file_play(ctx, url) 172 await self._handle_compressed_file_play(ctx, url)