refactor: update search_type handling in Player and Node classes to be nullish to support lavasrc

This commit is contained in:
cloudwithax 2024-06-10 21:20:59 -04:00
parent 8679d6d125
commit 80f7b77cd3
2 changed files with 7 additions and 3 deletions

View File

@ -396,7 +396,7 @@ class Player(VoiceProtocol):
query: str,
*,
ctx: Optional[commands.Context] = None,
search_type: SearchType = SearchType.ytsearch,
search_type: SearchType | None = SearchType.ytsearch,
filters: Optional[List[Filter]] = None,
) -> Optional[Union[List[Track], Playlist]]:
"""Fetches tracks from the node's REST api to parse into Lavalink.

View File

@ -560,7 +560,7 @@ class Node:
query: str,
*,
ctx: Optional[commands.Context] = None,
search_type: SearchType = SearchType.ytsearch,
search_type: SearchType | None = SearchType.ytsearch,
filters: Optional[List[Filter]] = None,
) -> Optional[Union[Playlist, List[Track]]]:
"""Fetches tracks from the node's REST api to parse into Lavalink.
@ -707,7 +707,11 @@ class Node:
)
else:
if not URLRegex.BASE_URL.match(query) and not re.match(r"(?:[a-z]+?)search:.", query):
if (
search_type
and not URLRegex.BASE_URL.match(query)
and not re.match(r"(?:[a-z]+?)search:.", query)
):
query = f"{search_type}:{query}"
# If YouTube url contains a timestamp, capture it for use later.