From 25ad3b076c2559b7c9c84977f22ebfae0710a28f Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Thu, 31 Mar 2022 22:52:10 -0400 Subject: [PATCH] Wait for the bot to connect before playing audio --- NoiseGatev2.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/NoiseGatev2.py b/NoiseGatev2.py index f8ae355..96a8db0 100644 --- a/NoiseGatev2.py +++ b/NoiseGatev2.py @@ -133,10 +133,13 @@ class NoiseGate(AudioStream): def core(self, error=None): if error: LOGGER.warning(error) - if voice_connection.is_connected(): - if not voice_connection.is_playing(): - LOGGER.debug(f"Playing stream to discord") - voice_connection.play(self.NGStream, after=self.core) + + while not voice_connection.is_connected(): + time.sleep(.2) + + if not voice_connection.is_playing(): + LOGGER.debug(f"Playing stream to discord") + voice_connection.play(self.NGStream, after=self.core) async def close(self): LOGGER.debug(f"Closing")