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

Fix skip, queue and pause crashing the bot

This commit is contained in:
Steffo 2020-04-02 17:00:30 +02:00
parent 877fad5b2b
commit 96fff959a8
3 changed files with 9 additions and 6 deletions

View file

@ -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()

View file

@ -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 {

View file

@ -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!