1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Fix find_voice_player

This commit is contained in:
Steffo 2020-03-28 18:43:42 +01:00
parent d6b2e71a1a
commit bbd49d1544

View file

@ -238,10 +238,12 @@ class DiscordSerf(Serf):
return channels[0]
def find_voice_player(self, guild: "discord.Guild") -> Optional[VoicePlayer]:
for voice_player in self.voice_players:
if not voice_player.voice_client.is_connected():
candidate_players: List[VoicePlayer] = []
for player in self.voice_players:
player: VoicePlayer
if not player.voice_client.is_connected():
continue
if voice_player.voice_client.guild == guild:
return voice_player
else:
return None
if guild is not None and guild != player.voice_client.guild:
continue
candidate_players.append(player)
return candidate_players[0] if len(candidate_players) > 0 else None