Skip to content
This repository was archived by the owner on Mar 25, 2020. It is now read-only.
This repository was archived by the owner on Mar 25, 2020. It is now read-only.

How to check if bot is streaming audio in a channel? #319

Description

@abdatta

I have a music bot and it streams audio from youtube well. Now I want to detect if it is already streaming something. My current code that simply streams is this:

bot.getAudioContext(user_voice_channel_id, (err, stream) => {
                if(err) return console.log(err);

                youtube.stream(url)
                    .on('error', (err) => handleError(err))
                    .pipe(stream, {end: false});
});

where youtube.stream is just the ytdl-core library.

I know I can keep a flag that is turned true when play starts and add a stream.once('done', () => flag = false), to turn it off, but this doesn't seem to be the most robust solution. The stream object itself should have some property that can tell if it is receiving any audio already.

So..... any help would be appreciated 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions