Skip to content

Commit

Permalink
jockey: Don't force disconnect while already playing
Browse files Browse the repository at this point in the history
  • Loading branch information
jareddantis committed Jul 14, 2023
1 parent 836b752 commit 4a8dfec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 6 additions & 0 deletions utils/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ def __init__(self, reason):


class JockeyError(Exception):
"""
Raised when an error warrants disconnection from the voice channel.
"""
pass


class JockeyException(Exception):
"""
Raised when an error does not warrant disconnection from the voice channel.
"""
pass


Expand Down
13 changes: 3 additions & 10 deletions utils/jockey.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,12 @@ async def play_impl(self, query: str, requester: int) -> str:
query,
requester
)
except IndexError:
raise JockeyError('No results found for query')
except LavalinkInvalidIdentifierError as e:
raise JockeyError(f'Invalid identifier: {e}')
except SpotifyInvalidURLError:
raise JockeyError('Can only play tracks, albums, and playlists from Spotify')
except SpotifyNoResultsError:
raise JockeyError('No results found for query, or playlist or album is empty')
except JockeyException:
# Just bubble this up
raise
except Exception as e:
raise JockeyError(f'Error parsing query: {e}')
if self.playing:
raise JockeyException(str(e))
raise JockeyError(str(e))

# Add new tracks to queue
old_size = len(self._queue)
Expand Down

0 comments on commit 4a8dfec

Please sign in to comment.