Skip to content
This repository has been 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

Open
abdatta opened this issue Sep 12, 2019 · 1 comment
Open

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

abdatta opened this issue Sep 12, 2019 · 1 comment

Comments

@abdatta
Copy link

abdatta commented Sep 12, 2019

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 😄

@cloudrac3r
Copy link

just do the flag.

Questions belong in the server, not in GitHub issues. https://discord.gg/0MvHMfHcTKVVmIGP

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants