-
I need to get current music time to show it in the console(like 1:23/4:56), but i really don't know how to implement this. P.S. I found some code there: https://www.reddit.com/r/Discord_Bots/comments/q9jl5b/how_to_make_discordpy_bot_display_current_song/ but i still don't understand where should i put this code. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Sorry for the late response. You just need to subclass the audio source class that your code uses - for example, to have it work with class TrackedFFmpegOpusAudio(discord.FFmpegOpusAudio):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.elapsed: int = 0
def read(self, *args, **kwargs):
ret = super().read()
if ret:
self.elapsed += 20
return ret
guild.voice_client.source.elapsed / 1000 # milliseconds -> seconds |
Beta Was this translation helpful? Give feedback.
Sorry for the late response.
You just need to subclass the audio source class that your code uses - for example, to have it work with
FFmpegOpusAudio
you can do the following:elapsed
can then be accessed from the voice client