Fixed no song suggestions when spotify_client is None

This commit is contained in:
Choco
2024-08-24 10:27:40 +08:00
parent 5be87b60ee
commit 9c32fd4767
2 changed files with 7 additions and 7 deletions

View File

@@ -345,7 +345,7 @@ class Player(VoiceProtocol):
self.shuffle_votes.clear()
self.stop_votes.clear()
track: Track = self.queue.get()
track = self.queue.get()
if not track:
if self.settings.get("autoplay", False) and await self.get_recommendations():
@@ -762,7 +762,7 @@ class Player(VoiceProtocol):
if self.volume != 100:
await self.set_volume(self.volume)
async def get_recommendations(self, *, track: Track = None) -> bool:
async def get_recommendations(self, *, track: Optional[Track] = None) -> bool:
"""Get recommendations from Youtube or Spotify."""
if not track:
try:

View File

@@ -515,12 +515,12 @@ class Node:
)
for track in tracks ]
async def get_recommendations(self, track: Track, limit: int = None) -> List[Track]:
if not self.spotify_client:
return
async def get_recommendations(self, track: Track, limit: int = None) -> List[Optional[Track]]:
if track.spotify:
spotify_tracks = await self._spotify_client.similar_track(seed_tracks=track.identifier, limit=limit)
if not self.spotify_client:
return []
spotify_tracks = await self.spotify_client.similar_track(seed_tracks=track.identifier, limit=limit)
tracks = [
Track(