Skip to content

Commit

Permalink
🔄Refactor(voice_client.py): on_voice_state_update function to handle …
Browse files Browse the repository at this point in the history
…voice state updates more efficiently.
  • Loading branch information
Mantouisyummy committed Dec 24, 2023
1 parent 95eeb17 commit cfe3bba
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lava/voice_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ async def on_voice_state_update(self, data):
'd': data
}

channel = get(self.channel.guild.voice_channels, id=int(data['channel_id']))
self.channel = channel

await self.lavalink.voice_update_handler(lavalink_data)

if not data['channel_id']:
if data['channel_id']:
channel = get(self.channel.guild.voice_channels, id=int(data['channel_id']))
self.channel = channel
await self.lavalink.voice_update_handler(lavalink_data)
else:
await self.channel.guild.change_voice_state(channel=None)
self.cleanup()

async def connect(self, *, timeout: float, reconnect: bool, self_deaf: bool = False,
Expand Down

0 comments on commit cfe3bba

Please sign in to comment.