Working on bug in leaving

This commit is contained in:
Logan Cusano
2022-02-27 18:40:36 -05:00
parent 7fa11a4abe
commit 706f4a31df
2 changed files with 10 additions and 4 deletions

8
bot.py
View File

@@ -93,7 +93,7 @@ class Bot(commands.Bot):
# Create an audio stream from selected device
self.streamHandler = sound.PCMStream(self.DEVICE_ID)
# Start the audio stream
self.streamHandler.stream.start()
self.streamHandler.play()
# Play the stream
voice_connection.play(discord.PCMAudio(self.streamHandler))
@@ -119,12 +119,12 @@ class Bot(commands.Bot):
async def leave(ctx, member: discord.Member = None):
member = member or ctx.author.display_name
if self.Bot_Connected:
print("Cleaning up")
# Stop the sound handlers
self.streamHandler.clean_up()
print("Disconnecting")
# Disconnect the client from the voice channel
await ctx.voice_client.disconnect()
print("Cleaning up")
# Stop the sound handlers
self.streamHandler.pause()
print("Changing presence")
# Change the presence to away and '@ me'
await self.set_activity(False)

View File

@@ -26,6 +26,12 @@ class PCMStream:
self.stream.stop(ignore_errors=True)
self.stream.close(ignore_errors=True)
def pause(self):
self.stream.stop(ignore_errors=True)
def play(self):
self.stream.start()
def read(self, num_bytes):
if self.stream.active:
# frame is 4 bytes