Working on bug in leaving

This commit is contained in:
Logan Cusano
2022-02-27 19:09:48 -05:00
parent 6ad489183f
commit ba237d2d53
2 changed files with 12 additions and 8 deletions

16
bot.py
View File

@@ -88,15 +88,15 @@ class Bot(commands.Bot):
await ctx.send(f"Ok {str(member).capitalize()}, I'm joining {channel}")
# Join the voice channel with the audio stream
self.voice_connection = await channel.connect()
voice_connection = await channel.connect()
# Create an audio stream from selected device
self.streamHandler = sound.PCMStream(self.DEVICE_ID)
# Start the audio stream
self.streamHandler.play()
await self.streamHandler.play()
# Play the stream
self.voice_connection.play(discord.PCMAudio(self.streamHandler))
voice_connection.play(discord.PCMAudio(self.streamHandler))
# Start the SDR and begin playing to the audio stream
self.start_sdr()
@@ -121,20 +121,24 @@ class Bot(commands.Bot):
if self.Bot_Connected:
print("Cleaning up")
# Stop the sound handlers
self.streamHandler.pause()
await self.streamHandler.pause()
print("Disconnecting")
# Disconnect the client from the voice channel
#await ctx.voice_client.disconnect()
await self.voice_connection.disconnect()
await ctx.voice_client.disconnect()
print("Changing presence")
# Change the presence to away and '@ me'
await self.set_activity(False)
# Stop the SDR so it can cool off
print("Stopping SDR")
self.stop_sdr()
print("Unlocking the bot")
# 'Unlock' the bot
self.Bot_Connected = False
print("Sending Goodbye")
await ctx.send(f"Goodbye {str(member).capitalize()}.")
else: