From 7479f9bfe253ddb9db654850e34b0b4249916d9a Mon Sep 17 00:00:00 2001 From: Choco <94597336+ChocoMeow@users.noreply.github.com> Date: Wed, 8 Oct 2025 12:19:40 +0800 Subject: [PATCH] Show track length in autocomplete choices Track autocomplete choices now display the formatted track length for both current tracks and history, improving user clarity when selecting tracks. --- cogs/basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cogs/basic.py b/cogs/basic.py index a66f70c..3017b8e 100644 --- a/cogs/basic.py +++ b/cogs/basic.py @@ -95,10 +95,10 @@ class Basic(commands.Cog): if isinstance(tracks, voicelink.Playlist): tracks = tracks.tracks - return [app_commands.Choice(name=truncate_string(f"🎵 {track.author} - {track.title}", 100), value=truncate_string(f"{track.author} - {track.title}", 100)) for track in tracks] + return [app_commands.Choice(name=truncate_string(f"🎵 [{track.formatted_length}] {track.author} - {track.title}", 100), value=track.uri) for track in tracks] history = {track["identifier"]: track for track_id in reversed(await MongoDBHandler.get_user(interaction.user.id, d_type="history")) if (track := voicelink.Track.decode(track_id))["uri"]} - return [app_commands.Choice(name=truncate_string(f"🕒 {track['author']} - {track['title']}", 100), value=track['uri']) for track in history.values() if len(track['uri']) <= 100][:25] + return [app_commands.Choice(name=truncate_string(f"🕒 [{format_ms(track['length'])}] {track['author']} - {track['title']}", 100), value=track['uri']) for track in history.values() if len(track['uri']) <= 100][:25] @commands.hybrid_command(name="connect", aliases=get_aliases("connect")) @app_commands.describe(channel="Provide a channel to connect.")