Skip to content
Discussion options

You must be logged in to vote

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:

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

elapsed can then be accessed from the voice client

guild.voice_client.source.elapsed / 1000 # milliseconds -> seconds

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by f1refa11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants