From 96fff959a83dddccd1c50c0cf90770723e17f0c6 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 2 Apr 2020 17:00:30 +0200 Subject: [PATCH] Fix skip, queue and pause crashing the bot --- royalpack/events/discord_pause.py | 5 +++-- royalpack/events/discord_queue.py | 5 +++-- royalpack/events/discord_skip.py | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/royalpack/events/discord_pause.py b/royalpack/events/discord_pause.py index f7733f5c..501510c6 100644 --- a/royalpack/events/discord_pause.py +++ b/royalpack/events/discord_pause.py @@ -23,10 +23,11 @@ class DiscordPauseEvent(Event): guild: discord.Guild = client.get_guild(guild_id) if guild is None: raise InvalidInputError("Impossibile trovare il Server specificato.") - voice_player: VoicePlayer = self.serf.find_voice_player(guild) - if voice_player is None: + voice_players = self.serf.find_voice_players(guild) + if len(voice_players): raise UserError("Il bot non è in nessun canale vocale.\n" "Evocalo prima con [c]summon[/c]!") + voice_player = voice_players[0] if voice_player.voice_client.is_paused(): voice_player.voice_client.resume() diff --git a/royalpack/events/discord_queue.py b/royalpack/events/discord_queue.py index 6a668f05..3345e8dc 100644 --- a/royalpack/events/discord_queue.py +++ b/royalpack/events/discord_queue.py @@ -26,10 +26,11 @@ class DiscordQueueEvent(Event): guild: discord.Guild = client.get_guild(guild_id) if guild is None: raise InvalidInputError("Impossibile trovare il Server specificato.") - voice_player: VoicePlayer = self.serf.find_voice_player(guild) - if voice_player is None: + voice_players = self.serf.find_voice_players(guild) + if len(voice_players): raise UserError("Il bot non è in nessun canale vocale.\n" "Evocalo prima con [c]summon[/c]!") + voice_player = voice_players[0] if isinstance(voice_player.playing, RoyalQueue): now_playing = voice_player.playing.now_playing return { diff --git a/royalpack/events/discord_skip.py b/royalpack/events/discord_skip.py index cb186f35..e6537d86 100644 --- a/royalpack/events/discord_skip.py +++ b/royalpack/events/discord_skip.py @@ -23,10 +23,11 @@ class DiscordSkipEvent(Event): guild: discord.Guild = client.get_guild(guild_id) if guild is None: raise InvalidInputError("Impossibile trovare il Server specificato.") - voice_player: VoicePlayer = self.serf.find_voice_player(guild) - if voice_player is None: + voice_players = self.serf.find_voice_players(guild) + if len(voice_players): raise UserError("Il bot non è in nessun canale vocale.\n" "Evocalo prima con [c]summon[/c]!") + voice_player = voice_players[0] # Stop the playback of the current song voice_player.voice_client.stop() # Done!