mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Audio] Show correct time remaining for bumped tracks (#3375)
* Fixes Bump play * *sigh*
This commit is contained in:
parent
cd7f4681a4
commit
41b283ce5d
1
changelog.d/audio/3373.bugfix.1.rst
Normal file
1
changelog.d/audio/3373.bugfix.1.rst
Normal file
@ -0,0 +1 @@
|
||||
``[p]bumpplay`` now shows the current remaining time until the bumped track is played.
|
||||
@ -2957,8 +2957,7 @@ class Audio(commands.Cog):
|
||||
return await self._embed_msg(ctx, embed=embed)
|
||||
elif isinstance(tracks, discord.Message):
|
||||
return
|
||||
queue_dur = await queue_duration(ctx)
|
||||
lavalink.utils.format_time(queue_dur)
|
||||
queue_dur = await track_remaining_duration(ctx)
|
||||
index = query.track_index
|
||||
seek = 0
|
||||
if query.start_time:
|
||||
|
||||
@ -211,7 +211,7 @@ class LocalPath:
|
||||
|
||||
def tracks_in_tree(self):
|
||||
tracks = []
|
||||
for track in self.multirglob(*[f"*{ext}" for ext in self._all_music_ext]):
|
||||
for track in self.multirglob(*[f"{ext}" for ext in self._all_music_ext]):
|
||||
if track.exists() and track.is_file() and track.parent != self.localtrack_folder:
|
||||
tracks.append(Query.process_input(LocalPath(str(track.absolute()))))
|
||||
return sorted(tracks, key=lambda x: x.to_string_user().lower())
|
||||
|
||||
@ -43,6 +43,7 @@ __all__ = [
|
||||
"CacheLevel",
|
||||
"format_playlist_picker_data",
|
||||
"get_track_description_unformatted",
|
||||
"track_remaining_duration",
|
||||
"Notifier",
|
||||
"PlaylistScope",
|
||||
]
|
||||
@ -126,6 +127,20 @@ async def queue_duration(ctx) -> int:
|
||||
return queue_total_duration
|
||||
|
||||
|
||||
async def track_remaining_duration(ctx) -> int:
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
if not player.current:
|
||||
return 0
|
||||
try:
|
||||
if not player.current.is_stream:
|
||||
remain = player.current.length - player.position
|
||||
else:
|
||||
remain = 0
|
||||
except AttributeError:
|
||||
remain = 0
|
||||
return remain
|
||||
|
||||
|
||||
async def draw_time(ctx) -> str:
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
paused = player.paused
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user