Skip to content

Commit

Permalink
[Spotify] Handle no input in Play on Spotify command nicely
Browse files Browse the repository at this point in the history
  • Loading branch information
TrustyJAID committed Feb 14, 2024
1 parent 8e2b2fb commit 6e577a5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions spotify/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,15 @@ async def play_from_message(self, interaction: discord.Interaction, message: dis

user_spotify = tekore.Spotify(sender=self._sender)
if not any(tracks + albums + playlists):
with user_spotify.token_as(user_token):
search = await user_spotify.search(
message.content, ("track",), "from_token", limit=50
)
items = search[0].items
try:
with user_spotify.token_as(user_token):
search = await user_spotify.search(
message.content, ("track",), "from_token", limit=50
)
items = search[0].items
except Exception:
await ctx.send(_("No tracks found from that search."))
return
if len(items) > 1:
x = SpotifySearchMenu(
source=SpotifyTrackPages(items=items, detailed=False),
Expand Down

0 comments on commit 6e577a5

Please sign in to comment.