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) guild: discord.Guild = client.get_guild(guild_id)
if guild is None: if guild is None:
raise InvalidInputError("Impossibile trovare il Server specificato.") raise InvalidInputError("Impossibile trovare il Server specificato.")
voice_player: VoicePlayer = self.serf.find_voice_player(guild) voice_players = self.serf.find_voice_players(guild)
if voice_player is None: if len(voice_players):
raise UserError("Il bot non è in nessun canale vocale.\n" raise UserError("Il bot non è in nessun canale vocale.\n"
"Evocalo prima con [c]summon[/c]!") "Evocalo prima con [c]summon[/c]!")
voice_player = voice_players[0]
if voice_player.voice_client.is_paused(): if voice_player.voice_client.is_paused():
voice_player.voice_client.resume() voice_player.voice_client.resume()

View file

@ -26,10 +26,11 @@ class DiscordQueueEvent(Event):
guild: discord.Guild = client.get_guild(guild_id) guild: discord.Guild = client.get_guild(guild_id)
if guild is None: if guild is None:
raise InvalidInputError("Impossibile trovare il Server specificato.") raise InvalidInputError("Impossibile trovare il Server specificato.")
voice_player: VoicePlayer = self.serf.find_voice_player(guild) voice_players = self.serf.find_voice_players(guild)
if voice_player is None: if len(voice_players):
raise UserError("Il bot non è in nessun canale vocale.\n" raise UserError("Il bot non è in nessun canale vocale.\n"
"Evocalo prima con [c]summon[/c]!") "Evocalo prima con [c]summon[/c]!")
voice_player = voice_players[0]
if isinstance(voice_player.playing, RoyalQueue): if isinstance(voice_player.playing, RoyalQueue):
now_playing = voice_player.playing.now_playing now_playing = voice_player.playing.now_playing
return { return {

View file

@ -23,10 +23,11 @@ class DiscordSkipEvent(Event):
guild: discord.Guild = client.get_guild(guild_id) guild: discord.Guild = client.get_guild(guild_id)
if guild is None: if guild is None:
raise InvalidInputError("Impossibile trovare il Server specificato.") raise InvalidInputError("Impossibile trovare il Server specificato.")
voice_player: VoicePlayer = self.serf.find_voice_player(guild) voice_players = self.serf.find_voice_players(guild)
if voice_player is None: if len(voice_players):
raise UserError("Il bot non è in nessun canale vocale.\n" raise UserError("Il bot non è in nessun canale vocale.\n"
"Evocalo prima con [c]summon[/c]!") "Evocalo prima con [c]summon[/c]!")
voice_player = voice_players[0]
# Stop the playback of the current song # Stop the playback of the current song
voice_player.voice_client.stop() voice_player.voice_client.stop()
# Done! # Done!